From 5d8490d2fc7a735f747704792d4fc7d779d6e471 Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 15 Mar 2021 22:32:16 +0100 Subject: [PATCH] feat(users/Profpatsch): build attrset members on CI Setting meta.targets to include all derivations in the different package sets in Profpatsch's user folder makes them checked by CI until they do the readTree refactor as promised. To reduce code duplication we handle this in a simple function which is exposed from nix.utils which may be a good place for depot specific bits and bops we accumulate over time. To get around the issue of too nested sets we perform the following renames: * users.Profpatsch.tests gets moved into its own directory * users.Profpatsch.arglib.netencode now lives in its own file instead of the default.nix * users.Profpatsch.netstring.tests gets moved into its own directory Change-Id: Icd039c29d7760a711c1c53554504d6b0cd19e120 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2603 Tested-by: BuildkiteCI Reviewed-by: Profpatsch --- nix/utils/OWNERS | 3 +++ nix/utils/default.nix | 24 +++++++++++++++++++ .../arglib/{default.nix => netencode.nix} | 6 +---- users/Profpatsch/execline/default.nix | 2 +- users/Profpatsch/netencode/default.nix | 2 +- users/Profpatsch/netstring/default.nix | 16 +------------ .../{tests.nix => tests/default.nix} | 11 +++++++-- users/Profpatsch/nixpkgs-rewriter/default.nix | 2 +- users/Profpatsch/tree-sitter.nix | 2 +- users/Profpatsch/writers/default.nix | 14 ----------- .../writers/{tests.nix => tests/default.nix} | 19 ++++++++++++--- 11 files changed, 58 insertions(+), 43 deletions(-) create mode 100644 nix/utils/OWNERS create mode 100644 nix/utils/default.nix rename users/Profpatsch/arglib/{default.nix => netencode.nix} (97%) rename users/Profpatsch/netstring/{tests.nix => tests/default.nix} (87%) rename users/Profpatsch/writers/{tests.nix => tests/default.nix} (84%) diff --git a/nix/utils/OWNERS b/nix/utils/OWNERS new file mode 100644 index 000000000..f16dd105d --- /dev/null +++ b/nix/utils/OWNERS @@ -0,0 +1,3 @@ +inherited: true +owners: + - sterni diff --git a/nix/utils/default.nix b/nix/utils/default.nix new file mode 100644 index 000000000..33f72e390 --- /dev/null +++ b/nix/utils/default.nix @@ -0,0 +1,24 @@ +{ depot, lib, ... }: + +let + + /* Takes an attribute set and adds a meta.targets + attribute to it which contains all direct children + of the attribute set which are derivations. + + Type: attrs -> attrs + */ + drvTargets = attrs: + attrs // { + meta = { + targets = builtins.filter + (x: lib.isDerivation attrs."${x}") + (builtins.attrNames attrs); + } // (attrs.meta or {}); + }; + +in { + inherit + drvTargets + ; +} diff --git a/users/Profpatsch/arglib/default.nix b/users/Profpatsch/arglib/netencode.nix similarity index 97% rename from users/Profpatsch/arglib/default.nix rename to users/Profpatsch/arglib/netencode.nix index b263654ac..6b568ab80 100644 --- a/users/Profpatsch/arglib/default.nix +++ b/users/Profpatsch/arglib/netencode.nix @@ -37,8 +37,4 @@ let ''; }; -in { - inherit - netencode - ; -} +in depot.nix.utils.drvTargets netencode diff --git a/users/Profpatsch/execline/default.nix b/users/Profpatsch/execline/default.nix index 852fcfcfa..c852b82a8 100644 --- a/users/Profpatsch/execline/default.nix +++ b/users/Profpatsch/execline/default.nix @@ -5,7 +5,7 @@ let name = "exec-helpers"; } (builtins.readFile ./exec_helpers.rs); -in { +in depot.nix.utils.drvTargets { inherit exec-helpers ; diff --git a/users/Profpatsch/netencode/default.nix b/users/Profpatsch/netencode/default.nix index 294e3b439..dabf640d5 100644 --- a/users/Profpatsch/netencode/default.nix +++ b/users/Profpatsch/netencode/default.nix @@ -125,7 +125,7 @@ let } ''; -in { +in depot.nix.utils.drvTargets { inherit netencode-rs netencode-mustache diff --git a/users/Profpatsch/netstring/default.nix b/users/Profpatsch/netstring/default.nix index 3cf882d5a..a1d6a1e77 100644 --- a/users/Profpatsch/netstring/default.nix +++ b/users/Profpatsch/netstring/default.nix @@ -52,25 +52,11 @@ let } ''; - tests = import ./tests.nix { - inherit - depot - pkgs - lib - python-netstring - rust-netstring - toNetstring - toNetstringKeyVal - ; - }; - -in { +in depot.nix.utils.drvTargets { inherit toNetstring toNetstringKeyVal python-netstring rust-netstring - tests ; - } diff --git a/users/Profpatsch/netstring/tests.nix b/users/Profpatsch/netstring/tests/default.nix similarity index 87% rename from users/Profpatsch/netstring/tests.nix rename to users/Profpatsch/netstring/tests/default.nix index 23141472d..a9e6c9c68 100644 --- a/users/Profpatsch/netstring/tests.nix +++ b/users/Profpatsch/netstring/tests/default.nix @@ -1,7 +1,14 @@ -{ depot, lib, pkgs, python-netstring, rust-netstring, toNetstring, toNetstringKeyVal }: +{ depot, lib, pkgs, ... }: let + inherit (depot.users.Profpatsch.netstring) + toNetstring + toNetstringKeyVal + python-netstring + rust-netstring + ; + python-netstring-test = depot.users.Profpatsch.writers.python3 { name = "python-netstring-test"; libraries = p: [ @@ -53,7 +60,7 @@ let } ''; -in { +in depot.nix.utils.drvTargets { inherit python-netstring-test rust-netstring-test diff --git a/users/Profpatsch/nixpkgs-rewriter/default.nix b/users/Profpatsch/nixpkgs-rewriter/default.nix index 286530b03..ff414862f 100644 --- a/users/Profpatsch/nixpkgs-rewriter/default.nix +++ b/users/Profpatsch/nixpkgs-rewriter/default.nix @@ -102,7 +102,7 @@ let "nix-instantiate" "$1" "-A" "{}" ]; -in { +in depot.nix.utils.drvTargets { inherit instantiate-nixpkgs-randomly # requires hnix, which we don’t want in tvl for now diff --git a/users/Profpatsch/tree-sitter.nix b/users/Profpatsch/tree-sitter.nix index 099fa2d5b..8fc2a847c 100644 --- a/users/Profpatsch/tree-sitter.nix +++ b/users/Profpatsch/tree-sitter.nix @@ -169,7 +169,7 @@ let ''; }; -in { +in depot.nix.utils.drvTargets { inherit print-ast tree-sitter-nix diff --git a/users/Profpatsch/writers/default.nix b/users/Profpatsch/writers/default.nix index 3888579a6..a71bed38e 100644 --- a/users/Profpatsch/writers/default.nix +++ b/users/Profpatsch/writers/default.nix @@ -138,19 +138,6 @@ let ]; in drvSeqL [ tests ] (crate false); - - tests = import ./tests.nix { - inherit - depot - pkgs - python3 - python3Lib - rustSimpleLib - rustSimple - testRustSimple - ; - }; - in { inherit python3 @@ -159,6 +146,5 @@ in { rustSimpleBin rustSimpleLib testRustSimple - tests ; } diff --git a/users/Profpatsch/writers/tests.nix b/users/Profpatsch/writers/tests/default.nix similarity index 84% rename from users/Profpatsch/writers/tests.nix rename to users/Profpatsch/writers/tests/default.nix index 680c37a2e..a16f5fa1f 100644 --- a/users/Profpatsch/writers/tests.nix +++ b/users/Profpatsch/writers/tests/default.nix @@ -1,10 +1,23 @@ -{ depot, pkgs, python3, python3Lib, rustSimpleLib, rustSimple, testRustSimple }: +{ depot, ... }: let + inherit (depot.users.Profpatsch.writers) + python3Lib + python3 + testRustSimple + rustSimple + rustSimpleLib + rustSimpleBin + ; + + inherit (depot.third_party) + coreutils + ; + run = drv: depot.nix.runExecline.local "run-${drv.name}" {} [ "if" [ drv ] "importas" "out" "out" - "${pkgs.coreutils}/bin/touch" "$out" + "${coreutils}/bin/touch" "$out" ]; pythonTransitiveLib = python3Lib { @@ -76,7 +89,7 @@ let ''); -in { +in depot.nix.utils.drvTargets { inherit pythonWithLib rustTransitiveLib