-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.nix
382 lines (320 loc) · 10.5 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
args@{ ... }:
let
config-k = "config";
inherit (import ./constants.nix)
wenzelUserName xkb keyRepeat
rawdevinputGroupName backlightcontrolGroupName jackaudioGroupName audioGroupName;
in
# WARNING! Never assert "config" argument, nowhere in the modules too, it's recursive self-reference.
# It refers to the configuration itself, to this module we're just about to construct.
# Otherwise it will fail with infinite recursion error.
# assert let k = config-k; in builtins.hasAttr k args -> builtins.isAttrs args.${k};
let
withConfigArgs =
let k = config-k; in if builtins.hasAttr k args then { ${k} = args.${k}; } else {};
pkgs = import ./pkgs.nix withConfigArgs;
utils = (import ./picks/nix-utils.nix (withConfigArgs // { inherit pkgs; })).pkg;
inherit (utils) esc;
moduleArgs = withConfigArgs // { inherit pkgs utils; };
home-manager = import ./picks/home-manager.nix;
wenzels-i3 = import apps/wenzels-i3.nix moduleArgs;
grant-access-to-input-devices = (import utils/grant-access-to-input-devices moduleArgs).pkg;
laptop-backlight = (import utils/laptop-backlight moduleArgs).pkg;
my-packages = import ./my-packages.nix moduleArgs;
inherit (my-packages.my-apps) wenzels-bash;
in
{
imports = [
(import "${home-manager}/nixos")
my-packages.configuration
./machine-specific.nix
];
system = {
stateVersion = "20.03";
fsPackages = [pkgs.xfsprogs.bin];
};
boot = {
loader = {
systemd-boot.enable = true;
grub = {
enable = true;
version = 2;
device = "nodev";
efiSupport = true;
enableCryptodisk = true;
};
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
initrd = {
availableKernelModules = [
"xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"
"xfs" "crc32c"
"nvme"
];
# kernelModules = [];
};
# kernelModules = [];
# extraModulePackages = [];
};
networking = {
networkmanager.enable = true;
# wireless.enable = true; # incompatible with networkmanager
useDHCP = false; # just legacy flag
# let network manager do the work.
# if you turn both this and network manager on the network
# will constantly go up and down in an infinite loop.
# interfaces.enp3s0.useDHCP = false;
# proxy = {
# default = "http://user:password@proxy:port/";
# noProxy = "127.0.0.1,localhost,internal.domain";
# };
firewall = {
enable = true;
allowedTCPPorts = [
# 80 443
];
allowedTCPPortRanges = [
# { from = 8000; to = 8010; }
];
};
};
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
time.timeZone = "Europe/Helsinki";
# shellInit = ''
# export FOO=bar
# '';
environment = {
variables = {
EDITOR = "nvim";
TERMINAL = "termite";
# XCompose and XIM setup
XMODIFIERS = "@im=none";
QT_IM_MODULE = "xim";
GTK_IM_MODULE = "xim";
GTK_THEME = "Adwaita:dark";
};
etc = {
"xdg/gtk-2.0/gtkrc".text = ''
gtk-theme-name = "Adwaita-dark"
gtk-icon-theme-name = "Adwaita"
'';
"xdg/gtk-3.0/settings.ini".text = ''
[Settings]
gtk-theme-name = Adwaita-dark
gtk-application-prefer-dark-theme = true
gtk-icon-theme-name = Adwaita
'';
};
};
qt5 = {
enable = true;
platformTheme = "gnome";
style = "adwaita-dark";
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
programs = {
gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryFlavor = "gnome3";
};
ssh.knownHosts = {
"wenzel-nixos-pc.local" = {
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOmL8yMVM5zEkU3v3BEBdGRKeTUE23SLM0cQpmZ7KsWy";
};
"rw-wenzel-nixos-laptop.local" = {
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINuEudWImNcFDrEfvfUipPBBcpVHj0YsWiqh0qLURPIo";
};
};
seahorse.enable = true;
dconf.enable = true;
gpaste.enable = true;
bash.enableCompletion = true;
zsh.enable = true;
zsh.enableCompletion = true;
tmux.enable = true;
# TODO configure, see https://framagit.org/mpo/era-configuration-nix
# chromium = {};
};
sound.enable = true;
hardware = {
pulseaudio = {
enable = true;
support32Bit = true;
package = pkgs.pulseaudio.override { jackaudioSupport = true; };
};
opengl = rec {
enable = true;
driSupport = true;
driSupport32Bit = true;
# s3tcSupport = true; # in nixos-unstable it’s no longer needed
extraPackages = [
pkgs.mesa
pkgs.vaapiVdpau
pkgs.vaapiIntel
pkgs.libvdpau-va-gl
];
extraPackages32 = extraPackages;
};
};
services = {
openssh = {
enable = true;
permitRootLogin = "no";
passwordAuthentication = false;
startWhenNeeded = false;
forwardX11 = true;
};
# discover local machines
avahi = {
enable = true;
ipv4 = true;
ipv6 = true;
nssmdns = true;
publish = {
enable = true;
userServices = true;
domain = true;
};
};
udev = {
extraRules = ''
# Teensy rules for the Ergodox EZ Original / Shine / Glow
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"
# STM32 rules for the Planck EZ Standard / Glow
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", \
MODE:="0666", \
SYMLINK+="stm32_dfu"
'';
};
printing.enable = false; # CUPS to print documents (have no printer yet)
# X11
xserver = {
enable = true;
layout = xkb.layout;
xkbOptions = xkb.options;
desktopManager = {
# default = "none";
xterm.enable = false;
};
displayManager = {
defaultSession = "none+i3";
lightdm.enable = true;
sessionCommands = ''
${esc pkgs.xorg.xset}/bin/xset r rate ${esc keyRepeat.delay} ${esc keyRepeat.interval}
'';
};
windowManager.i3 = {
enable = true;
configFile = wenzels-i3.configFile {
inherit (my-packages.my-apps)
autostart-setup input-setup
cursor-to-display gpaste-gui pamng screen-backlight;
};
};
libinput.enable = true; # touchpad
};
gnome3.gnome-keyring.enable = true;
upower.enable = true;
fwupd.enable = true;
# see also https://nixos.wiki/wiki/JACK
# jack = {
# jackd.enable = true;
# # alsa.enable = true; # support ALSA-only programs via ALSA JACK PCM plugin
# # loopback.enable = true; # support ALSA-only programms via loopback device (e.g. Steam)
# };
};
virtualisation = {
docker.enable = true;
virtualbox.host.enable = true;
};
fonts = {
enableFontDir = true;
fonts = [
pkgs.hack-font
pkgs.fira-code-symbols
pkgs.iosevka
pkgs.nerdfonts
pkgs.terminus_font # for "place-cursor-at"
];
fontconfig = {
defaultFonts = let font = ["Hack"]; in { monospace = font; sansSerif = font; serif = font; };
subpixel.rgba = "none";
};
};
users = {
users."${wenzelUserName}" = {
uid = 1989;
isNormalUser = true;
group = wenzelUserName;
shell = wenzels-bash;
extraGroups = [
"users"
"wheel"
"networkmanager"
rawdevinputGroupName
backlightcontrolGroupName
"docker"
"vboxusers"
jackaudioGroupName
audioGroupName
];
openssh.authorizedKeys.keys = [
# wenzel-nixos-pc
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDL2A7YiBrYwyxx9HTa8YVGeS8et1ae1K7VuwYtqL+pV41GeQdpug7crGbM9U2NQ4zXBxpcV0Wu/Fxa4KcecBuw2PTv8bJO6+38U39iOWtJ6ArxC0dkAPTssVpWw1Bvc61WUvLsP8PtgauZjO18HAOJD62yPmqOgf/IIY9TCAv2QuQD+nSaPVn3TSVUDhBCFM/ZC7I/D0pdgWTkSUKEoNgXF47sVYs14BN8ey87UQd9OK02gbcGUMXaLXGQfa5BezHHiwpyVCnkujpaKkiNOvcmb5bVyhT8bnds2zmEOu6wmFEyiK0Cozb6b7vpnjtKV+U4M+IJzSkV9RjeoJaEN79e0SC1YHusKE5EZlcgvVt5+sR9G1mXlXaqL/g3rMuDy4gECDa0PGSFj6tiYqlk22Pdcx8dzK1yMzroeCD0++umChyRm6xM8sb7vRm+j3ZnRdeSq77VX66q0oJaVeCCXF4BGf+RJgf0SApKfg9Xts0EekZylYyerXw1i4R8eV9WIr4oA7vCTg/QuAa7U0lezDBNjf+cb9eZu4kgyi/Cft06T17DS3t7Nqe2cgsGqfJpnSPTTV6HduLmQAhfcDGbJ5QuzMswUbgCh4ZbMDinBPXRwoCyfQa+L21gcFYd9QkTt6KEuciAd9L8AzyzhhJCid85Ku7DNcRCz7epFwYdkKT+Iw== (none)"
# rw-wenzel-nixos-laptop
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/7GGxP+9Y0oiCPFuFWVgYfQV26K4yLbVOWXaVjhl8ydZykgGZ1BHt/IHeq7FpJimwFbCj1JiFi/iAW4oY5yQs5YKR/rJ5zlyUeOfVFZHV1mONN8hyDOyftO/KGGWWPdEB6bLlMyeP2bNjrSulvljp/zHix1be00dfoKA+D9i0haYQX4kJT1H3j9Ouf4Ea5kQmxLlksQIwEOTIsyi/UWU2U9NmBBi88oQwluIAZjOPUeijq3jnGti0yWPHnXqoD0ssfcBt+z8kdB1eYqUYxn80dDgid0Pllp6EWBBZr1mhzUkkKeVWGt0cHnItt9YxiDqHVpD0RzXbLDWTgDNwHjJX (none)"
];
};
groups = {
${wenzelUserName}.gid = 1989;
${rawdevinputGroupName}.gid = 500;
${backlightcontrolGroupName}.gid = 501;
};
};
security = {
wrappers =
let
rootSuidGroup = source: group: {
${source.name} = {
source = source;
permissions = "u+xs,g+x";
owner = "root";
group = group;
};
};
in
rootSuidGroup grant-access-to-input-devices rawdevinputGroupName //
rootSuidGroup laptop-backlight backlightcontrolGroupName;
pam.loginLimits = [
{ domain = "@${audioGroupName}"; item = "memlock"; type = "-"; value = "unlimited"; }
{ domain = "@${audioGroupName}"; item = "rtprio"; type = "-"; value = "99"; }
{ domain = "@${audioGroupName}"; item = "nofile"; type = "soft"; value = "99999"; }
{ domain = "@${audioGroupName}"; item = "nofile"; type = "hard"; value = "99999"; }
];
};
home-manager.users.${wenzelUserName} = {
programs.git = {
enable = true;
userName = "Viacheslav Lotsmanov";
userEmail = "[email protected]";
};
home.file.".bashrc".text = ''
. ${esc wenzels-bash.history-settings-file-path}
'';
};
}