Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover composition #21

Merged
merged 5 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 27 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
{ 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;

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;
};
}