Add *With functions to allow for more parameters

This commit is contained in:
Robert Hensing 2021-10-25 14:22:12 +02:00
parent 9e80c4d830
commit 998b4b7318
2 changed files with 25 additions and 15 deletions

View file

@ -6,29 +6,36 @@ let
let newSrc = lib.cleanSourceWith { filter = f: t: true; src = ./.; };
in (builtins.functionArgs lib.cleanSourceWith) ? name || newSrc ? name;
in
{
inherit (find-files) gitignoreFilter;
gitignoreSource =
if newCleanSourceWith
then
path:
let
origPath = path.origPath or path;
in
lib.cleanSourceWith {
name = "source";
filter = find-files.gitignoreFilter origPath;
src = path;
}
path: gitignoreSourceWith { inherit path; }
else
path:
if path ? _isLibCleanSourceWith
then builtins.abort "Sorry, please update your Nixpkgs to 19.09 or master if you want to use gitignoreSource on cleanSourceWith"
else builtins.path {
else lib.warn "You are using gitignore.nix with an old version of Nixpkgs that is not supported." (builtins.path {
name = "source";
filter = find-files.gitignoreFilter path;
inherit path;
};
});
gitignoreSourceWith = { path }:
lib.cleanSourceWith {
name = "source";
filter = find-files.gitignoreFilterWith { basePath = path.origPath or path; };
src = path;
};
in
{
inherit (find-files)
gitignoreFilter
gitignoreFilterWith
;
inherit
gitignoreSource
gitignoreSourceWith
;
}

View file

@ -18,6 +18,9 @@ rec {
# TODO: write test for trailing slash (matches dir only)
gitignoreFilter = basePath:
gitignoreFilterWith { inherit basePath; };
gitignoreFilterWith = { basePath }:
let
patternsBelowP = findPatternsTree basePath;
basePathStr = toString basePath;