fork/home-manager

git clone https://git.julia.blue/fork/home-manager

musjjlf: simplify option validation (#4334)406d34d9

master
1.4 KiB85 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  pvScript = builtins.toFile "pv.sh" "cat $1";
7  expected = builtins.toFile "settings-expected" ''
8    set icons
9    set noignorecase
10    set ratios "2:2:3"
11    set tabstop 4
12
13    cmd added :echo "foo"
14    cmd multiline :{{
15      push gg
16      echo "bar"
17      push i
18    }}
19    cmd removed
20
21    map aa should-be-added
22    map ab
23
24    cmap <c-a> should-be-added
25    cmap <c-b>
26
27    set previewer ${pvScript}
28    map i ${"$"}${pvScript} "$f" | less -R
29
30
31
32    # More config...
33
34  '';
35in {
36  config = {
37    programs.lf = {
38      enable = true;
39
40      cmdKeybindings = {
41        "<c-a>" = "should-be-added";
42        "<c-b>" = null;
43      };
44
45      commands = {
46        added = '':echo "foo"'';
47        removed = null;
48        multiline = ''
49          :{{
50            push gg
51            echo "bar"
52            push i
53          }}'';
54      };
55
56      extraConfig = ''
57        # More config...
58      '';
59
60      keybindings = {
61        aa = "should-be-added";
62        ab = null;
63      };
64
65      previewer = {
66        keybinding = "i";
67        source = pvScript;
68      };
69
70      settings = {
71        ignorecase = false;
72        icons = true;
73        tabstop = 4;
74        ratios = [ 2 2 3 ];
75      };
76    };
77
78    test.stubs.lf = { };
79
80    nmt.script = ''
81      assertFileExists home-files/.config/lf/lfrc
82      assertFileContent home-files/.config/lf/lfrc ${expected}
83    '';
84  };
85}