luks: rename extraArgs to extraFormatArgs, add extraOpenArgs

This commit is contained in:
Linus Heckemann committed 2023-03-21 19:43:42 +01:00
1 parent 25c5376b02
commit 0577409d12
3 files changed
+13 -6

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@
type = "luks"; type = "luks";
name = "crypted1"; name = "crypted1";
keyFile = "/tmp/secret.key"; keyFile = "/tmp/secret.key";
extraArgs = [ extraFormatArgs = [
"--iter-time 1" "--iter-time 1"
]; ];
content = { content = {
@@ -67,7 +67,7 @@
type = "luks"; type = "luks";
name = "crypted2"; name = "crypted2";
keyFile = "/tmp/secret.key"; keyFile = "/tmp/secret.key";
extraArgs = [ extraFormatArgs = [
"--iter-time 1" "--iter-time 1"
]; ];
content = { content = {
+1
View File
@@ -30,6 +30,7 @@
content = { content = {
type = "luks"; type = "luks";
name = "crypted"; name = "crypted";
extraOpenArgs = [ "--allow-discards" ];
keyFile = "/tmp/secret.key"; keyFile = "/tmp/secret.key";
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
+10 -4
View File
@@ -15,10 +15,16 @@
default = null; default = null;
description = "Path to the key for encryption"; description = "Path to the key for encryption";
}; };
extraArgs = lib.mkOption { extraFormatArgs = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = [ ]; default = [ ];
description = "Extra arguments"; description = "Extra arguments to pass to `cryptsetup luksFormat` when formatting";
};
extraOpenArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Extra arguments to pass to `cryptsetup luksOpen` when opening";
example = [ "--allow-discards" ];
}; };
content = diskoLib.deviceType; content = diskoLib.deviceType;
_meta = lib.mkOption { _meta = lib.mkOption {
@@ -32,8 +38,8 @@
_create = diskoLib.mkCreateOption { _create = diskoLib.mkCreateOption {
inherit config options; inherit config options;
default = { dev }: '' default = { dev }: ''
cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs} cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraFormatArgs}
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"} cryptsetup luksOpen ${dev} ${config.name} ${toString config.extraOpenArgs} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"}
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/mapper/${config.name}";})} ${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/mapper/${config.name}";})}
''; '';
}; };