diff --git a/example/complex.nix b/example/complex.nix index 939f71e..1c02ef9 100644 --- a/example/complex.nix +++ b/example/complex.nix @@ -39,7 +39,7 @@ type = "luks"; name = "crypted1"; keyFile = "/tmp/secret.key"; - extraArgs = [ + extraFormatArgs = [ "--iter-time 1" ]; content = { @@ -67,7 +67,7 @@ type = "luks"; name = "crypted2"; keyFile = "/tmp/secret.key"; - extraArgs = [ + extraFormatArgs = [ "--iter-time 1" ]; content = { diff --git a/example/luks-lvm.nix b/example/luks-lvm.nix index a6879ce..51cd24c 100644 --- a/example/luks-lvm.nix +++ b/example/luks-lvm.nix @@ -30,6 +30,7 @@ content = { type = "luks"; name = "crypted"; + extraOpenArgs = [ "--allow-discards" ]; keyFile = "/tmp/secret.key"; content = { type = "lvm_pv"; diff --git a/types/luks.nix b/types/luks.nix index 90fcdcc..350a238 100644 --- a/types/luks.nix +++ b/types/luks.nix @@ -15,10 +15,16 @@ default = null; description = "Path to the key for encryption"; }; - extraArgs = lib.mkOption { + extraFormatArgs = lib.mkOption { type = lib.types.listOf lib.types.str; 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; _meta = lib.mkOption { @@ -32,8 +38,8 @@ _create = diskoLib.mkCreateOption { inherit config options; default = { dev }: '' - cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs} - cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"} + cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraFormatArgs} + 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}";})} ''; };