From 68978ef1ed95c9bfc778d14797b2107c6398bb2a Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Sat, 14 Mar 2026 21:14:26 +0000 Subject: [PATCH 1/2] examples: add zfs-simple-root.nix This is a real world example that contains some nice features like zstd compression and noatime, just to show what's possible. A user could just use this as-is and change only the disk path --- example/zfs-simple-root.nix | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 example/zfs-simple-root.nix diff --git a/example/zfs-simple-root.nix b/example/zfs-simple-root.nix new file mode 100644 index 00000000..4bc8b061 --- /dev/null +++ b/example/zfs-simple-root.nix @@ -0,0 +1,73 @@ +{ + disko.devices = { + disk = { + disk1 = { + device = "/dev/disk/sdx"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + type = "EF00"; + size = "2G"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "rpool"; + }; + }; + }; + }; + }; + }; + zpool = { + rpool = { + type = "zpool"; + rootFsOptions = { + acltype = "posixacl"; + compression = "zstd"; + dnodesize = "auto"; + normalization = "formD"; + relatime = "on"; + xattr = "sa"; + }; + options = { + ashift = "12"; + autotrim = "on"; + }; + + datasets = { + "root" = { + type = "zfs_fs"; + options = { + mountpoint = "legacy"; + }; + mountpoint = "/"; + }; + "nix" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/nix"; + }; + "var" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/var"; + }; + "home" = { + type = "zfs_fs"; + mountpoint = "/home"; + options.mountpoint = "legacy"; + }; + }; + }; + }; + }; +} From 06a3e1c91ffc192d0df7a03074936e814aa27cf4 Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Sat, 14 Mar 2026 21:15:09 +0000 Subject: [PATCH 2/2] tests: add make-disk-image-zfs.nix This uses the simple zfs on root example to test that zfs disk images can be made in CI --- tests/make-disk-image-zfs.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/make-disk-image-zfs.nix diff --git a/tests/make-disk-image-zfs.nix b/tests/make-disk-image-zfs.nix new file mode 100644 index 00000000..fcb598fc --- /dev/null +++ b/tests/make-disk-image-zfs.nix @@ -0,0 +1,26 @@ +{ + pkgs ? import { }, + ... +}: + +(pkgs.nixos [ + ../module.nix + ../example/zfs-simple-root.nix + ( + { config, ... }: + { + networking.hostId = "00000000"; + + # Adds some weight to the closure size to test real world usage + disko.devices.disk.disk1.imageSize = "5G"; + environment.systemPackages = with pkgs; [ + chromium + firefox + ]; + + documentation.enable = false; + system.stateVersion = config.system.nixos.release; + disko.checkScripts = true; + } + ) +]).config.system.build.diskoImages