fork/home-manager

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

Robert Helgessontests: add option `test.stubs`cb09a968

master
1.5 KiB72 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  # Samples taken from the ne manual.
8  keybindings = ''
9    SEQ  "\x1b[1;5D"  14A
10    KEY  14A          HELP
11  '';
12
13  menus = ''
14    MENU "File"
15    ITEM "Open...     ^O" Open
16    ITEM "Close         " Close
17    ITEM "DoIt          " Macro DoIt
18  '';
19
20  virtualExtensions = ''
21    sh   1  ^#!\s*/.*\b(bash|sh|ksh|zsh)\s*
22    csh  1  ^#!\s*/.*\b(csh|tcsh)\s*
23    pl   1  ^#!\s*/.*\bperl\b
24    py   1  ^#!\s*/.*\bpython[0-9]*\s*
25    rb   1  ^#!\s*/.*\bruby\s*
26    xml  1  ^<\?xml
27  '';
28
29  automaticPreferences = {
30    nix = ''
31      TAB 0
32      TS 2
33    '';
34    js = ''
35      TS 4
36    '';
37  };
38
39  checkFile = filename: contents: ''
40    assertFileExists home-files/.ne/${filename}
41    assertFileContent home-files/.ne/${filename} ${
42      builtins.toFile "checkFile" contents
43    }
44  '';
45
46in {
47  config = {
48    programs.ne = {
49      enable = true;
50      inherit keybindings;
51      inherit menus;
52      inherit virtualExtensions;
53      inherit automaticPreferences;
54    };
55
56    test.stubs.ne = { };
57
58    nmt = {
59      description = "Check that configuration files are correctly written";
60      script = concatStringsSep "\n" [
61        (checkFile ".keys" keybindings)
62        (checkFile ".extensions" virtualExtensions)
63        (checkFile ".menus" menus)
64
65        # Generates a check command for each entry in automaticPreferences.
66        (concatStringsSep "\n" (mapAttrsToList
67          (extension: contents: checkFile "${extension}#ap" contents)
68          automaticPreferences))
69      ];
70    };
71  };
72}