Merge pull request #22 from hercules-ci/unescape-hash-sign
Unescape hash sign
This commit is contained in:
commit
f952568243
7 changed files with 198 additions and 24 deletions
1
ci.nix
1
ci.nix
|
|
@ -1 +0,0 @@
|
|||
import ./tests/default.nix { pkgs = import ./nix {}; }
|
||||
13
nix/ci.nix
Normal file
13
nix/ci.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let
|
||||
sources = import ./sources.nix;
|
||||
inherit (import ./dimension.nix { lib = import (sources.nixpkgs + "/lib"); })
|
||||
dimension
|
||||
;
|
||||
in
|
||||
dimension "Nixpkgs" {
|
||||
"nixpkgs-19_03" = sources."nixos-19.03";
|
||||
"nixpkgs-19_09" = sources."nixos-19.09";
|
||||
} (_key: nixpkgs:
|
||||
import ../tests/default.nix { pkgs = import ./default.nix { inherit nixpkgs; }; }
|
||||
)
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
{ sources ? import ./sources.nix }:
|
||||
{ sources ? import ./sources.nix, nixpkgs ? sources.nixpkgs }:
|
||||
let
|
||||
config = {};
|
||||
overlays = [(super: self: {
|
||||
inherit (import sources.niv {}) niv;
|
||||
})];
|
||||
pkgs = import sources.nixpkgs { inherit overlays config; };
|
||||
pkgs = import nixpkgs { inherit overlays config; };
|
||||
in
|
||||
pkgs
|
||||
|
|
|
|||
115
nix/dimension.nix
Normal file
115
nix/dimension.nix
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
{ lib }:
|
||||
{
|
||||
/*
|
||||
dimension: name -> attrs -> function -> attrs
|
||||
where
|
||||
function: keyText -> value -> attrsOf package
|
||||
|
||||
WARNING: Attribute names must not contain periods (".").
|
||||
See https://github.com/NixOS/nix/issues/3088
|
||||
|
||||
NOTE: The dimension name will be picked up by agent and web ui soon.
|
||||
|
||||
Specifies a dimension of the build matrix. For example
|
||||
|
||||
dimension "Example" {
|
||||
withP = { p = true; }
|
||||
withoutP = { p = false; }
|
||||
} (key: # either "withP" or "withoutP"
|
||||
{ p }: # either p = true or p = false
|
||||
myProject p
|
||||
)
|
||||
|
||||
evaluates roughly to
|
||||
|
||||
{
|
||||
withP = myProject true;
|
||||
withoutP = myProject false;
|
||||
}
|
||||
|
||||
Use nested calls for multiple dimensions.
|
||||
|
||||
Example:
|
||||
|
||||
dimension "System" {
|
||||
"x86_64-linux" = {};
|
||||
# ...
|
||||
}: (system: {}:
|
||||
|
||||
dimension "Nixpkgs release" (
|
||||
{
|
||||
"nixpkgs-19_03".nixpkgs = someSource
|
||||
} // optionalAttrs (system != "...") {
|
||||
"nixpkgs-unstable".nixpkgs = someOtherSource
|
||||
}
|
||||
) (_key: { nixpkgs }:
|
||||
|
||||
myProject system nixpkgs
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
evaluates roughly to
|
||||
|
||||
{
|
||||
x86_64-linux.nixpkgs-19_03 = myProject "x86_64-linux" someSource;
|
||||
x86_64-linux.nixpkgs-unstable = myProject "x86_64-linux" someOtherSource;
|
||||
...
|
||||
}
|
||||
|
||||
If you need to make references across attributes, you can do so by binding
|
||||
the result. Wherever you write
|
||||
|
||||
dimension "My dimension" {} (key: value: f1 key value)
|
||||
|
||||
You can also write
|
||||
|
||||
let
|
||||
myDimension = dimension "My dimension" {} (key: value: f2 key value myDimension)
|
||||
in
|
||||
myDimension
|
||||
|
||||
This example builds a single test runner to reuse across releases:
|
||||
|
||||
let
|
||||
overlay =
|
||||
testRunnerPkgs: self: super: {
|
||||
# ...
|
||||
};
|
||||
myProject =
|
||||
{ nixpkgs,
|
||||
pkgs ? import nixpkgs { overlays = [ overlay ]; },
|
||||
testRunnerPkgs ? pkgs
|
||||
}: pkgs;
|
||||
in
|
||||
|
||||
let
|
||||
latest = "nixpkgs-19_03";
|
||||
releases =
|
||||
dimension "Nixpkgs release"
|
||||
{
|
||||
nixpkgs-18_09.nixpkgs = someSource
|
||||
nixpkgs-19_03.nixpkgs = someOtherSource
|
||||
}
|
||||
(_key: { nixpkgs }:
|
||||
|
||||
myProject {
|
||||
inherit nixpkgs;
|
||||
testRunnerPkgs = releases."${latest}";
|
||||
}
|
||||
|
||||
);
|
||||
in releases;
|
||||
|
||||
*/
|
||||
dimension = name: attrs: f:
|
||||
lib.mapAttrs
|
||||
(k: v:
|
||||
let o = f k v;
|
||||
in o // { recurseForDerivations = o.recurseForDerivations or true; }
|
||||
)
|
||||
attrs
|
||||
// { meta.dimension.name = name; };
|
||||
|
||||
# TODO: move this file somewhere (a flake?)
|
||||
}
|
||||
|
|
@ -1,25 +1,50 @@
|
|||
{
|
||||
"nixpkgs": {
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/312a059bef8b29b4db4e73dc02ff441cab7bb26d.tar.gz",
|
||||
"owner": "NixOS",
|
||||
"branch": "nixos-19.03",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
|
||||
"repo": "nixpkgs-channels",
|
||||
"type": "tarball",
|
||||
"sha256": "1j52yvkhw1inp6ilpqy81xv1bbwgwqjn0v9647whampkqgn6dxhk",
|
||||
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
|
||||
"rev": "312a059bef8b29b4db4e73dc02ff441cab7bb26d"
|
||||
},
|
||||
"niv": {
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"url": "https://github.com/nmattia/niv/archive/5d9e3a5f7d51765f0369a4682770ec57d863f19f.tar.gz",
|
||||
"owner": "nmattia",
|
||||
"branch": "master",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
|
||||
"repo": "niv",
|
||||
"type": "tarball",
|
||||
"sha256": "0x7d2rb89h0h7g8sjsgax6ncvf2wwbmxkgvlfi53d00kxj6kfzba",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"rev": "5d9e3a5f7d51765f0369a4682770ec57d863f19f"
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "5e9671a9a87c240b1c6ce981d04ad23ba4291451",
|
||||
"sha256": "08j7msxkv452pyxnh0sgn6h9930i5mk9mszba49bj5401gzmfb8a",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/5e9671a9a87c240b1c6ce981d04ad23ba4291451.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixos-19.03": {
|
||||
"branch": "nixos-19.03",
|
||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "2dfae8e22fde5032419c3027964c406508332974",
|
||||
"sha256": "0293j9wib78n5nspywrmd9qkvcqq2vcrclrryxqnaxvj3bs1c0vj",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/2dfae8e22fde5032419c3027964c406508332974.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixos-19.09": {
|
||||
"branch": "nixos-19.09",
|
||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "e6b068cd952e4640d416c2ccd62587d8a35cd774",
|
||||
"sha256": "1ngac24cmdms1g37cpi6xs666bz1pf0fhw52zxa91i7bj30x9vw5",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/e6b068cd952e4640d416c2ccd62587d8a35cd774.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",
|
||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "2dfae8e22fde5032419c3027964c406508332974",
|
||||
"sha256": "0293j9wib78n5nspywrmd9qkvcqq2vcrclrryxqnaxvj3bs1c0vj",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/2dfae8e22fde5032419c3027964c406508332974.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,10 +105,14 @@ rec {
|
|||
in str : recurse str;
|
||||
chars = s: filter (c: c != "" && !isList c) (splitString s);
|
||||
escape = s: map (c: "\\" + c) (chars s);
|
||||
|
||||
# The "#" character normally starts a comment, but can be escaped with a
|
||||
# backslash to be a literal # in the pattern.
|
||||
unescapes = "#";
|
||||
in
|
||||
replaceStrings
|
||||
((chars special) ++ (escape escs) ++ ["**/" "**" "*" "?"])
|
||||
((escape special) ++ (escape escs) ++ ["(.*/)?" ".*" "[^/]*" "[^/]"]);
|
||||
((chars special) ++ (escape unescapes) ++ (escape escs) ++ ["**/" "**" "*" "?"])
|
||||
((escape special) ++ (chars unescapes) ++ (escape escs) ++ ["(.*/)?" ".*" "[^/]*" "[^/]"]);
|
||||
|
||||
# (regex -> regex) -> regex -> regex
|
||||
mapAroundCharclass = f: r: # rl = regex or list
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ let
|
|||
create-tree() { (
|
||||
mkdir -p "$1"; cd "$1"
|
||||
|
||||
touch '#' '#ignored'
|
||||
|
||||
touches 1-simpl {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\,simple-test}
|
||||
touches 1-simpl/1-simpl {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\,simpletest}
|
||||
touches 1-xxxxx/1-simpl {1,2}
|
||||
|
|
@ -29,6 +31,13 @@ let
|
|||
|
||||
touches 5-directory {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\}
|
||||
|
||||
mkdir 6-hash
|
||||
touch '6-hash/a' '6-hash/a#0' '6-hash/a\#1' '6-hash/a\\#2'
|
||||
touch '6-hash/b' '6-hash/b#0' '6-hash/b\#1' '6-hash/b\\#2'
|
||||
touch '6-hash/c' '6-hash/c#0' '6-hash/c\#1' '6-hash/c\\#2'
|
||||
touch '6-hash/d' '6-hash/d#0' '6-hash/d\#1' '6-hash/d\\#2'
|
||||
touch '6-hash/z' '6-hash/z#0' '6-hash/z\#1' '6-hash/z\\#2'
|
||||
|
||||
touches 9-expected {unfiltered,filtered-via-aux-{filter,ignore,filepath}}
|
||||
|
||||
touches 10-subdir-ignoring-itself/foo {foo,bar}
|
||||
|
|
@ -77,6 +86,15 @@ let
|
|||
4-*/other.html$
|
||||
|
||||
5-*/
|
||||
|
||||
# A hash sign on a line
|
||||
#
|
||||
|
||||
6-hash/a*#
|
||||
6-hash/b*\#
|
||||
6-hash/c*\\#
|
||||
6-hash/d*\\\#
|
||||
6-hash/z*
|
||||
'';
|
||||
|
||||
ignoresAux = "/9-expected/*filepath\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue