-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.nix
414 lines (362 loc) · 12.4 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
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
nix = {
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
nixpkgs.config.allowUnfree = true;
nixpkgs.overlays = [(final: prev: {
gnome = prev.gnome // {gnome-keyring = final.stdenv.mkDerivation {
name = "modified-gnome-keyring";
src = prev.gnome.gnome-keyring;
nativeBuildInputs = [ final.rsync ];
installPhase = ''
mkdir $out
rsync -a $src/. $out --exclude gnome-keyring-ssh.desktop
'';
};};
#gnupg-patched = prev.gnupg.overrideAttrs (finalAttrs: prevAttrs: {
# patches = prevAttrs.patches ++ [ ./gnupg.patch ];
#});
strongswan = prev.strongswan.overrideAttrs (finalAttrs: prevAttrs: {
configureFlags = prevAttrs.configureFlags ++ [ "--enable-agent" "--enable-eap-tls" ];
patches = prevAttrs.patches ++ [ ./strongswan.patch ];
postInstall = prevAttrs.postInstall + ''
cat <<EOF > $out/etc/strongswan.d/charon/pkcs11.conf
pkcs11 {
load = yes
modules {
ykcs11 {
# load_certs = yes
# os_locking = no
path = ${final.yubico-piv-tool}/lib/libykcs11.so
}
}
}
EOF
cat <<EOF >> $out/etc/strongswan.d/charon-systemd.conf
charon-systemd {
journal {
default = 2
}
}
EOF
cat <<EOF >> $out/etc/strongswan.conf
charon-nm {
load_modular = yes
plugins {
include strongswan.d/charon/*.conf
}
}
EOF
'';
});
})];
boot.initrd = {
systemd.enable = true;
luks.devices = {
nixos = {
device = "/dev/disk/by-partuuid/19497523-4a8d-495c-b5de-976da50e31bb";
allowDiscards = true;
preLVM = true;
};
};
};
boot.resumeDevice = "/dev/disk/by-uuid/8fa8cb1d-cf56-4207-8315-5e0346d4682f";
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
security.tpm2.enable = true;
security.tpm2.pkcs11.enable = true;
security.tpm2.tctiEnvironment.enable = true;
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
boot.binfmt.registrations.appimage = {
wrapInterpreterInShell = false;
interpreter = "${pkgs.appimage-run}/bin/appimage-run";
recognitionType = "magic";
offset = 0;
mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff'';
magicOrExtension = ''\x7fELF....AI\x02'';
};
networking.hostName = "laptop";
networking.networkmanager = {
enable = true;
enableStrongSwan = true;
};
networking.extraHosts = ''
10.16.3.1 gitlab.home.josephmartin.org
10.16.3.1 registry.home.josephmartin.org
10.16.3.2 ldap.home.josephmartin.org
'';
services.automatic-timezoned.enable = true;
services.hardware.bolt.enable = true;
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
settings.PermitRootLogin = "no";
};
services.pcscd.enable = true;
# networking.hostName = "nixos"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
# time.timeZone = "Europe/Amsterdam";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
# };
systemd.sleep.extraConfig = ''
AllowSuspendThenHibernate=yes
HibernateDelaySec=3600
'';
systemd.tmpfiles.rules = [ "d /run/tpm2-tss/eventlog 0775 root tss -" ];
services.logind = {
suspendKey = "suspend-then-hibernate";
lidSwitch = "suspend-then-hibernate";
lidSwitchExternalPower = "suspend-then-hibernate";
lidSwitchDocked = "ignore";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the Plasma 5 Desktop Environment.
services.xserver.displayManager.sddm.enable = false;
services.xserver.desktopManager.plasma5.enable = false;
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.desktopManager.xterm.enable = false;
services.xserver.excludePackages = [ pkgs.xterm ];
# Configure keymap in X11
# services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
services.flatpak.enable = true;
services.fprintd.enable = true;
services.fprintd.tod.enable = true;
services.fprintd.tod.driver = pkgs.libfprint-2-tod1-goodix-550a;
xdg.portal = {
enable = true;
#extraPortals = [ pkgs.xdg-desktop-portal-kde pkgs.xdg-desktop-portal-gtk ];
};
users.users.joseph = {
isNormalUser = true;
description = "Joseph Martin";
extraGroups = [ "networkmanager" "wheel" "tss" "docker" ];
};
environment.systemPackages = with pkgs; [
neovim
libva-utils
tpm2-tss
tpm2-tools
acl
usbutils
plasma5Packages.plasma-thunderbolt
libsForQt5.qtstyleplugin-kvantum
gnomeExtensions.windownavigator
gnomeExtensions.gsconnect
#gnomeExtensions.hibernate-status-button
gnome.gnome-tweaks
yubico-piv-tool
opensc
yubikey-manager
#openssl_3_1
strongswan
openssl
(pkgs.stdenv.mkDerivation {
pname = "pkcs11-provider";
version = "0.2";
nativeBuildInputs = [ pkgs.autoconf-archive pkgs.pkg-config autoreconfHook ];
#buildInputs = [ pkgs.openssl_3_1 ];
buildInputs = [ pkgs.openssl ];
src = pkgs.fetchFromGitHub {
owner = "latchset";
repo = "pkcs11-provider";
rev = "v0.2";
sha256 = "sha256-PI4cmk/bojmn/3XaEQhU9FSzHawUYp4cmyXsjR0RG/o=";
};
})
];
#environment.variables = {
# TSS2_FAPICONF = "/etc/tpm2-tss/fapi-config.json";
# SSH_AUTH_SOCK = "/run/user/1000/gnupg/S.gpg-agent.ssh";
#};
environment.sessionVariables = {
SSH_AUTH_SOCK = "/run/user/$UID/gnupg/S.gpg-agent.ssh";
};
environment.etc = {
"bash_completion.d/kubectl.bash" = {
source = "${lib.makeSearchPath "share" [ pkgs.kubectl ] }/bash-completion/completions.kubectl.bash";
};
"tpm2-tss/fapi-config.json".text = ''
{
"ek_cert_less": "yes",
"profile_name": "P_ECCP256SHA256",
"profile_dir": "/etc/tpm2-tss/fapi-profiles/",
"user_dir": "~/.local/share/tpm2-tss/user/keystore",
"system_dir": "/var/lib/tpm2-tss/system/keystore",
"tcti": "${lib.makeLibraryPath [pkgs.tpm2-tss ]}/libtss2-tcti-device.so:/dev/tpmrm0",
"system_pcrs": [],
"log_dir": "/var/run/tpm2-tss/eventlog"
}
'';
"tpm2-tss/fapi-profiles/P_ECCP256SHA256.json" = {
mode = "444";
text = ''
{
"type": "TPM2_ALG_ECC",
"nameAlg": "TPM2_ALG_SHA256",
"srk_template": "system,restricted,decrypt,0x81000001",
"srk_description": "Storage root key SRK",
"srk_persistent": 0,
"ek_template": "system,restricted,decrypt",
"ek_description": "Endorsement key EK",
"ecc_signing_scheme": {
"scheme": "TPM2_ALG_ECDSA",
"details": {
"hashAlg": "TPM2_ALG_SHA256"
}
},
"sym_mode": "TPM2_ALG_CFB",
"sym_parameters": {
"algorithm": "TPM2_ALG_AES",
"keyBits": "128",
"mode": "TPM2_ALG_CFB"
},
"sym_block_size": 16,
"pcr_selection": [
{
"hash": "TPM2_ALG_SHA1",
"pcrSelect": []
},
{
"hash": "TPM2_ALG_SHA256",
"pcrSelect": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ]
}
],
"curveID": "TPM2_ECC_NIST_P256",
"ek_policy": {
"description": "Endorsement hierarchy used for policy secret.",
"policy": [
{
"type": "POLICYSECRET",
"objectName": "4000000b"
}
]
}
}
'';
};
};
system.activationScripts.fapiDirs = lib.stringAfter [ "var" ] ''
PATH=$PATH:${lib.makeBinPath [ pkgs.acl ]}
mkdir -p /var/lib/tpm2-tss
setfacl -R -m g:tss:rwx /var/lib/tpm2-tss
'';
virtualisation.podman.enable = true;
virtualisation.docker = {
enable = true;
daemon.settings.features."containerd-snapshotter" = true;
};
virtualisation.libvirtd.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
# users.users.alice = {
# isNormalUser = true;
# extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
# packages = with pkgs; [
# firefox
# tree
# ];
# };
# List packages installed in system profile. To search, run:
# $ nix search wget
# environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
# ];
# 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";
# };
#};
#programs.gnupg.package = pkgs.gnupg-patched;
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.firewall = {
enable = false;
#allowedTCPPortRanges = [
# { from = 1714; to = 1764; } # KDE Connect
#];
#allowedUDPPortRanges = [
# { from = 1714; to = 1764; } # KDE Connect
#];
};
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "23.11"; # Did you read the comment?
}