-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.nix
363 lines (328 loc) · 9.54 KB
/
configuration.nix
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
{
config,
pkgs,
lib,
apple-fonts,
ectool,
...
}: {
imports = [
./hardware-configuration.nix
./disko-configuration.nix
];
boot = {
blacklistedKernelModules = ["hid_sensor_hub"];
extraModprobeConfig = ''
options snd_hda_intel power_save=1
'';
initrd.systemd.enable = true;
kernelPackages = pkgs.linuxPackages_latest;
kernel.sysctl = {
# enable REISUB: https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
"kernel.sysrq" = 1 + 16 + 32 + 64 + 128;
};
lanzaboote = {
enable = true;
configurationLimit = 2;
pkiBundle = "/etc/secureboot";
};
loader = {
efi.canTouchEfiVariables = true;
systemd-boot.enable = lib.mkForce false;
};
};
environment.pathsToLink = [
"/share/zsh"
];
environment.systemPackages = with pkgs; [
aspell
aspellDicts.en
awscli2
brightnessctl
btrbk
chromium
diff-so-fancy
dig
ectool.packages."${pkgs.system}".ectool
efm-langserver
evolution
exiftool
fd
foot
fzf
gcc
gh
git
gnome-text-editor
gnome-calculator
gnome-calendar
gnome-monitor-config
gnome-clocks
gnome-contacts
nautilus
gnomeExtensions.appindicator
gnomeExtensions.light-style
gnomeExtensions.night-theme-switcher
gnumake
gnupg
htop
imagemagick
jpegoptim
jq
libreoffice
libva-utils
loupe
mpv
neovim
nodejs_20
optipng
pass-wayland
papers
pinentry-gnome3
prettierd
powerstat
powertop
pure-prompt
python3
rclone
sbctl
signal-desktop
tmux
tree
wl-clipboard
yt-dlp
zsh
zsh-z
];
environment.variables = {
EDITOR = "nvim";
QT_QPA_PLATFORM = "wayland";
};
fonts = {
enableDefaultPackages = false;
packages = [
pkgs.noto-fonts-color-emoji
apple-fonts.packages."${pkgs.system}".sf-pro
];
fontconfig = {
antialias = true;
hinting = {
enable = false;
autohint = false;
style = "none";
};
subpixel = {
lcdfilter = "none";
rgba = "none";
};
defaultFonts = {
serif = ["DejaVu Serif"];
sansSerif = ["SF Pro Text"];
monospace = ["DejaVu Sans Mono"];
emoji = ["Noto Color Emoji"];
};
localConf = ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<selectfont>
<rejectfont>
<pattern>
<patelt name="family">
<string>Cantarell</string>
</patelt>
</pattern>
</rejectfont>
</selectfont>
</fontconfig>
'';
};
};
hardware.enableAllFirmware = true;
hardware.pulseaudio.enable = false;
hardware.sensor.iio.enable = false;
i18n.defaultLocale = "en_GB.UTF-8";
networking.firewall = {
enable = true;
allowedTCPPorts = [
# Expo
8081
];
};
networking.hostName = "framework";
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
randomizedDelaySec = "1 hour";
};
nix.settings = {
experimental-features = [
"nix-command"
"flakes"
];
substituters = [
"https://tlvince-nixos-config.cachix.org"
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
trusted-public-keys = [
"tlvince-nixos-config.cachix.org-1:PYVWI+uNlq7mSJxFSPDkkCEtaeQeF4WvjtQKa53ZOyM="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
nixpkgs.config.allowUnfree = true;
programs.firefox.enable = true;
programs.zsh.enable = true;
services.btrbk.instances = {
btrbk = {
# Timer disabled in favour of hourly & daily timers
# TODO: upstream more configurables
onCalendar = null;
settings = {
backend_remote = "btrfs-progs-sudo";
lockfile = "/var/lib/btrbk/btrbk.lock";
snapshot_create = "onchange";
snapshot_dir = "snapshots";
ssh_identity = "/var/lib/btrbk/.ssh/id_ed25519";
ssh_user = "btrbk";
timestamp_format = "long";
archive_preserve = "30d *m";
archive_preserve_min = "latest";
snapshot_preserve = "24h 7d 0w 0m 0y";
snapshot_preserve_min = "latest";
target_preserve = "0h 14d 6w 4m 1y";
target_preserve_min = "latest";
volume = {
"/mnt/btrfs-root" = {
target = {
"ssh://bpim5:6683/mnt/catmull/snapshots/${config.networking.hostName}" = {
subvolume = {
"/" = {
snapshot_name = "root";
};
"/home" = {};
};
};
};
};
};
};
};
};
systemd.services.btrbk-local = {
description = "Take local Btrfs snapshots";
unitConfig.Documentation = "man:btrbk(1)";
path = ["/run/wrappers"] ++ config.services.btrbk.extraPackages;
after = ["time-sync.target"];
serviceConfig = {
User = "btrbk";
Group = "btrbk";
Type = "oneshot";
ExecStart = "${pkgs.btrbk}/bin/btrbk snapshot";
Nice = config.services.btrbk.niceness;
IOSchedulingClass = config.services.btrbk.ioSchedulingClass;
StateDirectory = "btrbk";
};
};
systemd.services.btrbk-remote = {
description = "Takes local Btrfs snapshots and back up to given targets";
unitConfig.Documentation = "man:btrbk(1)";
path = ["/run/wrappers"] ++ config.services.btrbk.extraPackages;
wants = ["network-online.target"];
after = ["btrbk-local.service" "network-online.target" "time-sync.target"];
serviceConfig = {
User = "btrbk";
Group = "btrbk";
Type = "oneshot";
ExecStart = "${pkgs.btrbk}/bin/btrbk run";
Nice = config.services.btrbk.niceness;
IOSchedulingClass = config.services.btrbk.ioSchedulingClass;
StateDirectory = "btrbk";
};
};
systemd.timers.btrbk-local = {
description = "Timer to take Btrfs snapshots and maintain retention policies.";
wantedBy = ["timers.target"];
timerConfig = {
AccuracySec = "10min";
OnBootSec = "5min";
OnCalendar = "hourly";
Persistent = true;
RandomizedDelaySec = "5min";
};
};
systemd.timers.btrbk-remote = {
description = "Timer to take Btrfs snapshots and maintain retention policies.";
wantedBy = ["timers.target"];
timerConfig = {
AccuracySec = "10min";
OnBootSec = "5min";
OnCalendar = "daily";
Persistent = true;
RandomizedDelaySec = "5min";
};
};
services.fprintd.enable = true;
services.fstrim.enable = true;
services.fwupd.enable = true;
# https://github.com/NixOS/nixpkgs/blob/d1f920fa88f38a50cab7ba62d77b7e1d5727222d/nixos/modules/services/x11/desktop-managers/gnome.nix
services.gnome.core-developer-tools.enable = false;
services.gnome.core-os-services.enable = true;
services.gnome.core-shell.enable = true;
services.gnome.core-utilities.enable = false;
services.gnome.games.enable = false;
services.hardware.bolt.enable = true;
services.printing.enable = false;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.enable = true;
services.xserver.excludePackages = [pkgs.xterm];
# services.gnome.core-shell
services.gnome.gnome-browser-connector.enable = false;
services.gnome.gnome-initial-setup.enable = false;
services.gnome.gnome-remote-desktop.enable = false;
services.gnome.gnome-user-share.enable = false;
services.gnome.rygel.enable = false;
environment.gnome.excludePackages = with pkgs; [
# services.gnome.core-shell
evince
geary
gnome-backgrounds
gnome-shell-extensions
gnome-tour
gnome-user-docs
orca
];
services.resolved.enable = true;
services.power-profiles-daemon.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
services.udev.extraRules = ''
# PCI auto suspend
SUBSYSTEM=="pci", ATTR{power/control}="auto"
# USB auto suspend
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
# Power switching, power saver handled by GNOME/UPower when low capacity (20%)
# https://github.com/NixOS/nixpkgs/blob/9357f4f23713673f310988025d9dc261c20e70c6/nixos/modules/services/hardware/upower.nix#L88
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced", RUN+="${pkgs.systemd}/bin/systemd-run --user --machine tlv@ ${pkgs.gnome-monitor-config}/bin/gnome-monitor-config set --logical-monitor --monitor eDP-1 --primary --mode '2880x1920@60.001+vrr' --scale 2"
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced", RUN+="${pkgs.systemd}/bin/systemd-run --user --machine tlv@ ${pkgs.gnome-monitor-config}/bin/gnome-monitor-config set --logical-monitor --monitor eDP-1 --primary --mode '2880x1920@120.000+vrr' --scale 2"
'';
system.stateVersion = "23.05";
systemd.services.wpa_supplicant = {
serviceConfig = {
# mt7921e CTRL-EVENT-SIGNAL-CHANGE spam with WiFi 6 APs
LogLevelMax = "notice";
};
};
time.timeZone = "Europe/London";
users.users.tlv = {
shell = pkgs.zsh;
isNormalUser = true;
extraGroups = ["wheel"];
};
}