summaryrefslogtreecommitdiff
path: root/hosts/skadhi/fs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/skadhi/fs.nix')
-rw-r--r--hosts/skadhi/fs.nix86
1 files changed, 86 insertions, 0 deletions
diff --git a/hosts/skadhi/fs.nix b/hosts/skadhi/fs.nix
new file mode 100644
index 00000000..41ef24f6
--- /dev/null
+++ b/hosts/skadhi/fs.nix
@@ -0,0 +1,86 @@
1{ flake, flakeInputs, pkgs, config, lib, ... }:
2{
3 imports = with flake.nixosModules.systemProfiles; [
4 disko
5 ];
6
7 config = {
8 fileSystems."/persistent".neededForBoot = true;
9 environment.persistence."/persistent" = {
10 hideMounts = true;
11 directories = [
12 "/nix"
13 "/root"
14 "/var/log"
15 "/var/lib/nixos"
16 "/var/lib/sops-nix"
17 "/var/lib/systemd"
18 "/var/lib/fprint"
19 "/var/lib/chrony"
20 "/var/lib/postfix"
21 config.boot.lanzaboote.pkiBundle
22 ];
23 };
24
25 disko.devices = {
26 disk.nvm = {
27 type = "disk";
28 device = "/dev/nvme0n1";
29 content = {
30 type = "gpt";
31 partitions = {
32 ESP = {
33 size = "512M";
34 type = "EF00";
35 content = {
36 type = "filesystem";
37 format = "vfat";
38 mountpoint = "/boot";
39 mountOptions = [
40 "fmask=0033" "dmask=0022"
41 ];
42 };
43 };
44 luks = {
45 size = "100%";
46 content = {
47 type = "luks";
48 name = "nvm";
49 extraFormatArgs = [
50 "--cipher" "aegis128-random"
51 "--key-size" "128"
52 "--integrity" "aead"
53 ];
54 content = {
55 type = "btrfs";
56 extraArgs = let
57 dirs = map (p: "/persistent/${p}") ["/etc"];
58 subvols = ["/persistent"] ++ map (p: "/persistent/${p}") ["/nix" "/var/log"];
59 restricted = map (p: "/persistent/${p}") ["/root"];
60 in [
61 "--csum" "blake2"
62 "--compress" "zstd:15"
63 "--rootdir" (toString (pkgs.runCommand "rootdir" {
64 } ''
65 mkdir $out
66 install -d ${lib.concatMapStringsSep " " (p: "$out/${p}") (dirs ++ subvols)}
67 install -m 0700 -d ${lib.concatMapStringsSep " " (p: "$out/${p}") restricted}
68 ln -s /etc/zoneinfo/UTC /persistent/etc/localtime
69 ''))
70 ] ++ lib.concatMap (p: ["--subvol" p]) (subvols ++ restricted);
71 subvolumes = {
72 "/persistent".mountpoint = "/persistent";
73 "/swap" = {
74 mountpoint = "/.swap";
75 swap.swapfile.size = "96G";
76 };
77 };
78 };
79 };
80 };
81 };
82 };
83 };
84 };
85 };
86}