static-nix-shell: add a srcRoot
argument which allows more precisely specifying the source files and avoiding unnecessary rebuilds
This commit is contained in:
@@ -37,10 +37,19 @@ in rec {
|
|||||||
pkgsEnv,
|
pkgsEnv,
|
||||||
pkgExprs,
|
pkgExprs,
|
||||||
srcPath ? pname,
|
srcPath ? pname,
|
||||||
|
srcRoot ? null,
|
||||||
extraMakeWrapperArgs ? [],
|
extraMakeWrapperArgs ? [],
|
||||||
...
|
...
|
||||||
}@attrs:
|
}@attrs:
|
||||||
let
|
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: <https://ryantm.github.io/nixpkgs/functions/library/fileset/>
|
||||||
|
src = lib.fileset.toSource {
|
||||||
|
root = srcRoot; fileset = lib.path.append srcRoot srcPath;
|
||||||
|
};
|
||||||
|
};
|
||||||
pkgsStr = concatStringsSep "" (map
|
pkgsStr = concatStringsSep "" (map
|
||||||
(pname: " -p ${pname}")
|
(pname: " -p ${pname}")
|
||||||
pkgExprs
|
pkgExprs
|
||||||
@@ -79,7 +88,7 @@ in rec {
|
|||||||
|
|
||||||
runHook postInstall
|
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.
|
# `mkShell` specialization for `nix-shell -i bash` scripts.
|
||||||
|
Reference in New Issue
Block a user