swap: forward discardPolicy option to randomEncryption.allowDiscards

I.e. instead of effectively ignoring `discardPolicy` when combined with
`randomEncryption`, or adding a second option requiring the user to
repeat themselves (DRY violation), just enable both when requested via
`discardPolicy`.

Without this `discardPolicy` is a NOP when `randomEncryption` is
enabled.
This commit is contained in:
Giel van Schijndel authored and mergify[bot] committed 2024-05-14 21:30:40 +00:00
1 parent e972a78f4a
commit f236f6df36
1 file changed
+6 -1
+6 -1
View File
@@ -92,7 +92,12 @@
default = [{
swapDevices = [{
device = config.device;
inherit (config) discardPolicy priority randomEncryption;
inherit (config) discardPolicy priority;
randomEncryption = {
enable = config.randomEncryption;
# forward discard/TRIM attempts through dm-crypt
allowDiscards = config.discardPolicy != null;
};
}];
boot.resumeDevice = lib.mkIf config.resumeDevice config.device;
}];