Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions lib/types/zpool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
...
}:
let
# TODO: Consider expanding to handle `file` and `draid` mode options.
# TODO: Consider expanding to handle `file` mode option.
modeOptions = [
""
"mirror"
Expand All @@ -16,6 +16,12 @@ let
"raidz2"
"raidz3"
];
zpoolModeType = lib.types.mkOptionType {
name = "zpoolMode";
description = "valid modes for a zpool";
descriptionClass = "noun";
check = (x: lib.isString x && (builtins.elem x modeOptions || lib.strings.hasPrefix "draid" x));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does example configuration for this looks like? Should we extend zfs-with-vdevs.nix ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks very similar to raidz, but the mode would look something like draid2:16d:27c:2s.

Copy link
Member

@Mic92 Mic92 Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a more complete configuration that I can use for testing?

Copy link
Author

@9p4 9p4 Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
  lib,
  ...
}:
let
in
{
  disko.devices = {
    disk = {
      "disk0" = {
        type = "disk";
        device = "/dev/mapper/disk0";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk1" = {
        type = "disk";
        device = "/dev/mapper/disk1";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk2" = {
        type = "disk";
        device = "/dev/mapper/disk2";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk3" = {
        type = "disk";
        device = "/dev/mapper/disk3";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk4" = {
        type = "disk";
        device = "/dev/mapper/disk4";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk5" = {
        type = "disk";
        device = "/dev/mapper/disk5";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk6" = {
        type = "disk";
        device = "/dev/mapper/disk6";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk7" = {
        type = "disk";
        device = "/dev/mapper/disk7";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk8" = {
        type = "disk";
        device = "/dev/mapper/disk8";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk9" = {
        type = "disk";
        device = "/dev/mapper/disk9";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk10" = {
        type = "disk";
        device = "/dev/mapper/disk10";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk11" = {
        type = "disk";
        device = "/dev/mapper/disk11";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk12" = {
        type = "disk";
        device = "/dev/mapper/disk12";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk13" = {
        type = "disk";
        device = "/dev/mapper/disk13";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk14" = {
        type = "disk";
        device = "/dev/mapper/disk14";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk15" = {
        type = "disk";
        device = "/dev/mapper/disk15";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk16" = {
        type = "disk";
        device = "/dev/mapper/disk16";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk17" = {
        type = "disk";
        device = "/dev/mapper/disk17";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk18" = {
        type = "disk";
        device = "/dev/mapper/disk18";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk19" = {
        type = "disk";
        device = "/dev/mapper/disk19";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk20" = {
        type = "disk";
        device = "/dev/mapper/disk20";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk21" = {
        type = "disk";
        device = "/dev/mapper/disk21";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk22" = {
        type = "disk";
        device = "/dev/mapper/disk22";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk23" = {
        type = "disk";
        device = "/dev/mapper/disk23";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk24" = {
        type = "disk";
        device = "/dev/mapper/disk24";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk25" = {
        type = "disk";
        device = "/dev/mapper/disk25";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
      "disk26" = {
        type = "disk";
        device = "/dev/mapper/disk26";
        content = {
          type = "gpt";
          partitions = {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "tank";
              };
            };
          };
        };
      };
    };
    zpool = {
      tank = {
        type = "zpool";
        mode = {
          topology = {
            type = "topology";
            vdev = [
              {
                mode = "draid2:16d:27c:2s"; # according to my calculations, this is pretty optimal. Read the README for more info
                members = [
                  "disk0"
                  "disk1"
                  "disk2"
                  "disk3"
                  "disk4"
                  "disk5"
                  "disk6"
                  "disk7"
                  "disk8"
                  "disk9"
                  "disk10"
                  "disk11"
                  "disk12"
                  "disk13"
                  "disk14"
                  "disk15"
                  "disk16"
                  "disk17"
                  "disk18"
                  "disk19"
                  "disk20"
                  "disk21"
                  "disk22"
                  "disk23"
                  "disk24"
                  "disk25"
                  "disk26"
                ];
              }
            ];
          };
        };
        datasets = {
          mirror = {
            type = "zfs_fs";
            mountpoint = "/srv/mirror";
          };
        };
      };
    };
  };
}

};
in
{
options = {
Expand Down Expand Up @@ -72,7 +78,7 @@ in
};
type = (
lib.types.oneOf [
(lib.types.enum modeOptions)
(zpoolModeType)
(lib.types.attrsOf (
diskoLib.subType {
types = {
Expand All @@ -83,7 +89,7 @@ in
{
options = {
mode = lib.mkOption {
type = lib.types.enum modeOptions;
type = zpoolModeType;
default = "";
description = "Mode of the zfs vdev";
};
Expand Down