blob: 1eedd1b4b62bb12e6b5f9284771821444e0de789 (
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
72
73
74
75
76
77
78
79
80
81
82
|
{
config,
lib,
pkgs,
...
}: let
cfg = config.personal.nix;
in {
options.personal.nix = {
enable = lib.mkEnableOption "nix configuration";
gc.enable = lib.mkEnableOption "garbage collection";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
nixpkgs = {
config.allowUnfree = true;
flake = lib.mkDefault {
setNixPath = false;
setFlakeRegistry = false;
};
};
nix = {
package = pkgs.lix;
settings = {
auto-optimise-store = true;
experimental-features = ["nix-command" "flakes" "recursive-nix"];
substituters = ["https://devenv.cachix.org/" "https://nix-community.cachix.org/"];
trusted-public-keys = ["devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="];
};
extraOptions = ''
!include secrets.conf
'';
registry.my-nixpkgs = {
from = {
type = "indirect";
id = "my-nixpkgs";
};
to = {
type = "github";
owner = "qaristote";
repo = "my-nixpkgs";
};
};
};
}
(lib.mkIf cfg.gc.enable {
nix.gc = {
automatic = true;
dates = "daily";
options = "--delete-old";
};
systemd.services = {
nix-gc = {
after = ["nixos-upgrade.service"];
personal.monitor = true;
};
nix-gc-remove-dead-roots = {
enable = cfg.gc.enable;
description = "Remove dead symlinks in /nix/var/nix/gcroots";
serviceConfig.Type = "oneshot";
script = "find /nix/var/nix/gcroots -xtype l -delete";
before = ["nix-gc.service"];
wantedBy = ["nix-gc.service"];
personal.monitor = true;
};
nix-gc-remove-old-hm-gens = let
user = config.personal.user;
in {
enable = user.enable && user.homeManager.enable;
description = "Remove old Home Manager generations for user ${user.name}";
serviceConfig.Type = "oneshot";
script = "${pkgs.nix}/bin/nix-env --profile /home/${user.name}/.local/state/nix/profiles/home-manager --delete-generations old";
before = ["nix-gc.service"];
wantedBy = ["nix-gc.service"];
personal.monitor = true;
};
};
})
]);
}
|