{ povSelf, hostConfig, config, lib, pkgs, ... }: let inherit (lib) types; cfg = lib.getAttrFromPath povSelf config; users = lib.pipe config.modules.users [ (lib.mapAttrsToList (name: value: if value.enable then name else null)) (lib.filter (element: !builtins.isNull element)) ]; part = name: content: if cfg.encrypt then { type = "luks"; settings.allowDiscards = true; inherit name content; } else content; in { options = { enable = { type = types.bool; default = false; }; disks = { type = types.listOf types.path; }; type = { type = types.enum [ "lvm" "zfs" ]; }; encrypt = { type = types.bool; default = false; }; parts = { home = { type = types.bool; default = false; }; homePerUser = { type = types.bool; default = cfg.parts.home; }; nix = { type = types.bool; default = true; }; tmp = { type = types.bool; default = false; }; system = { type = types.bool; default = false; }; }; reservedSpace = { type = types.nullOr types.str; default = "8G"; }; swap = { enable = { type = types.bool; default = false; }; size = { type = types.strMatching "[0-9]+[KMGTP]"; }; }; }; config = lib.mkIf cfg.enable { disko.devices = { disk = listToAttrs (imap0 (i: device: { name = "${hostConfig.hostName}-dsk${toString i}"; value = { inherit device; content = { type = "gpt"; partitions = { boot = { size = "512M"; type = "EF00"; content = { type = "filesystem"; format = "vfat"; # FIXME: Multidisk? mountpoint = "/boot"; mountOptions = [ "umask=0077" "dmask=0077" "nofail" ]; }; }; cryptroot = { size = "100%"; content = { type = "luks"; settings = { allowDiscards = true; # FIXME: If disk is an SSD?? }; content = { type = "lvm_pv"; # FIXME: Or ZFS? vg = hostConfig.hostName; }; }; }; }; }; }) cfg.disks); lvm_vg = { ${hostConfig.hostName} = { lvs = { swap = { size = cfg.swap.size; content.type = "swap"; }; root = {}; nix = {}; persist = {}; home = {}; }; }; }; }; }