diff --git a/flake.nix b/flake.nix index 7ff71d7..1da377b 100644 --- a/flake.nix +++ b/flake.nix @@ -161,6 +161,7 @@ builder = ./modules/nixos/builder.nix; community-builder = ./modules/nixos/community-builder; disko-raid = ./modules/nixos/disko-raid.nix; + disko-zfs = ./modules/nixos/disko-zfs.nix; github-org-backup = ./modules/nixos/github-org-backup.nix; hercules-ci = ./modules/nixos/hercules-ci; hydra = ./modules/nixos/hydra.nix; diff --git a/modules/nixos/disko-zfs.nix b/modules/nixos/disko-zfs.nix new file mode 100644 index 0000000..19fc901 --- /dev/null +++ b/modules/nixos/disko-zfs.nix @@ -0,0 +1,89 @@ +{ inputs, ... }: +{ + imports = [ + inputs.disko.nixosModules.disko + ]; + + networking.hostId = "deadbeef"; + + # this is both efi and bios compatible + boot.loader.grub = { + enable = true; + efiSupport = true; + efiInstallAsRemovable = true; + }; + + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for grub MBR + }; + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "nofail" ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + nvme1n1 = { + type = "disk"; + device = "/dev/nvme1n1"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + options = { + ashift = "12"; + }; + rootFsOptions = { + acltype = "posixacl"; + atime = "off"; + compression = "lz4"; + mountpoint = "none"; + xattr = "sa"; + "com.sun:auto-snapshot" = "false"; + }; + datasets = { + root = { + type = "zfs_fs"; + mountpoint = "/"; + options.mountpoint = "legacy"; + }; + }; + }; + }; + }; +}