blob: 3db8dfed80a9a1a5b18450aea082a9df93b5d129 (
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
63
64
65
66
67
68
69
70
71
|
{
config,
lib,
pkgs,
inputs,
...
}:
let
cfg = config.gitignore;
ignoreDevenv = cfg.devenv.enable or false;
templates = lib.attrNames (
lib.filterAttrs (name: value: (value.enable or false) && name != "devenv") cfg
);
toUncomment = builtins.concatLists (lib.collect lib.isList cfg);
in
{
options.gitignore = lib.mkOption {
type =
with lib.types;
(submodule {
freeformType =
with lib.types;
attrsOf (submodule {
options = {
enable = lib.mkEnableOption "";
uncomment = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
description = "Lines that should be uncommented and thus enabled in the template file.";
};
};
});
options.extra = lib.mkOption {
type = lib.types.lines;
default = "";
example = ''
*.my-file-extension
'';
};
});
default = {
extra = "";
};
};
config = {
dotfiles.".gitignore" = lib.mkIf (templates != { } || cfg.extra != "") {
gitignore = lib.mkDefault false;
text =
lib.optionalString (templates != [ ]) (
builtins.readFile (
(pkgs.extend inputs.my-nixpkgs.overlays.personal).personal.static.gitignore.override {
inherit templates toUncomment;
}
)
)
+ lib.optionalString ignoreDevenv ''
### devenv
.devenv/
.devenv.flake.nix
devenv.local.nix
.pre-commit-config.yaml
''
+ lib.optionalString (cfg.extra != "") ''
### miscellaneous
${cfg.extra}
'';
};
gitignore.devenv.enable = lib.mkDefault true;
};
}
|