diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2019-11-24 20:39:26 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2019-11-24 20:39:26 +0100 |
commit | 61e8781e600a916e51fd663c4d8cd5d93bb894cb (patch) | |
tree | 15a8e9abf15f5ebd8e2e692a9fc43a7124fae93e | |
parent | f55aa62c7dd25d44b37985ef5f109eb8212f5ae7 (diff) | |
download | utils-61e8781e600a916e51fd663c4d8cd5d93bb894cb.tar utils-61e8781e600a916e51fd663c4d8cd5d93bb894cb.tar.gz utils-61e8781e600a916e51fd663c4d8cd5d93bb894cb.tar.bz2 utils-61e8781e600a916e51fd663c4d8cd5d93bb894cb.tar.xz utils-61e8781e600a916e51fd663c4d8cd5d93bb894cb.zip |
persistent-nix-shell
-rw-r--r-- | nix/default.nix | 1 | ||||
-rw-r--r-- | nix/persistent-nix-shell.nix | 22 | ||||
-rwxr-xr-x | persistent-nix-shell | 20 |
3 files changed, 43 insertions, 0 deletions
diff --git a/nix/default.nix b/nix/default.nix index cef8800..f3e35e2 100644 --- a/nix/default.nix +++ b/nix/default.nix | |||
@@ -8,4 +8,5 @@ self: super: | |||
8 | rolling-directory = self.callPackage ./rolling-directory.nix {}; | 8 | rolling-directory = self.callPackage ./rolling-directory.nix {}; |
9 | recv = self.callPackage ./recv.nix {}; | 9 | recv = self.callPackage ./recv.nix {}; |
10 | notmuch-tcp = self.callPackage ./notmuch-tcp.nix {}; | 10 | notmuch-tcp = self.callPackage ./notmuch-tcp.nix {}; |
11 | persistent-nix-shell = self.callPackage ./persistent-nix-shell.nix {}; | ||
11 | } | 12 | } |
diff --git a/nix/persistent-nix-shell.nix b/nix/persistent-nix-shell.nix new file mode 100644 index 0000000..7b371c6 --- /dev/null +++ b/nix/persistent-nix-shell.nix | |||
@@ -0,0 +1,22 @@ | |||
1 | { stdenv | ||
2 | , zsh | ||
3 | }: | ||
4 | |||
5 | stdenv.mkDerivation rec { | ||
6 | pname = "persistent-nix-shell"; | ||
7 | version = "0.1"; | ||
8 | src = ../persistent-nix-shell; | ||
9 | |||
10 | phases = [ "buildPhase" "installPhase" ]; | ||
11 | |||
12 | inherit zsh; | ||
13 | |||
14 | buildPhase = '' | ||
15 | substituteAll $src persistent-nix-shell | ||
16 | ''; | ||
17 | |||
18 | installPhase = '' | ||
19 | install -m 0755 -D -t $out/bin \ | ||
20 | persistent-nix-shell | ||
21 | ''; | ||
22 | } | ||
diff --git a/persistent-nix-shell b/persistent-nix-shell new file mode 100755 index 0000000..a17f6de --- /dev/null +++ b/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) ${@} | ||