/
configuration.nix
633 lines (552 loc) · 15.7 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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
{ config, inputs, pkgs, lib, ... }:
let
keys = import ../../common/data/keys.nix;
userData = import ../../common/data/users.nix;
dwarffsModule =
{ pkgs, ... }@args:
let
originalModule = inputs.dwarffs.nixosModules.dwarffs args;
in
originalModule // {
# Overlay is already added when creating our pkgs (and with the correct Nix).
nixpkgs = builtins.removeAttrs originalModule.nixpkgs [ "overlays" ];
};
firefox = pkgs.firefox-wayland.override (args: args // {
cfg = args.cfg or {} // {
# nixpkgs.config NixOS option not actually passed to Nixpkgs
# so we need to replicate this part of chrome-gnome-shell module.
enableGnomeExtensions = true;
};
# Needs to match remoting name.
wmClass = "firefox-default";
extraPrefs = ''
// Downloading random PDFs from http website is super annoing with this.
lockPref("dom.block_download_insecure", false);
// Always use XDG portals for stuff
lockPref("widget.use-xdg-desktop-portal.file-picker", 1);
'';
});
openLocalhostAsHttp = pkgs.makeDesktopItem {
name = "localhost-proto-handler";
desktopName = "Open localhost protocol as http";
noDisplay = true;
exec = "${lib.getBin pkgs.glib}/bin/gio open http://%u";
mimeTypes = [
"x-scheme-handler/localhost"
];
};
in {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
dwarffsModule
inputs.self.nixosModules.profiles.virt
inputs.self.nixosModules.profiles.fonts
./development/web.nix
../../common/cachix.nix
];
boot.supportedFilesystems = [ "ntfs" ];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.luks.devices = {
root = {
device = "/dev/disk/by-uuid/cdfe8ed6-90bf-4b26-a1d3-0f0efa267c58"; # Obtained using `blkid /dev/sda2`
preLVM = true;
allowDiscards = true;
};
};
boot.kernelModules = [
"v4l2loopback"
];
boot.extraModulePackages = [
config.boot.kernelPackages.v4l2loopback.out
];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelParams = [
"boot.shell_on_fail"
# https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation
"resume_offset=1736704" # physical offset of the first ext in `filefrag -v /var/swap`
# The passive default severely degrades performance.
"intel_pstate=active"
];
boot.resumeDevice = "/dev/mapper/verbatim--20--vg-root";
# Sony Vaio keyboard not working after suspend
# https://discourse.nixos.org/t/keyboard-touchpad-do-not-wake-after-closing-laptop-lid/7565/6
powerManagement.resumeCommands = "${pkgs.kmod}/bin/rmmod atkbd; ${pkgs.kmod}/bin/modprobe atkbd reset=1";
boot.kernel.sysctl = {
# Note that inotify watches consume 1kB on 64-bit machines.
"fs.inotify.max_user_watches" = 1048576; # default: 8192
"fs.inotify.max_user_instances" = 1024; # default: 128
"fs.inotify.max_queued_events" = 32768; # default: 16384
"kernel.perf_event_paranoid" = 1; # for rr, default: 2
"kernel.sysrq" = 1; # allow all magic SysRq keys
};
systemd.tmpfiles.rules = [
# 12G (RAM size) for hibernation image size
# https://bbs.archlinux.org/viewtopic.php?pid=1731292#p1731292
"w /sys/power/image_size - - - - ${toString (12*1024*1024*1024)}"
];
boot.cleanTmpDir = true;
# Select internationalisation properties.
console = {
font = "Lat2-Terminus16";
useXkbConfig = true;
};
i18n = {
defaultLocale = "en_GB.UTF-8";
};
# Set your time zone.
time.timeZone = "Europe/Prague";
swapDevices = [
{
device = "/var/swap";
size = 1024 * 8 * 2; # twice the RAM should leave enough space for hibernation
}
];
# Configure sound.
hardware = {
pulseaudio.enable = false; # Using PipeWire
bluetooth = {
enable = true;
settings = {
General = {
# Battery API does not have a separate UUID.
Experimental = "*";
};
};
};
cpu.intel.updateMicrocode = true;
};
environment.systemPackages = with pkgs; [
abiword
alejandra
almanah
anki-bin
apg
bat
bind
binutils # readelf, xstrings
bpb
bustle
cachix
cawbird
chromium
common-updater-scripts
config.boot.kernelPackages.v4l2loopback
curlFull
(deadbeef-with-plugins.override {
plugins = with deadbeefPlugins; [
headerbar-gtk3
lyricbar
mpris2
];
})
deja-dup
dfeet
d-spy
droidcam
dos2unix
easyeffects
easytag
exa
exiftool
fd
file
firefox
font-manager
fractal
fzf
gcolor3
gdb
gimp
diff-so-fancy
git-crypt
gitFull
gitg
git-auto-fixup
git-auto-squash
git-part-pick
glade
gnome.cheese
gnome.dconf-editor
gnome.devhelp
gnome.geary
gnome.ghex
gnome.gnome-chess
gnome.gnome-dictionary
gnome.gnome-disk-utility
gnome.gnome-sound-recorder
gnome.gnome-tweaks
gnome.nautilus-python
gnome.pomodoro
gnomeExtensions.appindicator
gnomeExtensions.dash-to-dock
gnomeExtensions.hot-edge
gnomeExtensions.sound-output-device-chooser
gnomeExtensions.system-monitor
gnumeric
gnupg
gsmartcontrol
libadwaita # for demo
gtk3.dev # for gtk-builder-tool etc
graphviz
python3.pkgs.xdot
htop
icon-library
imagemagick
indent
inkscape
jq
libxml2 # for xmllint
lorri
ltrace
meld
mkpasswd
moreutils # isutf8
ncdu
nixpkgs-fmt
nix-bisect
nix-diff
nix-explore-closure-size
nix-index
nix-top
onboard
openLocalhostAsHttp
paprefs
pavucontrol
patchelf
patchutils # for filterdiff
playerctl
man-pages-posix
python3Full
ripgrep
sd
sequeler
signal-desktop
sman
sublime4-dev
sublime-merge
spotify
syncthing
tdesktop
tldr
transmission-gtk
treesheets
unrar
valgrind
vlc
wget
wirelesstools # for iwlist
xdot
xsel
xsv # handling CSV files
youtube-dl
zotero
];
services.udev.packages = with pkgs; [
# qmk-udev-rules
];
services.udev.extraRules = ''
# https://www.pjrc.com/teensy/00-teensy.rules
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789a]*", ENV{MTP_NO_PROBE}="1"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666", RUN:="${pkgs.coreutils}/bin/stty -F /dev/%k raw -echo"
KERNEL=="hidraw*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"
'';
environment.enableDebugInfo = true;
fonts.fontconfig.defaultFonts.emoji = [ "JoyPixels" ];
# List programs
programs = {
adb.enable = true;
fish = {
enable = true;
interactiveShellInit =
''
eval (${pkgs.direnv}/bin/direnv hook fish)
''
+ builtins.readFile ../../common/data/config.fish;
};
gnupg.agent.enable = true;
kdeconnect = {
enable = true;
package = pkgs.gnomeExtensions.gsconnect;
};
wireshark.enable = true;
};
documentation = {
dev.enable = true;
};
# List services that you want to enable:
services.flatpak.enable = true;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
services.acpid = {
enable = true;
handlers = {
mute = {
event = "button/fnf1";
action = ''
device=/sys/devices/platform/sony-laptop/touchpad
expr 1 - $(cat $device) > $device
'';
};
};
};
services.openssh = {
enable = true;
passwordAuthentication = false;
};
security.sudo.extraConfig = ''
Defaults pwfeedback
Defaults timestamp_timeout=25
'';
boot.plymouth.enable = true;
services.sysprof.enable = true;
services.fwupd.enable = true;
programs.gnome-terminal.enable = true;
programs.gpaste.enable = true;
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver.layout = "cz";
services.xserver.xkbVariant = "qwerty";
services.xserver.xkbOptions = "compose:caps";
# Enable the Desktop Environment.
services.xserver.displayManager.gdm = {
enable = true;
debug = true;
};
services.xserver.displayManager.defaultSession = "gnome-xorg";
services.xserver.desktopManager.gnome = {
enable = true;
};
i18n.inputMethod.enabled = "ibus";
i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ mozc ];
# Ugly hack for GPG choosing socket directory based on GNUPGHOME.
# If any other user wants to use gpg-agent they are out of luck,
# unless they modify the socket in their profile (e.g. using home-manager).
systemd.user.sockets.gpg-agent = {
listenStreams = let
user = "jtojnar";
socketDir = pkgs.runCommand "gnupg-socketdir" {
nativeBuildInputs = [ pkgs.python3 ];
} ''
python3 ${../../common/gnupgdir.py} '/home/${user}/.local/share/gnupg' > $out
'';
in [
"" # unset
"%t/gnupg/${builtins.readFile socketDir}/S.gpg-agent"
];
};
environment.etc = {
"gitconfig".text = ''
[user]
name = ${userData.jtojnar.name}
email = ${userData.jtojnar.email}
signingkey = ${userData.jtojnar.gpg}
[push]
default = current
followTags = true
[pull]
ff = only
[core]
eol = lf
autocrlf = false
pager = diff-so-fancy | less --tabs=4 -RFX
# allow using markdown headings in commit messages
commentChar = ";"
[commit]
gpgsign = true
[gpg]
program = bpb
# colour scheme for diff-so-fancy & co.
# https://github.com/so-fancy/diff-so-fancy#improved-colors-for-the-highlighted-bits
[color]
ui = true
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "diff"]
meta = 227
frag = magenta bold
commit = 227 bold
old = red bold
new = green bold
whitespace = red reverse
[sendemail]
smtpEncryption = tls
smtpServer = smtp.gmail.com
smtpUser = ${userData.jtojnar.email}
smtpServerPort = 587
[credential]
helper = libsecret
'';
};
users.extraUsers = {
root = {
hashedPassword = "*";
};
jtojnar = {
isNormalUser = true;
uid = 1000;
extraGroups = [
"wheel"
"dialout" # for serial
"networkmanager"
"wireshark"
"docker"
"kvm"
"vboxusers"
];
useDefaultShell = true;
openssh.authorizedKeys.keys = keys.jtojnar ++ keys.jtojnar-redmi;
# generated with `diceware -w en_eff` and hashed using `mkpasswd --method=sha-512 --rounds=1000000`
# https://logs.nix.samueldr.com/nixos/2020-04-09#1586472710-1586474674;
hashedPassword = "$6$rounds=1000000$B4206OAvwCfr$5yakyriBawsKHHYsziytYmpzgR0zjPaBgWAJEE6ir0KT0if4yX7NCan4codw48eyORNy3YFCAlVaww0mHfZg0/";
};
};
home-manager.users.jtojnar = { lib, ... }: {
imports = [
../../common/configs/keepassxc
];
dconf.settings = {
"org/gnome/desktop/background" = {
primary-color = "#000000";
secondary-color = "#000000";
picture-uri = "file://${pkgs.reflection_by_yuumei}";
picture-uri-dark = "file://${pkgs.reflection_by_yuumei}";
};
"org/gnome/desktop/screensaver" = {
lock-delay = lib.hm.gvariant.mkUint32 3600;
lock-enabled = true;
picture-uri = "file://${pkgs.undersea_city_by_mrainbowwj}";
primary-color = "#000000";
secondary-color = "#000000";
};
"org/gnome/desktop/peripherals/touchpad" = {
click-method = "default";
};
"org/gnome/desktop/session" = {
idle-delay = lib.hm.gvariant.mkUint32 900;
};
"org/gnome/desktop/wm/keybindings" = {
switch-input-source = [ "<Super>i" ];
switch-input-source-backward = [ "<Shift><Super>i" ];
};
"org/gnome/settings-daemon/plugins/media-keys" = {
previous = ["<Super>b"];
custom-keybindings = ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"];
next = ["<Super>n"];
home = ["<Super>e"];
play = ["<Super>space"];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = {
binding = "<Super>t";
command = "gnome-terminal";
name = "Open terminal";
};
"org/gnome/settings-daemon/plugins/power" = {
power-button-action = "nothing";
idle-dim = true;
sleep-inactive-battery-type = "nothing";
sleep-inactive-ac-timeout = 3600;
sleep-inactive-ac-type = "nothing";
sleep-inactive-battery-timeout = 1800;
};
"org/gnome/shell" = {
"enabled-extensions" = [
"appindicatorsupport@rgcjonas.gmail.com"
"dash-to-dock@micxgx.gmail.com"
"GPaste@gnome-shell-extensions.gnome.org"
"pomodoro@arun.codito.in"
];
};
"org/gtk/settings/file-chooser" = {
sort-directories-first = true;
location-mode = "path-bar";
};
"org/gnome/desktop/input-sources" = {
sources = [
(lib.hm.gvariant.mkTuple [
"xkb"
"${config.services.xserver.layout}${lib.optionalString (config.services.xserver.xkbVariant != "") "+" + config.services.xserver.xkbVariant}"
])
(lib.hm.gvariant.mkTuple [
"ibus"
"mozc-jp"
])
];
xkb-options = [
config.services.xserver.xkbOptions
];
};
};
home.file.".config/npm/npmrc".text = ''
prefix=''${XDG_DATA_HOME}/npm
cache=''${XDG_CACHE_HOME}/npm
'';
home.file.".config/mozc/ibus_config.textproto".text = ''
# `ibus write-cache; ibus restart` might be necessary to apply changes.
engines {
name : "mozc-jp"
longname : "Mozc"
layout : "default"
layout_variant : ""
layout_option : ""
rank : 80
}
# Ensure hiragana input mode is default.
active_on_launch: True
'';
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.gh = {
enable = true;
settings = {
git_protocol = "ssh";
editor = "subl -w";
aliases = {
"co" = "pr checkout";
};
};
};
programs.nix-index.enable = true;
home.stateVersion = "18.09";
};
# For agenix.
age.identityPaths = [
"/etc/ssh/ssh_host_ed25519_key"
];
users.defaultUserShell = pkgs.fish;
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "21.05";
nix = {
distributedBuilds = true;
buildMachines = [
{
hostName = "aarch64.nixos.community";
maxJobs = 64;
sshKey = "/root/id_aarch64box";
sshUser = "jtojnar";
system = "aarch64-linux";
supportedFeatures = [ "big-parallel" ];
}
];
# nix options for derivations to persist garbage collection
settings = {
keep-outputs = true;
keep-derivations = true;
};
};
}