static-nix-shell: more clearly mark the nix-shell preambles

This commit is contained in:
2025-07-20 20:55:25 +00:00
parent 3b8b227c09
commit 1a89305f18

View File

@@ -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";