summaryrefslogtreecommitdiffstats
path: root/example/zfs.nix
blob: 59c3f24acfc7d2833c16b22b4430ee4fe4c89a8c (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
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
  disk = {
    x = {
      type = "disk";
      device = builtins.elemAt disks 0;
      content = {
        type = "table";
        format = "gpt";
        partitions = [
          {
            type = "partition";
            name = "ESP";
            start = "0";
            end = "64MiB";
            fs-type = "fat32";
            bootable = true;
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
            };
          }
          {
            type = "partition";
            name = "zfs";
            start = "128MiB";
            end = "100%";
            content = {
              type = "zfs";
              pool = "zroot";
            };
          }
        ];
      };
    };
    y = {
      type = "disk";
      device = builtins.elemAt disks 1;
      content = {
        type = "table";
        format = "gpt";
        partitions = [
          {
            type = "partition";
            name = "zfs";
            start = "128MiB";
            end = "100%";
            content = {
              type = "zfs";
              pool = "zroot";
            };
          }
        ];
      };
    };
  };
  zpool = {
    zroot = {
      type = "zpool";
      mode = "mirror";
      rootFsOptions = {
        compression = "lz4";
        "com.sun:auto-snapshot" = "false";
      };
      mountpoint = "/";

      datasets = {
        zfs_fs = {
          zfs_type = "filesystem";
          mountpoint = "/zfs_fs";
          options."com.sun:auto-snapshot" = "true";
        };
        zfs_unmounted_fs = {
          zfs_type = "filesystem";
          options.mountpoint = "none";
        };
        zfs_legacy_fs = {
          zfs_type = "filesystem";
          options.mountpoint = "legacy";
          mountpoint = "/zfs_legacy_fs";
        };
        zfs_testvolume = {
          zfs_type = "volume";
          size = "10M";
          content = {
            type = "filesystem";
            format = "ext4";
            mountpoint = "/ext4onzfs";
          };
        };
      };
    };
  };
}