diff options
Diffstat (limited to 'nixos/modules/config/swap.nix')
-rw-r--r-- | nixos/modules/config/swap.nix | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix index 9a5d6a9fc333..f0353c5a35ec 100644 --- a/nixos/modules/config/swap.nix +++ b/nixos/modules/config/swap.nix @@ -128,6 +128,7 @@ in wantedBy = [ "${realDevice'}.swap" ]; before = [ "${realDevice'}.swap" ]; path = [ pkgs.utillinux ] ++ optional sw.randomEncryption pkgs.cryptsetup; + script = '' ${optionalString (sw.size != null) '' @@ -145,11 +146,13 @@ in mkswap ${sw.realDevice} ''} ''; + unitConfig.RequiresMountsFor = [ "${dirOf sw.device}" ]; unitConfig.DefaultDependencies = false; # needed to prevent a cycle serviceConfig.Type = "oneshot"; serviceConfig.RemainAfterExit = sw.randomEncryption; - serviceConfig.ExecStop = optionalString sw.randomEncryption "cryptsetup luksClose ${sw.deviceName}"; + serviceConfig.ExecStop = optionalString sw.randomEncryption "${pkgs.cryptsetup}/bin/cryptsetup luksClose ${sw.deviceName}"; + restartIfChanged = false; }; in listToAttrs (map createSwapDevice (filter (sw: sw.size != null || sw.randomEncryption) config.swapDevices)); |