From 49badf305f632132cfa70eac4058d06d44ef3c20 Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 28 Dec 2022 16:22:03 +0100 Subject: [PATCH] zpool: add optionsAfterCreate... Not sure about the best implementation here yet. I'd like to use disk encryption with ZFS and existing disko facilities work fine to set it up, but we obviously can't use keylocation=prompt during disko formatting. So unlocking fails on boot if the file referred to by keylocation isn't included in the initrd. Ideally I could use keylocation=file://tmp/disk.key during partitioning, but set keylocation=prompt right after that. example usage: ``` rpool = { type = "zpool"; mode = ""; options = { ashift = "12"; autotrim = "on"; }; optionsAfterCreate = { keylocation = "prompt"; }; rootFsOptions = { encryption = "on"; keylocation = "file:///tmp/disk.key"; keyformat = "passphrase"; compression = "zstd"; acltype = "posixacl"; mountpoint = "none"; canmount = "off"; xattr = "sa"; dnodesize = "auto"; normalization = "formD"; relatime = "on"; }; ``` --- types.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types.nix b/types.nix index ff87a6c..256d2f0 100644 --- a/types.nix +++ b/types.nix @@ -1118,6 +1118,10 @@ rec { default = {}; description = "Options for the ZFS pool"; }; + optionsAfterCreate = mkOption { + type = types.attrsOf types.str; + default = {}; + }; rootFsOptions = mkOption { type = types.attrsOf types.str; default = {}; @@ -1155,6 +1159,7 @@ rec { ${concatStringsSep " " (mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \ ${concatStringsSep " " (mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \ ''${ZFSDEVICES_${config.name}} + zfs set ${concatStringsSep " " (mapAttrsToList (n: v: "${n}=${v}") config.optionsAfterCreate)} ${config.name} ${concatMapStrings (dataset: dataset._create config.name) (attrValues config.datasets)} ''; description = "Creation script";