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{ pkgs ? import ../../.. { } }:
10let
11 inherit (pkgs.lib) mapAttrs mapAttrsToList isDerivation mergeAttrs foldl' attrValues recurseIntoAttrs;
12
13 structured = {
14 formats = import ./formats.nix { inherit pkgs; };
15 java-properties = recurseIntoAttrs {
16 jdk8 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk8; };
17 jdk11 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk11_headless; };
18 jdk17 = pkgs.callPackage ../formats/java-properties/test { jdk = pkgs.jdk17_headless; };
19 };
20
21 libconfig = recurseIntoAttrs (import ../formats/libconfig/test { inherit pkgs; });
22
23 hocon = recurseIntoAttrs (import ../formats/hocon/test { inherit pkgs; });
24 };
25
26 flatten = prefix: as:
27 foldl'
28 mergeAttrs
29 { }
30 (attrValues
31 (mapAttrs
32 (k: v:
33 if isDerivation v
34 then { "${prefix}${k}" = v; }
35 else if v?recurseForDerivations
36 then flatten "${prefix}${k}-" (removeAttrs v [ "recurseForDerivations" ])
37 else builtins.trace v throw "expected derivation or recurseIntoAttrs")
38 as
39 )
40 );
41in
42
43# It has to be a link farm for inclusion in the hydra unstable jobset.
44pkgs.linkFarm "pkgs-lib-formats-tests"
45 (mapAttrsToList
46 (k: v: { name = k; path = v; })
47 (flatten "" structured)
48 )
49// structured