-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmachine.nix
157 lines (128 loc) · 4.07 KB
/
machine.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
{ self, aquaris, lib, config, pkgs, ... }:
let
inherit (lib) mkDefault mkOption pipe;
inherit (lib.types) bool int nullOr str;
inherit (aquaris.inputs) nixpkgs;
cfg = config.aquaris.machine;
# pin exactly this version since it's cached in nix-community.cachix.org
lanza042 = builtins.getFlake "github:nix-community/lanzaboote/a65905a09e2c43ff63be8c0e86a93712361f871e";
inherit (config.aquaris.persist) root;
in
{
options.aquaris.machine = {
id = mkOption {
description = "The machine ID (used by systemd and others)";
type = str;
};
secureboot = mkOption {
description = "Whether to enable Secure Boot support using lanzaboote";
type = bool;
default = true;
};
keepGenerations = mkOption {
description = "How many generations to keep (null to disable autocleanup)";
type = nullOr int;
default = 5;
};
};
imports = [ "${lanza042}/nix/modules/lanzaboote.nix" ];
config = {
boot = {
initrd.systemd.enable = mkDefault true;
kernelParams = [
"vt.default_red=0x28,0xcc,0x98,0xd7,0x45,0xb1,0x68,0xa8,0x92,0xfb,0xb8,0xfa,0x83,0xd3,0x8e,0xeb"
"vt.default_grn=0x28,0x24,0x97,0x99,0x85,0x62,0x9d,0x99,0x83,0x49,0xbb,0xbd,0xa5,0x86,0xc0,0xdb"
"vt.default_blu=0x28,0x1d,0x1a,0x21,0x88,0x86,0x6a,0x84,0x74,0x34,0x26,0x2f,0x98,0x9b,0x7c,0xb2"
];
lanzaboote = {
enable = mkDefault cfg.secureboot;
pkiBundle = pipe pkgs.sbctl.ldflags [
(builtins.concatStringsSep " ")
(builtins.match ".*DatabasePath=([^ ]+).*")
builtins.head
];
package = pkgs.writeShellApplication {
name = "lzbt";
runtimeInputs = with pkgs; [
lanza042.packages.${pkgs.system}.lzbt
sbctl
];
text = let pki = config.boot.lanzaboote.pkiBundle; in ''
if [ ! -f "${pki}/GUID" ]; then
sbctl create-keys
fi
exec lzbt "$@"
'';
};
};
loader = {
efi.canTouchEfiVariables = mkDefault true;
timeout = mkDefault 0;
systemd-boot = {
enable = mkDefault (! cfg.secureboot);
editor = mkDefault false;
};
};
tmp.useTmpfs = mkDefault true;
};
environment.etc = {
"machine-id".text = cfg.id;
"nix/channel".source = nixpkgs.outPath;
"nixos".source = self.outPath;
};
networking = {
hostId = builtins.substring 0 8 cfg.id; # for ZFS
hostName = aquaris.name;
useNetworkd = mkDefault true;
networkmanager = {
enable = mkDefault true;
plugins = lib.mkOverride 99 [ ];
};
};
nix = {
package = mkDefault self.inputs.obscura.packages.${pkgs.system}.lix-fix-help;
settings = {
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
keep-going = true;
use-xdg-base-directories = true;
};
nixPath = [ "nixpkgs=/etc/nix/channel" ];
registry = {
config.flake = self;
nixpkgs.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
inherit (nixpkgs) rev;
};
};
};
services = {
journald.extraConfig = mkDefault "SystemMaxUse=100M";
openssh = {
enable = mkDefault true;
settings = {
PasswordAuthentication = false;
PermitRootLogin = "no";
};
hostKeys = [{
path = "${root}/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}];
};
};
system = {
configurationRevision = mkDefault (self.rev or self.dirtyRev or null);
etc.overlay.enable = mkDefault true;
stateVersion = mkDefault "24.05";
};
# misc
console.keyMap = mkDefault "de-latin1";
i18n.extraLocaleSettings.LC_COLLATE = mkDefault "C.UTF-8";
i18n.extraLocaleSettings.LC_TIME = mkDefault "de_DE.UTF-8";
systemd.extraConfig = mkDefault "DefaultTimeoutStopSec=5s";
time.timeZone = mkDefault "Europe/Berlin";
zramSwap.enable = mkDefault true;
};
}