diff --git a/example/zfs-encrypted-root.nix b/example/zfs-encrypted-root.nix new file mode 100644 index 0000000..cb60a70 --- /dev/null +++ b/example/zfs-encrypted-root.nix @@ -0,0 +1,63 @@ +{ + disko.devices = { + disk = { + root = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "nofail" ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + rootFsOptions = { + mountpoint = "none"; + compression = "zstd"; + acltype = "posixacl"; + xattr = "sa"; + "com.sun:auto-snapshot" = "true"; + }; + options.ashift = "12"; + datasets = { + "root" = { + type = "zfs_fs"; + options = { + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + #keylocation = "file:///tmp/secret.key"; + keylocation = "prompt"; + }; + mountpoint = "/"; + + }; + "root/nix" = { + type = "zfs_fs"; + options.mountpoint = "/nix"; + mountpoint = "/nix"; + }; + }; + }; + }; + }; +} diff --git a/tests/zfs-encrypted-root.nix b/tests/zfs-encrypted-root.nix new file mode 100644 index 0000000..a883a2f --- /dev/null +++ b/tests/zfs-encrypted-root.nix @@ -0,0 +1,18 @@ +{ pkgs ? import { } +, diskoLib ? pkgs.callPackage ../lib { } +}: +diskoLib.testLib.makeDiskoTest { + inherit pkgs; + name = "zfs-encrypted-root"; + extraInstallerConfig.networking.hostId = "8425e349"; + extraSystemConfig.networking.hostId = "8425e349"; + disko-config = + pkgs.lib. recursiveUpdate (import ../example/zfs-encrypted-root.nix) { + disko.devices.zpool.zroot.datasets.root.options.keylocation = "file:///tmp/secret.key"; + }; + extraTestScript = '' + machine.succeed("mountpoint /"); + machine.succeed("mountpoint /nix"); + ''; +} +