From 18d2edf330e6932c177e71b1c7831a7a5ad77e38 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 18 Feb 2020 11:25:34 +0100 Subject: Add plain persistent nix-shell wrapper Automatically adds GC roots, including a fix for an implicit interactiveBash dependency --- pkgs/persistent-nix-shell/default.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pkgs/persistent-nix-shell/default.nix (limited to 'pkgs/persistent-nix-shell') diff --git a/pkgs/persistent-nix-shell/default.nix b/pkgs/persistent-nix-shell/default.nix new file mode 100644 index 0000000..8a74eb4 --- /dev/null +++ b/pkgs/persistent-nix-shell/default.nix @@ -0,0 +1,20 @@ +{ stdenv, pkgs, ... }: + +pkgs.writeTextFile { + name = "persistent-nix-shell"; + executable = true; + destination = "/bin/persistent-nix-shell"; + + text = '' + #!/bin/sh -eu + + mkdir -p .gcroots + + nix-instantiate shell.nix --indirect --add-root $PWD/.gcroots/shell.drv > /dev/null + nix-store -r $(nix-store --query --references $PWD/.gcroots/shell.drv) --indirect --add-root $PWD/.gcroots/shell.dep > /dev/null + + # Fix to prevent implicit interactiveBash dependency + export NIX_BUILD_SHELL=/run/current-system/sw/bin/bash + exec nix-shell $(readlink $PWD/.gcroots/shell.drv) "$@" + ''; +} -- cgit v1.2.3