From 136bc53720a0424acc7e9c3a2f5402c8ebd76a3e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 3 Jan 2021 18:13:19 +0100 Subject: persistent-nix-shell --- overlays/persistent-nix-shell/default.nix | 19 +++++++++++++++++++ overlays/persistent-nix-shell/persistent-nix-shell | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 overlays/persistent-nix-shell/default.nix create mode 100644 overlays/persistent-nix-shell/persistent-nix-shell (limited to 'overlays/persistent-nix-shell') 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 @@ +final: prev: { + persistent-nix-shell = prev.stdenv.mkDerivation { + name = "persistent-nix-shell"; + src = ./persistent-nix-shell; + + phases = [ "buildPhase" "installPhase" ]; + + inherit (final) zsh; + + buildPhase = '' + substituteAll $src persistent-nix-shell + ''; + + installPhase = '' + install -m 0755 -D -t $out/bin \ + persistent-nix-shell + ''; + }; +} 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 @@ +#!@zsh@/bin/zsh + +set -e + +gcrootsDir=${PWD}/.nix-gc-roots + +if [[ ${#@} -ge 1 ]]; then + shellFile=${1} + shift +else + shellFile=${PWD}/shell.nix +fi + +set -x +mkdir -p ${gcrootsDir} +nix-instantiate ${shellFile} --indirect --add-root ${gcrootsDir}/shell.drv +nix-store --indirect --add-root ${gcrootsDir}/shell.dep --realise $(nix-store --query --references ${gcrootsDir}/shell.drv) +set +x + +exec nix-shell $(readlink ${gcrootsDir}/shell.drv) ${@} -- cgit v1.2.3