-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfiguration.nix
389 lines (333 loc) · 9.65 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
{ config, lib, pkgs, options, ... }:
let
theme = import ./theme.nix;
secrets = import "${fetchGit {
url = "ssh://[email protected]/aaronjanse/secrets.git";
rev = "16fe9eb16fb4e32d5b2b3e5d4d5cbc3ac8e0ae32";
}}"
{ inherit pkgs; };
in
{
/* Nix preferences */
nix = {
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes ca-references
builders-use-substitutes = true
'';
distributedBuilds = true;
};
nix.trustedUsers = [ "ajanse" ];
/* XPS 13 hardware */
boot.kernelParams = [ "mem_sleep_default=deep" ];
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.requestEncryptionCredentials = [ "zzroot" ];
hardware.enableRedistributableFirmware = true;
powerManagement.powertop.enable = true;
# Disable sleep
# # systemd.targets.sleep.enable = false;
# # systemd.targets.suspend.enable = false;
# # systemd.targets.hibernate.enable = false;
# # systemd.targets.hybrid-sleep.enable = false;
boot.extraModulePackages = [ config.boot.kernelPackages.v4l2loopback ];
hardware.opengl = {
enable = true;
extraPackages = with pkgs; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
];
driSupport32Bit = true;
};
environment.systemPackages = with pkgs; [
nixFlakes
git
vaapiIntel
vaapi-intel-hybrid
libva-full
libva-utils
intel-media-driver
v4l-utils
gnome3.adwaita-icon-theme
vanilla-dmz
];
# services.neo4j = {
# enable = true;
# bolt.tlsLevel = "DISABLED";
# https.enable = false;
# extraServerConfig = ''
# apoc.export.file.enabled=true
# '';
# };
services.postgresql = {
enable = true;
ensureUsers = [ ];
initialScript = secrets.postgresqlInit;
};
/* Boot */
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = false;
grub.enable = false;
};
boot.loader.grub.copyKernels = true;
# boot.kernelPatches = let hashes = [
# "sha256-ffrN0y5Us/VJ1v6JObfkSVD4PCm23wueI0JXjoRcOao="
# "sha256-mh9MgRtLp4+sXjM6GHkAkyyvp5DP3yTxl+d/kJ3+KJQ="
# "sha256-1Jy1uv9x1c06/auY1aHN0SuyOsbIF1IcaK8/PuGmX8Q="
# "sha256-QE3NfIg60RxV528AbpNAcxIdToplRNm5DgMNPn6AjHQ="
# "sha256-zyL1g2oNiTzYfS5qUOehduGfzFfi2WIVLCQMg+XGBwE="
# "sha256-f79tof0O5HBFwLbddR9FOqqLsqGsHqMZM45uYZNcoec="
# "sha256-JD0bi4sjsI9qRpHXxcPlGpiiwXMu2oPm/HJU8iQI1ag="
# "sha256-V+AGk7FGNiidd22ektlGCvSh3Wo2bRrUWp6qgGmsKPI="
# ]; in builtins.genList (i: {
# name = "fuse_passthrough ${toString (i+1)}/8";
# patch = pkgs.fetchpatch {
# url = "https://lore.kernel.org/lkml/20210125153057.3623715-${toString (i+2)}[email protected]/raw";
# sha256 = builtins.elemAt hashes i;
# };
# }) 8;
/* Maintenance */
time.timeZone = "America/Los_Angeles";
services.journald.extraConfig = "MaxRetentionSec=1week";
boot.cleanTmpDir = true;
boot.tmpOnTmpfs = true;
systemd = {
timers.zbak-snap = {
wantedBy = [ "timers.target" ];
partOf = [ "zbak-snap.service" ];
timerConfig.OnCalendar = "*:0/15";
};
services.zbak-snap = {
serviceConfig.Type = "oneshot";
path = [ pkgs.zbak ];
script = ''
zbak snap zzroot/code --keep 7d24h4f
'';
};
# timers.zbak-send = {
# wantedBy = [ "timers.target" ];
# partOf = [ "zbak-send.service" ];
# timerConfig.OnCalendar = "*:10,40";
# };
# services.zbak-send = {
# serviceConfig.Type = "oneshot";
# path = [ pkgs.zbak ];
# script = ''
# [ $(cat /sys/class/power_supply/BAT0/status) = "Full" ] && \
# zbak send --name ssd500gb \
# --from zzroot/code \
# --to [email protected]:rpool/code \
# --keep 6m4w7d
# '';
# };
};
/* Security */
services.openssh.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.adb.enable = true;
security.sudo = {
enable = true;
wheelNeedsPassword = true;
};
users.mutableUsers = true;
users.users.ajanse = {
isNormalUser = true;
uid = 1000;
group = "users";
extraGroups = [
"wheel"
"lp" # for bluetooth
"video"
"audio"
"vboxusers"
"adbusers"
"libvirtd"
"kvm"
"adbusers"
"docker"
"bluetooth"
];
createHome = true;
home = "/home/ajanse";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILBA0RNuRdCTQgK15gzpqMBHH9XBbkvE2z7orygz67jv" # Phone
];
};
users.users.enclave = {
isNormalUser = true;
uid = 1001;
group = "users";
extraGroups = [ "wheel" ];
createHome = true;
home = "/home/enclave";
};
/* Shell */
users.defaultUserShell = pkgs.fish;
environment.pathsToLink = [ "/share/zsh" "/share/fish" ];
environment.variables.MOZ_X11_EGL = "1";
environment.variables.EDITOR = "${pkgs.kakoune}/bin/kak";
environment.etc."fish/config.fish".text = ''
set REPO_DIR $HOME/school/sp21-s367
set SNAPS_DIR $HOME/school/snaps-sp21-s367
set GOPATH $HOME/.go
alias enter="sudo ip netns exec wguard su - enclave"
alias ls=exa
'';
/* Networking */
networking = {
hostName = "xps-ajanse";
networkmanager.enable = true;
nameservers = pkgs.lib.mkForce [ "193.138.218.74" ]; # mullvad
iproute2.enable = true;
firewall = {
enable = true;
allowedTCPPorts = [ 80 ];
allowedUDPPorts = [ 51820 41641 ];
trustedInterfaces = [ "wg0" ];
};
hosts = {
"192.168.1.249" = [ "BRW707781875760.local" ];
"172.31.98.1" = [ "aruba.odyssys.net" ];
"127.0.0.1" = [ "localhost.dev" "local.metaculus.com" ];
};
};
services.tailscale.enable = true;
services.rpcbind.enable = true;
services.nfs.server.enable = true;
networking.wireguard.enable = true;
networking.wireguard.interfaces.wg0 = secrets.wireguard;
/* Sound */
sound.enable = true;
hardware.pulseaudio = {
enable = true;
daemon.config = { flat-volumes = "no"; };
};
/* Bluetooth */
hardware.bluetooth.enable = true;
services.blueman.enable = true;
programs.dconf.enable = true;
services.dbus.packages = [ pkgs.blueman pkgs.foliate ];
hardware.pulseaudio = {
extraModules = [ pkgs.pulseaudio-modules-bt ];
package = pkgs.pulseaudioFull;
};
services.pcscd.enable = true;
services.udev.packages = [
pkgs.yubikey-personalization
pkgs.libu2f-host
pkgs.android-udev-rules
];
# systemd.user.sockets.gpg-agent-ssh = {
# wantedBy = [ "sockets.target" ];
# listenStreams = [ "%t/gnupg/S.gpg-agent.ssh" ];
# socketConfig = {
# FileDescriptorName = "ssh";
# Service = "gpg-agent.service";
# SocketMode = "0600";
# DirectoryMode = "0700";
# };
# };
# environment.shellInit = ''
# export GPG_TTY="$(tty)"
# ${pkgs.gnupg}/bin/gpg-connect-agent /bye
# export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
# '';
# services.yubikey-agent.enable = true;
programs = {
ssh.startAgent = false;
gnupg.agent.enable = true;
gnupg.agent.enableSSHSupport = true;
gnupg.agent.pinentryFlavor = "gtk2";
};
/* User Interface */
services.xserver = {
enable = true;
displayManager.gdm = {
enable = true;
wayland = true;
};
desktopManager.gnome.enable = true;
};
programs.light.enable = true;
/* HiDPI */
console = {
earlySetup = true;
font = "sun12x22";
colors = theme.colors16;
};
services.xserver.dpi = 192;
services.xserver.displayManager.sessionCommands = ''
${pkgs.xorg.xrdb}/bin/xrdb -merge <<EOF
Xcursor.theme: Vanilla-DMZ
Xcursor.size: 32
EOF
${pkgs.xorg.xrandr}/bin/xrandr --output eDP-1 --scale 1.25x1.25
'';
environment.variables = {
GDK_SCALE = "1.5";
GDK_DPI_SCALE = "0.75";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
};
/* Peripherials */
services.xserver.xkbOptions = "compose:caps";
services.xserver.libinput = {
enable = true;
touchpad = {
tappingDragLock = false;
naturalScrolling = true;
};
};
systemd.user.services.xinput-config = {
description = "configure xinput for xps";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
script = ''
${pkgs.xorg.xinput}/bin/xinput set-prop "SynPS/2 Synaptics TouchPad" "libinput Accel Speed" 0.55 || true
${pkgs.xorg.xinput}/bin/xinput set-prop "SynPS/2 Synaptics TouchPad" "libinput Tapping Drag Enabled" 0 || true
${pkgs.xorg.xinput}/bin/xinput set-prop "SysPS/2 Synaptics TouchPad" "libinput Disable While Typing Enabled" 0 || true
'';
};
/* Printing */
services.printing.enable = true;
services.printing.drivers = [ pkgs.brlaser pkgs.mfcl2740dwlpr pkgs.mfcl2740dwcupswrapper ];
services.avahi.enable = true;
services.avahi.nssmdns = true;
/* Default Fonts */
fonts = {
fontDir.enable = true;
fonts = with pkgs;[
corefonts
inconsolata
terminus_font
dejavu_fonts
ubuntu_font_family
source-code-pro
source-sans-pro
source-serif-pro
roboto-mono
roboto
overpass
libre-baskerville
font-awesome
julia-mono
];
};
/* Virtualization */
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
# virtualisation.libvirtd.enable = true;
# virtualisation.cri-o = {
# enable = true;
# storageDriver = "vfs";
# };
# virtualisation.virtualbox.host = {
# enable = true;
# enableExtensionPack = false; # takes a long time to build
# };
# virtualisation.docker = {
# enable = true;
# storageDriver = "zfs";
# };
system.stateVersion = "19.03";
}