diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2022-01-25 14:13:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 14:13:24 +0100 |
commit | 8919495cacf6411bde7b9c14bc4a9d12142a7356 (patch) | |
tree | ab1e8c88e5374544563eff047b4ba3dedebfeefd /lib/options.nix | |
parent | 25dc5a5d2dca644390f23ad376119d62468bf57b (diff) | |
parent | 48dbe26229124114f26cfe0eec32866a47888452 (diff) | |
download | nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar.gz nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar.bz2 nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar.lz nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar.xz nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.tar.zst nixpkgs-8919495cacf6411bde7b9c14bc4a9d12142a7356.zip |
Merge pull request #156503 from hercules-ci/nixos-add-system.build-options
nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error message
Diffstat (limited to 'lib/options.nix')
-rw-r--r-- | lib/options.nix | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/options.nix b/lib/options.nix index 794ca5e3394..627aac24d2f 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -172,11 +172,13 @@ rec { else if all isInt list && all (x: x == head list) list then head list else throw "Cannot merge definitions of `${showOption loc}'. Definition values:${showDefs defs}"; - mergeOneOption = loc: defs: - if defs == [] then abort "This case should never happen." - else if length defs != 1 then - throw "The unique option `${showOption loc}' is defined multiple times. Definition values:${showDefs defs}" - else (head defs).value; + mergeOneOption = mergeUniqueOption { message = ""; }; + + mergeUniqueOption = { message }: loc: defs: + if length defs == 1 + then (head defs).value + else assert length defs > 1; + throw "The option `${showOption loc}' is defined multiple times.\n${message}\nDefinition values:${showDefs defs}"; /* "Merge" option definitions by checking that they all have the same value. */ mergeEqualOption = loc: defs: |