Skip to content

Commit 1b5b637

Browse files
committed
nix: move shells to shell.nix
Both available mechanisms for determining whether we are in a nix-shell invocation are currently broken: - the `inNixShell` argument is not set by nix-direnv; - the `IN_NIX_SHELL` environment variable is an environment variable, so it affects nix-build calls inside nix shells. So we keep the shells separate instead.
1 parent 842a081 commit 1b5b637

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

default.nix

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{ # Is this a nix-shell invocation?
2-
# NOTE: We do not rely on the IN_NIX_SHELL environment variable as it
3-
# also affects nix-build invocations inside of nix shells.
4-
inNixShell ? false
5-
, system ? builtins.currentSystem
1+
{ system ? builtins.currentSystem
62
}:
73
let
84
pkgs = import ./support/nix/nixpkgs.nix { inherit system; };
@@ -64,20 +60,16 @@ let
6460

6561
# For building diagrams:
6662
poppler-utils our-texlive
67-
] ++ lib.optionals inNixShell [
68-
(lib.getBin labHaskellPackages.Agda)
69-
sort-imports
7063
];
7164
in
7265
pkgs.stdenv.mkDerivation rec {
7366
name = "1lab";
7467

75-
src = if inNixShell then null else
76-
with pkgs.nix-gitignore; gitignoreFilterSourcePure (_: _: true) [
77-
# Keep .git around for extracting page authors
78-
(compileRecursiveGitignore ./.)
79-
".github"
80-
] ./.;
68+
src = with pkgs.nix-gitignore; gitignoreFilterSourcePure (_: _: true) [
69+
# Keep .git around for extracting page authors
70+
(compileRecursiveGitignore ./.)
71+
".github"
72+
] ./.;
8173

8274
nativeBuildInputs = deps ++ [
8375
shakefile
@@ -105,16 +97,7 @@ in
10597
'';
10698

10799
passthru = {
108-
inherit deps sort-imports nodeModules;
100+
inherit pkgs shakefile deps sort-imports nodeModules;
109101
texlive = our-texlive;
110-
111-
shakefile = if !inNixShell then shakefile else
112-
# A shell for working on the shakefile.
113-
(shakefile.envFunc { withHoogle = false; }).overrideAttrs (old: {
114-
nativeBuildInputs = old.nativeBuildInputs ++ deps ++ [
115-
pkgs.cabal-install
116-
pkgs.labHaskellPackages.haskell-language-server
117-
];
118-
});
119102
};
120103
}

shell.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{ system ? builtins.currentSystem
2+
}:
3+
let
4+
the1lab = import ./. { inherit system; };
5+
inherit (the1lab) pkgs shakefile deps sort-imports;
6+
inherit (pkgs) lib;
7+
in
8+
# Note that mkShell destroys the installPhase.
9+
the1lab.overrideAttrs (old: {
10+
src = null; # Don't copy anything to the store.
11+
12+
nativeBuildInputs = old.nativeBuildInputs or [] ++ [
13+
(lib.getBin pkgs.labHaskellPackages.Agda)
14+
sort-imports
15+
];
16+
17+
passthru = old.passthru // {
18+
shakefile =
19+
(shakefile.envFunc { withHoogle = false; }).overrideAttrs (old: {
20+
nativeBuildInputs = old.nativeBuildInputs ++ deps ++ [
21+
pkgs.cabal-install
22+
pkgs.labHaskellPackages.haskell-language-server
23+
];
24+
});
25+
};
26+
})

0 commit comments

Comments
 (0)