0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Add read-only options

These are options that can have only one definition, regardless of
priority.
This commit is contained in:
Eelco Dolstra 2015-07-30 13:36:57 +02:00
parent d61e1b24e6
commit f463d24903
4 changed files with 16 additions and 5 deletions

View file

@ -261,11 +261,16 @@ rec {
evalOptionValue = loc: opt: defs:
let
# Add in the default value for this option, if any.
defs' = (optional (opt ? default)
{ file = head opt.declarations; value = mkOptionDefault opt.default; }) ++ defs;
defs' =
(optional (opt ? default)
{ file = head opt.declarations; value = mkOptionDefault opt.default; }) ++ defs;
# Handle properties, check types, and merge everything together.
res = mergeDefinitions loc opt.type defs';
res =
if opt.readOnly or false && length defs' > 1 then
throw "The option `${showOption loc}' is read-only, but it's set multiple times."
else
mergeDefinitions loc opt.type defs';
# Check whether the option is defined, and apply the apply
# function to the merged value. This allows options to yield a