This has been broken since its introduction due to a typo. `lib.cleanSourceWith` uses the field `origSrc` to store the initial path prior to processing— which is presumably what the author intended. With this change, `gitignoreSource (lib.sources.trace /path/to/repo)` no longer incorrectly prints ignored paths. Change-Id: I475cee9576dd9969f5fe5127d937bc7fb480eb22
41 lines
1.1 KiB
Nix
41 lines
1.1 KiB
Nix
{ lib ? import <nixpkgs/lib> }:
|
|
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;
|
|
|
|
gitignoreSource =
|
|
if newCleanSourceWith
|
|
then
|
|
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 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.origSrc or path; };
|
|
src = path;
|
|
};
|
|
|
|
in
|
|
{
|
|
inherit (find-files)
|
|
gitignoreFilter
|
|
gitignoreFilterWith
|
|
;
|
|
inherit
|
|
gitignoreSource
|
|
gitignoreSourceWith
|
|
;
|
|
|
|
}
|