mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-14 13:39:15 +03:00
nixos/filesystems: assert that the device and label options are consistent
This commit is contained in:
parent
8aa3366263
commit
b6dbf6deed
1 changed files with 10 additions and 2 deletions
|
@ -138,7 +138,7 @@ let
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.device = lib.mkIf (config.label != null) "/dev/disk/by-label/${escape config.label}";
|
config.device = lib.mkIf (config.label != null) (lib.mkDefault "/dev/disk/by-label/${escape config.label}");
|
||||||
|
|
||||||
config.options = let
|
config.options = let
|
||||||
inInitrd = utils.fsNeededForBoot config;
|
inInitrd = utils.fsNeededForBoot config;
|
||||||
|
@ -354,7 +354,15 @@ in
|
||||||
options.
|
options.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
] ++ lib.map (fs: {
|
||||||
|
assertion = fs.label != null -> fs.device == "/dev/disk/by-label/${escape fs.label}";
|
||||||
|
message = ''
|
||||||
|
The filesystem with mount point ${fs.mountPoint} has its label and device set to inconsistent values:
|
||||||
|
label: ${toString fs.label}
|
||||||
|
device: ${toString fs.device}
|
||||||
|
'filesystems.<name>.label' and 'filesystems.<name>.device' are mutually exclusive. Please set only one.
|
||||||
|
'';
|
||||||
|
}) fileSystems;
|
||||||
|
|
||||||
# Export for use in other modules
|
# Export for use in other modules
|
||||||
system.build.fileSystems = fileSystems;
|
system.build.fileSystems = fileSystems;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue