From 9d769b6b9d50195ec7370ec34fbd2b1aaea840c6 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Sun, 6 Jul 2025 08:14:43 -0400 Subject: [PATCH 1/2] nixos/unlock-bcachefs: Fix x-systemd.requires/wants= matching. It would match options with those keys as a prefix, e.g. x-systemd.requires-mounts-for=, and fail to extract a sensible value. --- nixos/modules/tasks/filesystems/bcachefs.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 97d4bd283115..21d5c4a9e84b 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -111,7 +111,7 @@ let deviceUnit = mkDeviceUnit device; mountUnit = mkMountUnit (prefix + fs.mountPoint); extractProperty = - prop: options: (map (lib.removePrefix "${prop}=") (builtins.filter (lib.hasPrefix prop) options)); + prop: options: (map (lib.removePrefix prop) (builtins.filter (lib.hasPrefix prop) options)); normalizeUnits = unit: if lib.hasPrefix "/dev/" unit then @@ -120,8 +120,8 @@ let mkMountUnit unit else unit; - requiredUnits = map normalizeUnits (extractProperty "x-systemd.requires" fs.options); - wantedUnits = map normalizeUnits (extractProperty "x-systemd.wants" fs.options); + requiredUnits = map normalizeUnits (extractProperty "x-systemd.requires=" fs.options); + wantedUnits = map normalizeUnits (extractProperty "x-systemd.wants=" fs.options); in { name = "unlock-bcachefs-${utils.escapeSystemdPath fs.mountPoint}"; From 45bb7f83f4c85dd14781b171ef657020168f5a4c Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Sun, 6 Jul 2025 08:14:43 -0400 Subject: [PATCH 2/2] nixos/unlock-bcachefs: Support x-systemd.requires/wants-mounts-for= --- nixos/modules/tasks/filesystems/bcachefs.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 21d5c4a9e84b..a64ff5e906e8 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -122,6 +122,8 @@ let unit; requiredUnits = map normalizeUnits (extractProperty "x-systemd.requires=" fs.options); wantedUnits = map normalizeUnits (extractProperty "x-systemd.wants=" fs.options); + requiredMounts = extractProperty "x-systemd.requires-mounts-for=" fs.options; + wantedMounts = extractProperty "x-systemd.wants-mounts-for=" fs.options; in { name = "unlock-bcachefs-${utils.escapeSystemdPath fs.mountPoint}"; @@ -136,6 +138,10 @@ let bindsTo = [ deviceUnit ]; requires = requiredUnits; wants = wantedUnits; + unitConfig = { + RequiresMountsFor = requiredMounts; + WantsMountsFor = wantedMounts; + }; conflicts = [ "shutdown.target" ]; unitConfig.DefaultDependencies = false; serviceConfig = {