Skip to content

Commit 5407a10

Browse files
committed
shell.nix: Support nix-shell -A
It used to be that `nix-shell -A hello` would launch the build shell for the `hello` package. By adding `/shell.nix`, that stopped working, as all versions of `nix-shell` resolve the unspecified file to `$PWD/shell.nix` if it exists, and now it does. I have to admit that this use of `//` is not pretty, but the UX/DX hard to match.
1 parent 6b2e0aa commit 5407a10

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

shell.nix

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
}:
1818
let
1919
inherit (import ./ci { inherit nixpkgs system; }) pkgs;
20+
21+
# For `nix-shell -A hello`
22+
curPkgs = builtins.removeAttrs (import ./. { inherit system; }) [
23+
# Although this is what anyone may expect from a `_type = "pkgs"`,
24+
# this file is intended to produce a shell in the first place,
25+
# and a `_type` tag could confuse some code.
26+
"_type"
27+
];
2028
in
21-
pkgs.mkShellNoCC {
29+
curPkgs
30+
// pkgs.mkShellNoCC {
2231
packages = with pkgs; [
2332
# The default formatter for Nix code
2433
# See https://github.com/NixOS/nixfmt

0 commit comments

Comments
 (0)