nixos/config/swap: refactor startup script generation

This commit is contained in:
Mikaela Allan 2023-05-07 11:42:36 -04:00
parent 21b6bec0ff
commit 445d7cae2a
No known key found for this signature in database
GPG Key ID: BC04913562575C81

View File

@ -275,12 +275,12 @@ in
''}
${optionalString sw.randomEncryption.enable ''
cryptsetup plainOpen -c ${sw.randomEncryption.cipher} -d ${sw.randomEncryption.source} \
'' + concatLines (filter (s: s != "") [
(optionalString (sw.randomEncryption.sectorSize != null) "--sector-size=${toString sw.randomEncryption.sectorSize} \\")
(optionalString (sw.randomEncryption.keySize != null) "--key-size=${toString sw.randomEncryption.keySize} \\")
(optionalString sw.randomEncryption.allowDiscards "--allow-discards \\")
]) + ''
${sw.device} ${sw.deviceName}
'' + concatMapStrings (arg: arg + " \\\n") (flatten [
(optional (sw.randomEncryption.sectorSize != null) "--sector-size=${toString sw.randomEncryption.sectorSize}")
(optional (sw.randomEncryption.keySize != null) "--key-size=${toString sw.randomEncryption.keySize}")
(optional sw.randomEncryption.allowDiscards "--allow-discards")
]) + ''
${sw.device} ${sw.deviceName}
mkswap ${sw.realDevice}
''}
'';