Merge pull request #21 from hercules-ci/recover-composition

Recover composition
This commit is contained in:
Robert Hensing 2019-09-12 13:43:28 +02:00 committed by GitHub
commit ec4a003915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 6 deletions

View file

@ -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

View file

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