diff --git a/default.nix b/default.nix index 68fc3b2..ec64995 100644 --- a/default.nix +++ b/default.nix @@ -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 + ; + } diff --git a/find-files.nix b/find-files.nix index ceccc65..09018db 100644 --- a/find-files.nix +++ b/find-files.nix @@ -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;