Merge pull request #55 from hercules-ci/extensible

Add *With functions to allow for more parameters
This commit is contained in:
Robert Hensing 2021-10-25 14:30:13 +02:00 committed by GitHub
commit 5b9e0ff9d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 15 deletions

View file

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

View file

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

View file

@ -7,6 +7,7 @@ let
dimension "Nixpkgs" {
"nixpkgs-19_03" = sources."nixos-19.03";
"nixpkgs-19_09" = sources."nixos-19.09";
"nixpkgs-21_05" = sources."nixos-21.05";
} (_key: nixpkgs:
import ../tests/default.nix { pkgs = import ./default.nix { inherit nixpkgs; }; }
)

View file

@ -35,6 +35,18 @@
"url": "https://github.com/NixOS/nixpkgs-channels/archive/e6b068cd952e4640d416c2ccd62587d8a35cd774.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixos-21.05": {
"branch": "nixos-21.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3b1789322fcbcb5cf51228d732752714f1bf77da",
"sha256": "0m6gcl2pzvicwbflsvmccdyf03ki1zl3d9dl8rn8hj1gdgssj6vr",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/3b1789322fcbcb5cf51228d732752714f1bf77da.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-19.03",
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",