diff --git a/README.md b/README.md index 5ccda96..30323bf 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,11 @@ mkDerivation { - Reads parent gitignores even if only pointed at a subdirectory - Source hashes only change when output changes - Not impacted by large or inaccessible ignored directories + - Composes with `cleanSourceWith` - Reads user git configuration; no need to bother your team with your tool config. - Also works with restrict-eval enabled (if avoiding `fetchFromGitHub`) - No import from derivation ("IFD") + - Name and hash are not sensitive to checkout location ## Comparison diff --git a/default.nix b/default.nix index f52045d..68fc3b2 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,34 @@ { lib ? import }: let find-files = import ./find-files.nix { inherit lib; }; + + newCleanSourceWith = + let newSrc = lib.cleanSourceWith { filter = f: t: true; src = ./.; }; + in (builtins.functionArgs lib.cleanSourceWith) ? name || newSrc ? name; + in { inherit (find-files) gitignoreFilter; - - gitignoreSource = path: builtins.path { - name = "source"; - filter = find-files.gitignoreFilter path; - inherit path; - }; + + gitignoreSource = + if newCleanSourceWith + then + path: + let + origPath = path.origPath or path; + in + lib.cleanSourceWith { + name = "source"; + filter = find-files.gitignoreFilter origPath; + src = 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 { + name = "source"; + filter = find-files.gitignoreFilter path; + inherit path; + }; }