aboutsummaryrefslogtreecommitdiff
path: root/hosts/enode/disko.nix
blob: b09de01c715a3b5e4fd91c47757382f1969d57f3 (plain)
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
let
  rootPartition = {
    type = "btrfs";
    extraArgs = [ "-f" ]; # override existing partition
    subvolumes = {
      "/root" = {
        mountpoint = "/";
        mountOptions = [
          "subvol=root"
          "compress=zstd"
          "noatime"
        ];
      };
      "/home" = {
        mountOptions = [
          "subvol=home"
          "compress=zstd"
          "noatime"
        ];
        mountpoint = "/home";
      };
      "/nix" = {
        mountOptions = [
          "subvol=nix"
          "compress=zstd"
          "noatime"
        ];
        mountpoint = "/nix";
      };
      "/log" = {
        mountpoint = "/var/log";
        mountOptions = [
          "subvol=log"
          "compress=zstd"
          "noatime"
        ];
      };
      "/persist" = {
        mountpoint = "/var/lib/persist";
        mountOptions = [
          "subvol=persist"
          "compress=zstd"
          "noatime"
        ];
      };
      "/secrets" = {
        mountpoint = "/var/lib/secrets";
        mountOptions = [
          "subvol=secrets"
          "compress=zstd"
          "noatime"
        ];
      };
    };
  };
in
{
  disko.devices.disk.vm-disk = {
    type = "disk";
    device = "/dev/vda";
    imageSize = "10G";
    content = {
      type = "gpt";
      partitions = {
        ESP = {
          priority = 1;
          name = "ESP";
          label = "boot";
          size = "1G";
          type = "EF00";
          content = {
            type = "filesystem";
            format = "vfat";
            mountpoint = "/boot";
            mountOptions = [
              "umask=0077"
            ];
          };
        };
        swap = {
          priority = 2;
          name = "swap";
          label = "swap";
          size = "4G";
          content = {
            type = "swap";
            discardPolicy = "both";
            postCreateHook = ''
              swapon "$device"
            '';
          };
        };
        root = {
          priority = 3;
          size = "100%";
          name = "root";
          label = "root";
          content = rootPartition;
        };
      };
    };
  };

  fileSystems."/var/lib/persist".neededForBoot = true;
  fileSystems."/var/log".neededForBoot = true;
}