···261 evalOptionValue = loc: opt: defs:
262 let
263 # Add in the default value for this option, if any.
264- defs' = (optional (opt ? default)
265- { file = head opt.declarations; value = mkOptionDefault opt.default; }) ++ defs;
0266267 # Handle properties, check types, and merge everything together.
268- res = mergeDefinitions loc opt.type defs';
0000269270 # Check whether the option is defined, and apply the ‘apply’
271 # function to the merged value. This allows options to yield a
···261 evalOptionValue = loc: opt: defs:
262 let
263 # Add in the default value for this option, if any.
264+ defs' =
265+ (optional (opt ? default)
266+ { file = head opt.declarations; value = mkOptionDefault opt.default; }) ++ defs;
267268 # Handle properties, check types, and merge everything together.
269+ res =
270+ if opt.readOnly or false && length defs' > 1 then
271+ throw "The option `${showOption loc}' is read-only, but it's set multiple times."
272+ else
273+ mergeDefinitions loc opt.type defs';
274275 # Check whether the option is defined, and apply the ‘apply’
276 # function to the merged value. This allows options to yield a
+2
lib/options.nix
···19 , apply ? null # Function that converts the option value to something else.
20 , internal ? null # Whether the option is for NixOS developers only.
21 , visible ? null # Whether the option shows up in the manual.
022 , options ? null # Obsolete, used by types.optionSet.
23 } @ attrs:
24 attrs // { _type = "option"; };
···90 declarations = filter (x: x != unknownModule) opt.declarations;
91 internal = opt.internal or false;
92 visible = opt.visible or true;
093 type = opt.type.name or null;
94 }
95 // (if opt ? example then { example = scrubOptionValue opt.example; } else {})
···19 , apply ? null # Function that converts the option value to something else.
20 , internal ? null # Whether the option is for NixOS developers only.
21 , visible ? null # Whether the option shows up in the manual.
22+ , readOnly ? null # Whether the option can be set only once
23 , options ? null # Obsolete, used by types.optionSet.
24 } @ attrs:
25 attrs // { _type = "option"; };
···91 declarations = filter (x: x != unknownModule) opt.declarations;
92 internal = opt.internal or false;
93 visible = opt.visible or true;
94+ readOnly = opt.readOnly or false;
95 type = opt.type.name or null;
96 }
97 // (if opt ? example then { example = scrubOptionValue opt.example; } else {})