blob: 867534c1f14930f2df56082c06c5aa62489d0c24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
{ config, lib, pkgs, ... }:
with lib;
let
in {
options.examples = mkOption { type = types.attrsOf hm.types.gvariant; };
config = {
examples = with hm.gvariant;
mkMerge [
{ bool = true; }
{ bool = true; }
{ float = 3.14; }
{ int = 42; }
{ int = 42; }
{ list = [ "one" ]; }
{ list = mkArray type.string [ "two" ]; }
{ emptyArray1 = [ ]; }
{ emptyArray2 = mkEmptyArray type.uint32; }
{ string = "foo"; }
{ string = "foo"; }
{ escapedString = "' \\"; }
{ tuple = mkTuple [ 1 [ "foo" ] ]; }
{ maybe1 = mkNothing type.string; }
{ maybe2 = mkJust (mkUint32 4); }
];
home.file."result.txt".text = let
mkLine = n: v: "${n} = ${toString (hm.gvariant.mkValue v)}";
result = concatStringsSep "\n" (mapAttrsToList mkLine config.examples);
in result + "\n";
nmt.script = ''
assertFileContent \
home-files/result.txt \
${
pkgs.writeText "expected.txt" ''
bool = true
emptyArray1 = @as []
emptyArray2 = @as []
escapedString = '\' \\'
float = 3.140000
int = 42
list = @as ['one','two']
maybe1 = @ms nothing
maybe2 = just @u 4
string = 'foo'
tuple = @(ias) (1,@as ['foo'])
''
}
'';
};
}
|