fork/home-manager

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

Ronny Pfannschmidtgit: add option to define store names for generated include files (#3171)5bb1f675

master
2.4 KiB101 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  gitInclude = {
8    user = {
9      name = "John Doe";
10      email = "user@example.org";
11    };
12  };
13
14  substituteExpected = path:
15    pkgs.substituteAll {
16      src = path;
17      git_include_path = pkgs.writeText "hm_gitconfig"
18        (builtins.readFile ./git-expected-include.conf);
19      git_named_include_path = pkgs.writeText "hm_gitconfigwork"
20        (builtins.readFile ./git-expected-include.conf);
21    };
22
23in {
24  config = {
25    programs.git = mkMerge [
26      {
27        enable = true;
28        package = pkgs.gitMinimal;
29        aliases = {
30          a1 = "foo";
31          a2 = "bar";
32          escapes = ''"\n	'';
33        };
34        extraConfig = {
35          extra = {
36            name = "value";
37            multiple = [ 1 ];
38          };
39        };
40        ignores = [ "*~" "*.swp" ];
41        includes = [
42          { path = "~/path/to/config.inc"; }
43          {
44            path = "~/path/to/conditional.inc";
45            condition = "gitdir:~/src/dir";
46          }
47          {
48            condition = "gitdir:~/src/dir";
49            contents = gitInclude;
50          }
51          {
52            condition = "gitdir:~/src/otherproject";
53            contents = gitInclude;
54            contentSuffix = "gitconfig-work";
55          }
56        ];
57        signing = {
58          gpgPath = "path-to-gpg";
59          key = "00112233445566778899AABBCCDDEEFF";
60          signByDefault = true;
61        };
62        userEmail = "user@example.org";
63        userName = "John Doe";
64        lfs.enable = true;
65        delta = {
66          enable = true;
67          options = {
68            features = "decorations";
69            whitespace-error-style = "22 reverse";
70            decorations = {
71              commit-decoration-style = "bold yellow box ul";
72              file-style = "bold yellow ul";
73              file-decoration-style = "none";
74            };
75          };
76        };
77      }
78
79      {
80        aliases.a2 = mkForce "baz";
81        extraConfig."extra \"backcompat.with.dots\"".previously = "worked";
82        extraConfig.extra.boolean = true;
83        extraConfig.extra.integer = 38;
84        extraConfig.extra.multiple = [ 2 ];
85        extraConfig.extra.subsection.value = "test";
86      }
87    ];
88
89    test.stubs = {
90      git-lfs = { };
91      delta = { };
92    };
93
94    nmt.script = ''
95      assertFileExists home-files/.config/git/config
96      assertFileContent home-files/.config/git/config ${
97        substituteExpected ./git-expected.conf
98      }
99    '';
100  };
101}