From 206787537e448b945257ad52690bc4c5bab1afc5 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 17 Sep 2019 12:51:55 +0200 Subject: [PATCH 1/4] Explicitly unescape hash signs. Required since Nix 2.3. --- rules.nix | 8 ++++++-- tests/testdata.nix | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/rules.nix b/rules.nix index 57746dd..81a04cc 100644 --- a/rules.nix +++ b/rules.nix @@ -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 diff --git a/tests/testdata.nix b/tests/testdata.nix index d26ae7e..2ca02f6 100644 --- a/tests/testdata.nix +++ b/tests/testdata.nix @@ -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} @@ -73,6 +82,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"; From eb24b3cceda182637ead9e52955d9dbcb4a03063 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 17 Sep 2019 13:22:17 +0200 Subject: [PATCH 2/4] ci.nix: Add 19.09 for Nix 2.3 --- ci.nix | 1 - nix/ci.nix | 14 ++++++ nix/default.nix | 4 +- nix/dimension.nix | 115 ++++++++++++++++++++++++++++++++++++++++++++++ nix/sources.json | 24 ++++++++++ 5 files changed, 155 insertions(+), 3 deletions(-) delete mode 100644 ci.nix create mode 100644 nix/ci.nix create mode 100644 nix/dimension.nix diff --git a/ci.nix b/ci.nix deleted file mode 100644 index dfd2bd1..0000000 --- a/ci.nix +++ /dev/null @@ -1 +0,0 @@ -import ./tests/default.nix { pkgs = import ./nix {}; } diff --git a/nix/ci.nix b/nix/ci.nix new file mode 100644 index 0000000..9b72b61 --- /dev/null +++ b/nix/ci.nix @@ -0,0 +1,14 @@ +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; }; } + ) + +#import ./tests/default.nix { pkgs = import ./nix {}; } diff --git a/nix/default.nix b/nix/default.nix index 193ac49..410c746 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -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 diff --git a/nix/dimension.nix b/nix/dimension.nix new file mode 100644 index 0000000..04d9811 --- /dev/null +++ b/nix/dimension.nix @@ -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?) +} diff --git a/nix/sources.json b/nix/sources.json index 979fb04..5d91e03 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -10,6 +10,30 @@ "description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels", "rev": "312a059bef8b29b4db4e73dc02ff441cab7bb26d" }, + "nixos-19.03": { + "homepage": "https://github.com/NixOS/nixpkgs", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/2dfae8e22fde5032419c3027964c406508332974.tar.gz", + "owner": "NixOS", + "branch": "nixos-19.03", + "url_template": "https://github.com///archive/.tar.gz", + "repo": "nixpkgs-channels", + "type": "tarball", + "sha256": "0293j9wib78n5nspywrmd9qkvcqq2vcrclrryxqnaxvj3bs1c0vj", + "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", + "rev": "2dfae8e22fde5032419c3027964c406508332974" + }, + "nixos-19.09": { + "homepage": "https://github.com/NixOS/nixpkgs", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/e6b068cd952e4640d416c2ccd62587d8a35cd774.tar.gz", + "owner": "NixOS", + "branch": "nixos-19.09", + "url_template": "https://github.com///archive/.tar.gz", + "repo": "nixpkgs-channels", + "type": "tarball", + "sha256": "1ngac24cmdms1g37cpi6xs666bz1pf0fhw52zxa91i7bj30x9vw5", + "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", + "rev": "e6b068cd952e4640d416c2ccd62587d8a35cd774" + }, "niv": { "homepage": "https://github.com/nmattia/niv", "url": "https://github.com/nmattia/niv/archive/5d9e3a5f7d51765f0369a4682770ec57d863f19f.tar.gz", From 0ab3edcc683f98319cabfddec8c6dcad5e1d7a7e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 17 Sep 2019 13:23:26 +0200 Subject: [PATCH 3/4] sources: Update and sort --- nix/sources.json | 73 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 5d91e03..6c2cc8f 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,49 +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///archive/.tar.gz", - "repo": "nixpkgs-channels", + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "5e9671a9a87c240b1c6ce981d04ad23ba4291451", + "sha256": "08j7msxkv452pyxnh0sgn6h9930i5mk9mszba49bj5401gzmfb8a", "type": "tarball", - "sha256": "1j52yvkhw1inp6ilpqy81xv1bbwgwqjn0v9647whampkqgn6dxhk", - "description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels", - "rev": "312a059bef8b29b4db4e73dc02ff441cab7bb26d" + "url": "https://github.com/nmattia/niv/archive/5e9671a9a87c240b1c6ce981d04ad23ba4291451.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" }, "nixos-19.03": { - "homepage": "https://github.com/NixOS/nixpkgs", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/2dfae8e22fde5032419c3027964c406508332974.tar.gz", - "owner": "NixOS", "branch": "nixos-19.03", - "url_template": "https://github.com///archive/.tar.gz", - "repo": "nixpkgs-channels", - "type": "tarball", - "sha256": "0293j9wib78n5nspywrmd9qkvcqq2vcrclrryxqnaxvj3bs1c0vj", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "rev": "2dfae8e22fde5032419c3027964c406508332974" + "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///archive/.tar.gz" }, "nixos-19.09": { - "homepage": "https://github.com/NixOS/nixpkgs", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/e6b068cd952e4640d416c2ccd62587d8a35cd774.tar.gz", - "owner": "NixOS", "branch": "nixos-19.09", - "url_template": "https://github.com///archive/.tar.gz", - "repo": "nixpkgs-channels", - "type": "tarball", - "sha256": "1ngac24cmdms1g37cpi6xs666bz1pf0fhw52zxa91i7bj30x9vw5", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "rev": "e6b068cd952e4640d416c2ccd62587d8a35cd774" - }, - "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///archive/.tar.gz", - "repo": "niv", + "homepage": "https://github.com/NixOS/nixpkgs", + "owner": "NixOS", + "repo": "nixpkgs-channels", + "rev": "e6b068cd952e4640d416c2ccd62587d8a35cd774", + "sha256": "1ngac24cmdms1g37cpi6xs666bz1pf0fhw52zxa91i7bj30x9vw5", "type": "tarball", - "sha256": "0x7d2rb89h0h7g8sjsgax6ncvf2wwbmxkgvlfi53d00kxj6kfzba", - "description": "Easy dependency management for Nix projects", - "rev": "5d9e3a5f7d51765f0369a4682770ec57d863f19f" + "url": "https://github.com/NixOS/nixpkgs-channels/archive/e6b068cd952e4640d416c2ccd62587d8a35cd774.tar.gz", + "url_template": "https://github.com///archive/.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///archive/.tar.gz" } } From b73965bd8637fdaedbf19c7b7f92feac9f59e99e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 17 Sep 2019 16:59:46 +0200 Subject: [PATCH 4/4] Update nix/ci.nix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Domen Kožar --- nix/ci.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nix/ci.nix b/nix/ci.nix index 9b72b61..70de687 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -11,4 +11,3 @@ let import ../tests/default.nix { pkgs = import ./default.nix { inherit nixpkgs; }; } ) -#import ./tests/default.nix { pkgs = import ./nix {}; }