From fe18bb82a1661e768864b377a5ecd9a2bd10dd6b Mon Sep 17 00:00:00 2001 From: Atemu Date: Tue, 9 Jun 2026 22:32:34 +0200 Subject: [PATCH 1/2] nixos/swap: detect whether swap is a device --- nixos/modules/config/swap.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix index fa09b61ddec0..334b0c84f67a 100644 --- a/nixos/modules/config/swap.nix +++ b/nixos/modules/config/swap.nix @@ -106,6 +106,11 @@ let description = "Path of the device or swap file."; }; + isDevice = mkOption { + default = lib.substring 0 5 config.device == "/dev/"; + internal = true; + }; + label = mkOption { example = "swap"; type = types.str; From a8f871c1483115f0480ebee2f756141952a065d9 Mon Sep 17 00:00:00 2001 From: Atemu Date: Tue, 9 Jun 2026 22:33:03 +0200 Subject: [PATCH 2/2] nixos/swap: trigger device readiness Attempts to fix https://github.com/nixos/nixpkgs/issues/524389 --- nixos/modules/config/swap.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix index 334b0c84f67a..c99fd3ddf162 100644 --- a/nixos/modules/config/swap.nix +++ b/nixos/modules/config/swap.nix @@ -334,6 +334,7 @@ in ) } ${sw.device} ${sw.deviceName} mkswap ${sw.realDevice} + ${lib.optionalString sw.isDevice "udevadm trigger ${sw.realDevice}"} ''} ''; enableStrictShellChecks = true;