nixos/filesystems: don't silently ignore label when device is set (#361418)

This commit is contained in:
Will Fancher 2024-12-03 23:59:55 -05:00 committed by GitHub
commit 74454e41a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,8 @@ with lib;
with utils;
let
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
addCheckDesc = desc: elemType: check: types.addCheck elemType check
// { description = "${elemType.description} (with check: ${desc})"; };
@ -136,6 +138,8 @@ let
};
config.device = lib.mkIf (config.label != null) "/dev/disk/by-label/${escape config.label}";
config.options = let
inInitrd = utils.fsNeededForBoot config;
in mkMerge [
@ -196,11 +200,8 @@ let
];
isBindMount = fs: builtins.elem "bind" fs.options;
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck || isBindMount fs;
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
in fstabFileSystems: { }: concatMapStrings (fs:
(if fs.device != null then escape fs.device
else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
else throw "No device specified for mount point ${fs.mountPoint}.")
+ " " + escape fs.mountPoint
+ " " + fs.fsType