diff --git a/pkgs/additional/static-nix-shell/default.nix b/pkgs/additional/static-nix-shell/default.nix index febabf60..dcc010ca 100644 --- a/pkgs/additional/static-nix-shell/default.nix +++ b/pkgs/additional/static-nix-shell/default.nix @@ -37,10 +37,19 @@ in rec { pkgsEnv, pkgExprs, srcPath ? pname, + srcRoot ? null, extraMakeWrapperArgs ? [], ... }@attrs: let + extraDerivArgs = lib.optionalAttrs (srcRoot != null) { + # use can use `srcRoot` instead of `src` in most scenarios, to avoid include the entire directory containing their + # source file in the closure, but *just* the source file itself. + # `lib.fileset` docs: + src = lib.fileset.toSource { + root = srcRoot; fileset = lib.path.append srcRoot srcPath; + }; + }; pkgsStr = concatStringsSep "" (map (pname: " -p ${pname}") pkgExprs @@ -79,7 +88,7 @@ in rec { runHook postInstall ''; - } // (removeAttrs attrs [ "extraMakeWrapperArgs" "interpreter" "interpreterName" "pkgsEnv" "pkgExprs" "srcPath" ]) + } // extraDerivArgs // (removeAttrs attrs [ "extraMakeWrapperArgs" "interpreter" "interpreterName" "pkgsEnv" "pkgExprs" "srcPath" ]) ); # `mkShell` specialization for `nix-shell -i bash` scripts.