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 --- default.nix | 2 ++ pkgs/persistent-nix-shell/default.nix | 20 ++++++++++++++++++++ web/tree/info.md | 1 + 3 files changed, 23 insertions(+) create mode 100644 pkgs/persistent-nix-shell/default.nix diff --git a/default.nix b/default.nix index 1552309..0e44786 100644 --- a/default.nix +++ b/default.nix @@ -15,5 +15,7 @@ let build-xslt = callPackage ./pkgs/xslt/build-xslt { }; static-xslt = callPackage ./pkgs/xslt/static-xslt { }; make-xslt = callPackage ./pkgs/xslt/make-xslt { }; + + persistent-nix-shell = callPackage ./pkgs/persistent-nix-shell { }; }; in custom 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) "$@" + ''; +} diff --git a/web/tree/info.md b/web/tree/info.md index cd1d773..1f95af9 100644 --- a/web/tree/info.md +++ b/web/tree/info.md @@ -32,6 +32,7 @@ Projects of my own: Configurations of my own: * [custom-neovim](https://code.kummerlaender.eu/pkgs/tree/pkgs/custom-neovim) +* [persistent-nix-shell](https://code.kummerlaender.eu/pkgs/tree/pkgs/persistent-nix-shell) Projects neither of my own nor of my configuration: -- cgit v1.2.3