pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / pkgs-lib / formats / hocon / test / comprehensive / default.nix
blobae4fae443d41b529c12967794f58a5febe14dcd4
1 { lib, formats, stdenvNoCC, writeText, ... }:
2 let
3   hocon = formats.hocon { };
5   include_file = (writeText "hocon-test-include.conf" ''
6     "val" = 1
7   '').overrideAttrs (_: _: {
8     outputHashAlgo = "sha256";
9     outputHashMode = "flat";
10     outputHash = "sha256-UhkJLhT3bD6znq+IdDjs/ahP19mLzrLCy/R14pVrfew=";
11   });
13   expression = {
14     simple_top_level_attr = "1.0";
15     nested.attrset.has.a.integer.value = 100;
16     some_floaty = 29.95;
18     array2d = [
19       [ 1 2 "a" ]
20       [ 2 1 "b" ]
21     ];
22     nasty_string = "\"@\n\\\t^*\b\f\n\0\";'''$";
24     "misc attrs" = {
25       x = 1;
26       y = hocon.lib.mkAppend { a = 1; };
27     };
29     "cursed \" .attrs \" " = {
30       "a" = 1;
31       "a b" = hocon.lib.mkSubstitution "a";
32       "a b c" = hocon.lib.mkSubstitution {
33         value = "a b";
34         required = false;
35       };
36     };
38     to_include = {
39       _includes = [
40         (hocon.lib.mkInclude include_file)
41         (hocon.lib.mkInclude "https://example.com")
42         (hocon.lib.mkInclude {
43           required = true;
44           type = "file";
45           value = include_file;
46         })
47         (hocon.lib.mkInclude { value = include_file; })
48         (hocon.lib.mkInclude {
49           value = "https://example.com";
50           type = "url";
51         })
52       ];
53     };
54   };
56   hocon-test-conf = hocon.generate "hocon-test.conf" expression;
58   stdenvNoCC.mkDerivation {
59     name = "pkgs.formats.hocon-test-comprehensive";
61     dontUnpack = true;
62     dontBuild = true;
64     doCheck = true;
65     checkPhase = ''
66       runHook preCheck
68       diff -U3 ${./expected.txt} ${hocon-test-conf}
70       runHook postCheck
71     '';
73     installPhase = ''
74       runHook preInstall
76       mkdir $out
77       cp ${./expected.txt} $out/expected.txt
78       cp ${hocon-test-conf} $out/hocon-test.conf
79       cp ${hocon-test-conf.passthru.json} $out/hocon-test.json
81       runHook postInstall
82     '';
83   }