1# Call nix-build on this file to run all tests in this directory
2
3# This produces a link farm derivation with the original attrs
4# merged on top of it.
5# You can run parts of the "hierarchy" with for example:
6# nix-build -A java-properties
7# See `structured` below.
8
9{
10 pkgs ? import ../../.. { },
11}:
12let
13 inherit (pkgs.lib)
14 mapAttrs
15 mapAttrsToList
16 isDerivation
17 mergeAttrs
18 foldl'
19 attrValues
20 recurseIntoAttrs
21 ;
22
23 structured = {
24 formats = import ./formats.nix { inherit pkgs; };
25 java-properties = recurseIntoAttrs {
26 jdk11 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk11_headless; };
27 jdk17 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk17_headless; };
28 jdk = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk_headless; };
29 };
30
31 libconfig = recurseIntoAttrs (import ../formats/libconfig/test { inherit pkgs; });
32
33 hocon = recurseIntoAttrs (import ../formats/hocon/test { inherit pkgs; });
34 };
35
36 flatten =
37 prefix: as:
38 foldl' mergeAttrs { } (
39 attrValues (
40 mapAttrs (
41 k: v:
42 if isDerivation v then
43 { "${prefix}${k}" = v; }
44 else if v ? recurseForDerivations then
45 flatten "${prefix}${k}-" (removeAttrs v [ "recurseForDerivations" ])
46 else
47 builtins.trace v throw "expected derivation or recurseIntoAttrs"
48 ) as
49 )
50 );
51in
52
53# It has to be a link farm for inclusion in the hydra unstable jobset.
54pkgs.linkFarm "pkgs-lib-formats-tests" (
55 mapAttrsToList (k: v: {
56 name = k;
57 path = v;
58 }) (flatten "" structured)
59)
60// structured