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.nix83
1 files changed, 83 insertions, 0 deletions
diff --git a/hosts/skadhi/fs.nix b/hosts/skadhi/fs.nix
new file mode 100644
index 00000000..73191aa9
--- /dev/null
+++ b/hosts/skadhi/fs.nix
@@ -0,0 +1,83 @@
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 config.boot.lanzaboote.pkiBundle
19 ];
20 };
21
22 disko.devices = {
23 disk.nvm = {
24 type = "disk";
25 device = "/dev/nvme0n1";
26 content = {
27 type = "gpt";
28 partitions = {
29 ESP = {
30 size = "512M";
31 type = "EF00";
32 content = {
33 type = "filesystem";
34 format = "vfat";
35 mountpoint = "/boot";
36 mountOptions = [
37 "fmask=0033" "dmask=0022"
38 ];
39 };
40 };
41 luks = {
42 size = "100%";
43 content = {
44 type = "luks";
45 name = "nvm";
46 extraFormatArgs = [
47 "--cipher" "aegis128-random"
48 "--key-size" "128"
49 "--integrity" "aead"
50 ];
51 content = {
52 type = "btrfs";
53 extraArgs = let
54 dirs = map (p: "/persistent/${p}") ["/etc"];
55 subvols = ["/persistent"] ++ map (p: "/persistent/${p}") ["/nix" "/var/log"];
56 restricted = map (p: "/persistent/${p}") ["/root"];
57 in [
58 "--csum" "blake2"
59 "--compress" "zstd:15"
60 "--rootdir" (toString (pkgs.runCommand "rootdir" {
61 } ''
62 mkdir $out
63 install -d ${lib.concatMapStringsSep " " (p: "$out/${p}") (dirs ++ subvols)}
64 install -m 0700 -d ${lib.concatMapStringsSep " " (p: "$out/${p}") restricted}
65 ln -s /etc/zoneinfo/UTC /persistent/etc/localtime
66 ''))
67 ] ++ lib.concatMap (p: ["--subvol" p]) (subvols ++ restricted);
68 subvolumes = {
69 "/persistent".mountpoint = "/persistent";
70 "/swap" = {
71 mountpoint = "/.swap";
72 swap.swapfile.size = "96G";
73 };
74 };
75 };
76 };
77 };
78 };
79 };
80 };
81 };
82 };
83}