From c90c29bacc3d7fd2f1032d7dc5801bb57f995d0e Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Wed, 25 Jun 2025 04:56:16 -0400 Subject: [PATCH] nixos/bcachefs: Parse tags Fixes #317901 --- nixos/modules/tasks/filesystems/bcachefs.nix | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 6128b5d1e68f..97d4bd283115 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -91,13 +91,27 @@ let mkUnits = prefix: name: fs: let - mountUnit = "${utils.escapeSystemdPath (prefix + (lib.removeSuffix "/" fs.mountPoint))}.mount"; - device = firstDevice fs; + parseTags = + device: + if lib.hasPrefix "LABEL=" device then + "/dev/disk/by-label/" + lib.removePrefix "LABEL=" device + else if lib.hasPrefix "UUID=" device then + "/dev/disk/by-uuid/" + lib.removePrefix "UUID=" device + else if lib.hasPrefix "PARTLABEL=" device then + "/dev/disk/by-partlabel/" + lib.removePrefix "PARTLABEL=" device + else if lib.hasPrefix "PARTUUID=" device then + "/dev/disk/by-partuuid/" + lib.removePrefix "PARTUUID=" device + else if lib.hasPrefix "ID=" device then + "/dev/disk/by-id/" + lib.removePrefix "ID=" device + else + device; + device = parseTags (firstDevice fs); mkDeviceUnit = device: "${utils.escapeSystemdPath device}.device"; + mkMountUnit = path: "${utils.escapeSystemdPath (lib.removeSuffix "/" path)}.mount"; deviceUnit = mkDeviceUnit device; + mountUnit = mkMountUnit (prefix + fs.mountPoint); extractProperty = prop: options: (map (lib.removePrefix "${prop}=") (builtins.filter (lib.hasPrefix prop) options)); - mkMountUnit = path: "${utils.escapeSystemdPath path}.mount"; normalizeUnits = unit: if lib.hasPrefix "/dev/" unit then