Extend getSrc to allow specifying subtrees of sources.
Using ${l.src dir} will include the whole subtree as a dependency.master
parent
69bd805cc6
commit
5e3b992c6f
|
@ -20,7 +20,7 @@ let
|
||||||
funcPkgs = {
|
funcPkgs = {
|
||||||
__functor = self: arg: resolve arg;
|
__functor = self: arg: resolve arg;
|
||||||
src = getSrc root rcwd filter;
|
src = getSrc root rcwd filter;
|
||||||
inherit pkgs cwd rcwd;
|
inherit pkgs cwd rcwd d1 d2;
|
||||||
};
|
};
|
||||||
|
|
||||||
_builder = let
|
_builder = let
|
||||||
|
|
22
lib.nix
22
lib.nix
|
@ -1,10 +1,10 @@
|
||||||
{ lib ? import <nixpkgs/lib> }:
|
{ lib ? import <nixpkgs/lib> }:
|
||||||
let
|
let
|
||||||
inherit (builtins) baseNameOf dirOf length genList pathExists filterSource
|
inherit (builtins) baseNameOf dirOf length genList pathExists filterSource
|
||||||
isString match replaceStrings;
|
isString match replaceStrings stringLength;
|
||||||
inherit (lib) take splitString concatStringsSep last foldl foldr head tail
|
inherit (lib) take splitString concatStringsSep last foldl foldr head tail
|
||||||
singleton removePrefix hasSuffix removeSuffix flatten crossLists reverseList
|
singleton removePrefix hasSuffix removeSuffix flatten crossLists reverseList
|
||||||
all any unique;
|
all any unique hasPrefix;
|
||||||
butlast = list: take (length list - 1) list;
|
butlast = list: take (length list - 1) list;
|
||||||
|
|
||||||
doFileSuffix = "do";
|
doFileSuffix = "do";
|
||||||
|
@ -77,7 +77,7 @@ let
|
||||||
# Add all preceding paths to a src down to the root. Otherwise
|
# Add all preceding paths to a src down to the root. Otherwise
|
||||||
# builtins.filterSource will reject it.
|
# builtins.filterSource will reject it.
|
||||||
augmentedSrcs = root: srcs: let
|
augmentedSrcs = root: srcs: let
|
||||||
aug = map (s: singleton s ++ (map (p: root + (removeSuffix "/" p)) (genPathlist (removePrefix root s)))) srcs;
|
aug = map (s: (map (p: root + (removeSuffix "/" p)) (genPathlist (removePrefix root s)))) srcs;
|
||||||
in unique (flatten aug);
|
in unique (flatten aug);
|
||||||
|
|
||||||
# The source tree resolver combinator.
|
# The source tree resolver combinator.
|
||||||
|
@ -90,15 +90,25 @@ let
|
||||||
captureFunc (resolveSrc root rcwd) (srcs: let
|
captureFunc (resolveSrc root rcwd) (srcs: let
|
||||||
|
|
||||||
rejector = path: (all (x: path != x) rejected);
|
rejector = path: (all (x: path != x) rejected);
|
||||||
|
|
||||||
|
# If a src in srcs is a prefix to a that (it must be a dir, then, or the
|
||||||
|
# file itself), allow all sub-paths.
|
||||||
|
srcFilter = path:
|
||||||
|
if srcs == []
|
||||||
|
then true
|
||||||
|
else (any (x: (hasPrefix x path)) srcs);
|
||||||
|
|
||||||
|
# Allow all directories lying on the way to specified srcs.
|
||||||
_srcs = (augmentedSrcs root srcs);
|
_srcs = (augmentedSrcs root srcs);
|
||||||
srcFilter = path: if srcs == []
|
srcDirFilter = path: if srcs == []
|
||||||
then true # No explicit srcs means: Take the whole source tree!
|
then true # No explicit srcs means: Take the whole source tree!
|
||||||
else (any (x: path == x) _srcs);
|
else (any (x: path == x) (_srcs));
|
||||||
filter = (path: type:
|
filter = (path: type:
|
||||||
(baseNameOf path != ".git") &&
|
(baseNameOf path != ".git") &&
|
||||||
(baseNameOf path != ".envrc") &&
|
(baseNameOf path != ".envrc") &&
|
||||||
(rejector path) &&
|
(rejector path) &&
|
||||||
(srcFilter path));
|
((srcFilter path) ||
|
||||||
|
(srcDirFilter path)));
|
||||||
in (builtins.filterSource filter root));
|
in (builtins.filterSource filter root));
|
||||||
|
|
||||||
self = {
|
self = {
|
||||||
|
|
Loading…
Reference in New Issue