summaryrefslogtreecommitdiff
path: root/persistent-nix-shell
blob: a17f6de6a410b9e216c47320591e77700bfd0f01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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) ${@}