diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 18:13:19 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 18:13:19 +0100 |
commit | 136bc53720a0424acc7e9c3a2f5402c8ebd76a3e (patch) | |
tree | ace8cc16f92f8b8675b9d1dc63f3dcc0a21ca470 /overlays | |
parent | 94b03d50d680bd001c059fe86668e02bd3f03e93 (diff) | |
download | nixos-136bc53720a0424acc7e9c3a2f5402c8ebd76a3e.tar nixos-136bc53720a0424acc7e9c3a2f5402c8ebd76a3e.tar.gz nixos-136bc53720a0424acc7e9c3a2f5402c8ebd76a3e.tar.bz2 nixos-136bc53720a0424acc7e9c3a2f5402c8ebd76a3e.tar.xz nixos-136bc53720a0424acc7e9c3a2f5402c8ebd76a3e.zip |
persistent-nix-shell
Diffstat (limited to 'overlays')
-rw-r--r-- | overlays/persistent-nix-shell/default.nix | 19 | ||||
-rw-r--r-- | overlays/persistent-nix-shell/persistent-nix-shell | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/overlays/persistent-nix-shell/default.nix b/overlays/persistent-nix-shell/default.nix new file mode 100644 index 00000000..60396335 --- /dev/null +++ b/overlays/persistent-nix-shell/default.nix | |||
@@ -0,0 +1,19 @@ | |||
1 | final: prev: { | ||
2 | persistent-nix-shell = prev.stdenv.mkDerivation { | ||
3 | name = "persistent-nix-shell"; | ||
4 | src = ./persistent-nix-shell; | ||
5 | |||
6 | phases = [ "buildPhase" "installPhase" ]; | ||
7 | |||
8 | inherit (final) zsh; | ||
9 | |||
10 | buildPhase = '' | ||
11 | substituteAll $src persistent-nix-shell | ||
12 | ''; | ||
13 | |||
14 | installPhase = '' | ||
15 | install -m 0755 -D -t $out/bin \ | ||
16 | persistent-nix-shell | ||
17 | ''; | ||
18 | }; | ||
19 | } | ||
diff --git a/overlays/persistent-nix-shell/persistent-nix-shell b/overlays/persistent-nix-shell/persistent-nix-shell new file mode 100644 index 00000000..a17f6de6 --- /dev/null +++ b/overlays/persistent-nix-shell/persistent-nix-shell | |||
@@ -0,0 +1,20 @@ | |||
1 | #!@zsh@/bin/zsh | ||
2 | |||
3 | set -e | ||
4 | |||
5 | gcrootsDir=${PWD}/.nix-gc-roots | ||
6 | |||
7 | if [[ ${#@} -ge 1 ]]; then | ||
8 | shellFile=${1} | ||
9 | shift | ||
10 | else | ||
11 | shellFile=${PWD}/shell.nix | ||
12 | fi | ||
13 | |||
14 | set -x | ||
15 | mkdir -p ${gcrootsDir} | ||
16 | nix-instantiate ${shellFile} --indirect --add-root ${gcrootsDir}/shell.drv | ||
17 | nix-store --indirect --add-root ${gcrootsDir}/shell.dep --realise $(nix-store --query --references ${gcrootsDir}/shell.drv) | ||
18 | set +x | ||
19 | |||
20 | exec nix-shell $(readlink ${gcrootsDir}/shell.drv) ${@} | ||