static-nix-shell: add extraMakeWrapperArgs option

This commit is contained in:
Colin 2023-10-22 11:45:44 +00:00
parent 2ee7af064d
commit baca7931ad

View File

@ -40,6 +40,7 @@ in rec {
pkgsEnv, pkgsEnv,
pkgExprs, pkgExprs,
srcPath ? pname, srcPath ? pname,
extraMakeWrapperArgs ? [],
... ...
}@attrs: }@attrs:
let let
@ -52,7 +53,7 @@ in rec {
pkgsEnv' = lib.flatten pkgsEnv; pkgsEnv' = lib.flatten pkgsEnv;
doWrap = pkgsEnv' != []; doWrap = pkgsEnv' != [];
in in
stdenv.mkDerivation ({ stdenv.mkDerivation (final: {
version = "0.1.0"; # default version version = "0.1.0"; # default version
patchPhase = '' patchPhase = ''
substituteInPlace ${srcPath} \ substituteInPlace ${srcPath} \
@ -62,6 +63,9 @@ in rec {
'# nix deps evaluated statically' '# nix deps evaluated statically'
''; '';
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
makeWrapperArgs = [
"--suffix" "PATH" ":" (lib.makeBinPath pkgsEnv')
] ++ extraMakeWrapperArgs;
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
@ -73,12 +77,12 @@ in rec {
'' + lib.optionalString doWrap '' '' + lib.optionalString doWrap ''
# add runtime dependencies to PATH # add runtime dependencies to PATH
wrapProgram $out/bin/${srcPath} \ wrapProgram $out/bin/${srcPath} \
--suffix PATH : ${lib.makeBinPath pkgsEnv' } ${lib.escapeShellArgs final.makeWrapperArgs}
'' + '' '' + ''
runHook postInstall runHook postInstall
''; '';
} // (removeAttrs attrs [ "interpreter" "interpreterName" "pkgsEnv" "pkgExprs" "srcPath" ]) } // (removeAttrs attrs [ "extraMakeWrapperArgs" "interpreter" "interpreterName" "pkgsEnv" "pkgExprs" "srcPath" ])
); );
# `mkShell` specialization for `nix-shell -i bash` scripts. # `mkShell` specialization for `nix-shell -i bash` scripts.