about summary refs log tree commit diff
path: root/pkgs/pkgs-lib/tests/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/pkgs-lib/tests/default.nix')
-rw-r--r--pkgs/pkgs-lib/tests/default.nix48
1 files changed, 43 insertions, 5 deletions
diff --git a/pkgs/pkgs-lib/tests/default.nix b/pkgs/pkgs-lib/tests/default.nix
index f3549ea9b0f2c..ae91e15aa9efa 100644
--- a/pkgs/pkgs-lib/tests/default.nix
+++ b/pkgs/pkgs-lib/tests/default.nix
@@ -1,7 +1,45 @@
 # Call nix-build on this file to run all tests in this directory
-{ pkgs ? import ../../.. {} }:
+
+# This produces a link farm derivation with the original attrs
+# merged on top of it.
+# You can run parts of the "hierarchy" with for example:
+#     nix-build -A java-properties
+# See `structured` below.
+
+{ pkgs ? import ../../.. { } }:
 let
-  formats = import ./formats.nix { inherit pkgs; };
-in pkgs.linkFarm "nixpkgs-pkgs-lib-tests" [
-  { name = "formats"; path = import ./formats.nix { inherit pkgs; }; }
-]
+  inherit (pkgs.lib) mapAttrs mapAttrsToList isDerivation mergeAttrs foldl' attrValues recurseIntoAttrs;
+
+  structured = {
+    formats = import ./formats.nix { inherit pkgs; };
+    java-properties = recurseIntoAttrs {
+      jdk8 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk8; };
+      jdk11 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk11_headless; };
+      jdk17 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk17_headless; };
+    };
+  };
+
+  flatten = prefix: as:
+    foldl'
+      mergeAttrs
+      { }
+      (attrValues
+        (mapAttrs
+          (k: v:
+            if isDerivation v
+            then { "${prefix}${k}" = v; }
+            else if v?recurseForDerivations
+            then flatten "${prefix}${k}-" (removeAttrs v [ "recurseForDerivations" ])
+            else builtins.trace v throw "expected derivation or recurseIntoAttrs")
+          as
+        )
+      );
+in
+
+# It has to be a link farm for inclusion in the hydra unstable jobset.
+pkgs.linkFarm "pkgs-lib-formats-tests"
+  (mapAttrsToList
+    (k: v: { name = k; path = v; })
+    (flatten "" structured)
+  )
+// structured