diff options
| -rw-r--r-- | modules/disk.nix | 171 |
1 files changed, 74 insertions, 97 deletions
diff --git a/modules/disk.nix b/modules/disk.nix index e7f85ab..79885cd 100644 --- a/modules/disk.nix +++ b/modules/disk.nix @@ -3,7 +3,6 @@ pkgs, lib, modulesPath, - inputs, ... }: let @@ -16,17 +15,16 @@ let ; in { - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - inputs.disko.nixosModules.default - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; options.depot.disk = { enable = lib.mkEnableOption "Apply depot-standard ZFS disk layout."; persistHome = lib.mkEnableOption "Persist home directories."; - device = lib.mkOption { - type = types.str; - description = "Name of device to install to."; + + reserved = lib.mkOption { + type = types.ints.positive; + description = "Space (in GB) to reserve as unusable on disk."; + default = 10; }; }; @@ -45,7 +43,7 @@ in daily = 14; monthly = 1; }; - datasets."zroot/persist" = { + datasets."zroot/local/var" = { useTemplate = [ "default" ]; recursive = true; }; @@ -69,6 +67,7 @@ in loader.efi.canTouchEfiVariables = true; loader.systemd-boot = { enable = true; + memtest86.enable = true; extraFiles."efi/ipxe.efi" = "${pkgs.ipxe}/ipxe.efi"; extraEntries."ipxe.conf" = '' title iPXE @@ -89,104 +88,82 @@ in }; }; - disko.devices.nodev."/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=2G" - "mode=755" - ]; - }; - - disko.devices.disk.main = { - imageSize = "32G"; - device = cfg.device; - type = "disk"; - content = { - type = "gpt"; - partitions.ESP = { - size = "1G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - partitions.ZFS = { - size = "100%"; - content.type = "zfs"; - content.pool = "zroot"; - }; + services.getty.autologinUser = "root"; + fileSystems = { + "/" = { + device = "nodev"; + fsType = "tmpfs"; + options = [ + "defaults" + "size=2G" + "mode=755" + ]; }; - }; - - disko.devices.zpool.zroot = { - type = "zpool"; - options = { - ashift = "12"; - autotrim = "on"; + "/nix" = { + device = "zroot/local/nix"; + fsType = "zfs"; }; - rootFsOptions = { - acltype = "posixacl"; - atime = "off"; - compression = "on"; - mountpoint = "none"; - normalization = "formD"; - relatime = "off"; - xattr = "sa"; + "/boot" = { + device = "/dev/disk/by-partlabel/ESP"; + fsType = "vfat"; + options = [ "umask=0077" ]; }; + }; - datasets = - let - inherit (lib) - genAttrs - ; + system.build.image = pkgs.depot.make-zfs-image.override { + inherit pkgs lib config; + format = "qcow2"; + }; - mounts = [ - # Any machine importing this configuration will require a - # nix store, so it needs to survive reboots. - "nix" + # datasets = + # let + # inherit (lib) + # genAttrs + # ; - # Although it goes against the idea of putting root on a - # tmpfs, SystemD stores useful state for timers, services, - # logs, etc. in var. - "var" + # mounts = [ + # # Any machine importing this configuration will require a + # # nix store, so it needs to survive reboots. + # "nix" - # Most machines using this module do not define additional - # users, so /root should persist as the only "home" on the - # system. - "root" + # # Although it goes against the idea of putting root on a + # # tmpfs, SystemD stores useful state for timers, services, + # # logs, etc. in var. + # "var" - # General storage that should outlive a reboot. Paths - # mentioned in Nix configs should generally use this - # directory rather than /var or other directories that - # happen to also be saved. - "persist" - ] ++ lib.optional cfg.persistHome "home"; + # # Most machines using this module do not define additional + # # users, so /root should persist as the only "home" on the + # # system. + # "root" - makeDataset = name: { - type = "zfs_fs"; - mountpoint = "/${name}"; - options.mountpoint = "legacy"; - }; - in - genAttrs mounts makeDataset - // { - # ZFS should not use all available space on a device. This - # reserves some space at pool creation time that is never mounted - # to ensure it never happens. - reserved = { - type = "zfs_fs"; - options = { - refreservation = "10G"; - mountpoint = "none"; - }; - }; - }; - }; + # # General storage that should outlive a reboot. Paths + # # mentioned in Nix configs should generally use this + # # directory rather than /var or other directories that + # # happen to also be saved. + # "persist" + # ] ++ lib.optional cfg.persistHome "home"; + + # makeDataset = name: { + # type = "zfs_fs"; + # mountpoint = "/${name}"; + # options.mountpoint = "legacy"; + # }; + # in + # genAttrs mounts makeDataset + # // { + # # ZFS should not use all available space on a device. This + # # reserves some space at pool creation time that is never mounted + # # to ensure it never happens. + # reserved = { + # type = "zfs_fs"; + # options = { + # refreservation = "${toString cfg.reserved}G"; + # mountpoint = "none"; + # }; + # }; + # }; + # }; }; } |
