-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnix.mod.nix
More file actions
150 lines (134 loc) · 3.74 KB
/
Copy pathnix.mod.nix
File metadata and controls
150 lines (134 loc) · 3.74 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{ self, inputs, ... }:
{
flake.commonModules.nix =
{
config,
lib,
pkgs,
...
}:
let
inherit (lib.attrsets)
attrsToList
filterAttrs
mapAttrs
mapAttrsToList
optionalAttrs
;
inherit (lib.lists) filter optional singleton;
inherit (lib.strings) concatStringsSep;
inherit (lib.trivial) const flip id;
inherit (lib.types) isType;
registryMap = filterAttrs (const <| isType "flake") inputs;
in
{
environment.systemPackages = [
pkgs.nh
pkgs.nix-index
pkgs.nix-output-monitor
];
system = optionalAttrs config.nixpkgs.hostPlatform.isLinux {
# We use `nh` and don't need nixos-rebuild, nixos-generate-config, etc.
disableInstallerTools = true;
};
nix.distributedBuilds = true;
nix.buildMachines =
self.nixosConfigurations
|> attrsToList
|> filter ({ name, value }: name != config.networking.hostName && value.config.users.users ? build)
|> map (
{ name, value }:
{
hostName = name;
maxJobs = 20;
protocol = "ssh-ng";
sshUser = "build";
supportedFeatures = [
"benchmark"
"big-parallel"
"kvm"
"nixos-test"
];
system = value.config.nixpkgs.hostPlatform.system;
}
);
nix.channel.enable = false;
nix.gc = {
automatic = true;
options = "--delete-older-than 3d";
};
nix.nixPath =
registryMap
|> mapAttrsToList (name: value: "${name}=${value}")
|> (if config.nixpkgs.hostPlatform.isDarwin then concatStringsSep ":" else id);
nix.registry =
registryMap // { default = inputs.nixpkgs; } |> mapAttrs (_: flake: { inherit flake; });
nix.settings =
(import <| self + /flake.nix).nixConfig
|> flip removeAttrs (optional config.nixpkgs.hostPlatform.isDarwin "use-cgroups");
nix.optimise.automatic = true;
nix.package = pkgs.nixVersions.latest;
home.extraModules = singleton {
programs.nushell.extraConfig = # nu
''
def --wrapped * [program: string = "", ...arguments] {
if ($program | str contains "#") or ($program | str contains ":") {
nix run $program -- ...$arguments
} else {
nix run ("default#" + $program) -- ...$arguments
}
}
def --wrapped > [...programs] {
nix shell ...($programs | each {
if ($in | str contains "#") or ($in | str contains ":") {
$in
} else {
"default#" + $in
}
})
}
'';
};
};
flake.nixosModules.nix =
{ lib, ... }:
let
inherit (lib.lists) singleton;
in
{
persist.subvolumes = singleton "/nix";
# TODO: Replace with nullfs when it becomes user-mountable.
#
# fileSystems."/nix/var/nix/profiles/per-user" = {
# device = "nullfs";
# fsType = "nullfs";
# options = singleton "X-mount.mkdir";
# };
fileSystems."/nix/var/nix/profiles/per-user" = {
device = "tmpfs";
fsType = "tmpfs";
options = [
"ro"
"size=1M"
"mode=755"
"X-mount.mkdir"
];
};
nix.gc = {
dates = "weekly";
persistent = true;
};
};
flake.darwinModules.nix =
{ lib, ... }:
let
inherit (lib.lists) singleton;
in
{
nix.gc.interval = singleton {
Hour = 3;
Minute = 15;
Weekday = 7;
};
};
}