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 2024-05-13 10:42:41 +02:00 committed by mergify[bot]
parent e972a78f4a
commit f236f6df36

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;
}];