From 1a89305f1885c0e710ff36d2c49b128b90b5de7c Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 20 Jul 2025 20:55:25 +0000 Subject: [PATCH] static-nix-shell: more clearly mark the nix-shell preambles --- pkgs/by-name/static-nix-shell/package.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/static-nix-shell/package.nix b/pkgs/by-name/static-nix-shell/package.nix index 5aaf6c987..c33210c20 100644 --- a/pkgs/by-name/static-nix-shell/package.nix +++ b/pkgs/by-name/static-nix-shell/package.nix @@ -105,13 +105,19 @@ in rec { buildPhase = '' runHook preBuild - #^ TODO: each shell should use preBuild to compute a `shellPreamble` die() { echo "$@" exit 1 } + if [ -n "$shellPreamble" ]; then + shellPreamble=" + # --- BEGIN: nix-shell preamble (generated code) --- + $shellPreamble + # --- END: nix-shell preamble (generated code) --- + " + fi substituteInPlace ${srcPath} \ --replace-fail '#!/usr/bin/env nix-shell' '#!${interpreter}' \ --replace-fail \ @@ -241,6 +247,7 @@ in rec { pkgsEnv = [ zsh ] ++ (builtins.attrValues pkgsAsAttrs); pkgExprs = insertTopo "zsh" (builtins.attrNames pkgsAsAttrs); in mkShell ({ + # TODO: generate `shellPreamble` here to reduce wrapping inherit pkgsEnv pkgExprs; interpreter = lib.getExe zsh; } // (removeAttrs attrs [ "pkgs" "zsh" ]) @@ -253,6 +260,7 @@ in rec { pkgsEnv = builtins.attrValues pkgsAsAttrs; pkgExprs = insertTopo "python3" (builtins.attrNames pkgsAsAttrs); in mkShell ({ + # TODO: generate `shellPreamble` here to reduce wrapping inherit pkgsEnv pkgExprs; interpreter = lib.getExe python3; interpreterName = "python3";