summary refs log tree commit diff
path: root/nixos/modules/config/swap.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-01-12 17:27:21 +0300
committerNikolay Amiantov <ab@fmap.me>2016-01-12 17:27:21 +0300
commit9df07753cef9dcc7f8aa08b3152bc62d95d01062 (patch)
treec8e5584fc1492fba639846760fa1b1ca3cf97529 /nixos/modules/config/swap.nix
parent4a9ad20a9598f03b098e236b22b5136e325b6924 (diff)
downloadnixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar.gz
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar.bz2
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar.lz
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar.xz
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.tar.zst
nixpkgs-9df07753cef9dcc7f8aa08b3152bc62d95d01062.zip
swap service: don't restart mkswap.service on switches
Sadly, we can't instruct systemd to properly restart device-name.swap when this service restarts (or I haven't found the way to do so). As of now blindly restarting it would only get you a bunch of errors about device already used -- let's avoid it.
Diffstat (limited to 'nixos/modules/config/swap.nix')
-rw-r--r--nixos/modules/config/swap.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix
index 0ab5bb3d89c..f0353c5a35e 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 "${pkgs.cryptsetup}/bin/cryptsetup luksClose ${sw.deviceName}";
+            restartIfChanged = false;
           };
 
       in listToAttrs (map createSwapDevice (filter (sw: sw.size != null || sw.randomEncryption) config.swapDevices));