Commit Graph

58 Commits

Author SHA1 Message Date
Eelco Dolstra
cbecbd01f9 Module system: Fix ‘definitions’ field
Fixes https://github.com/NixOS/nixops/issues/325.
2015-08-05 14:35:00 +02:00
Eelco Dolstra
f463d24903 Add read-only options
These are options that can have only one definition, regardless of
priority.
2015-07-30 13:44:50 +02:00
Eelco Dolstra
273d9ffd6a Remove superfluous copy of "min" 2015-07-28 18:42:22 +02:00
Eelco Dolstra
67b1a20f12 Minor module system evaluation speedups
This gives about a 5% speedup.

Issue #8152.
2015-07-28 15:04:18 +02:00
Eelco Dolstra
0ca10a445a Fix indentation 2015-07-28 15:04:18 +02:00
Eelco Dolstra
4cc6c83477 concatLists (map ...) -> concatMap 2015-07-23 18:31:54 +02:00
Eelco Dolstra
637e35deb9 Use foldl' instead of fold in some places 2015-07-23 18:31:54 +02:00
Nicolas B. Pierron
a6b455bbae NixOS modules: Add error context on module arguments evaluation. 2015-07-14 15:07:54 +02:00
Eelco Dolstra
c738b309ee types.uniq types.bool -> types.bool 2015-06-15 18:10:26 +02:00
Dan Peebles
b13cb54614 Bring an importable modulesPath back from the dead, in the only way I know 2015-06-08 01:55:49 +00:00
Nicolas B. Pierron
05e8a48fb4 Document and rename internal option of modules. 2015-03-15 14:45:42 +01:00
Nicolas B. Pierron
ed91474e9b Share common code for merging option definitions.
This move idioms which were used in `evalOptionValue` and in the `merge`
functions of `listOf` and `attrsOf` types, such that we can use a names such
as `isDefined` and `optionalValue` instead or repeating identical
comparisons of `defsFinal == []`.
2015-03-12 23:42:58 +01:00
Nicolas B. Pierron
dd4f5f6b78 Rename mergeDefinitions internal steps to functions which are independent of each others. 2015-03-12 23:42:58 +01:00
Nicolas B. Pierron
83dc60456e Expose submodule arguments to builtins.functionArgs before applying the arguments.
The current implementation of the ApplyIfFunction is looking at the
arguments of a module to decide which arguments should be given to each
module.  This patch make sure that we do not wrap a submodule function in
order to keep functionArgs working as expected.
2015-03-12 23:42:58 +01:00
Shea Levy
772b8869d2 Add comment about limitation on __internal.check 2015-03-12 23:42:57 +01:00
Shea Levy
0a0a29fd0b Add comments about the module system interface
Ideally the module system could be configured pretty much completely by
the contents of the modules themselves, so add comments about avoiding
complicating it further and possibly removing now-redundant
configurability from the existing interface.
2015-03-12 23:42:57 +01:00
Shea Levy
e3eff53037 evalModules: Add internal option for the check argument 2015-03-12 23:42:57 +01:00
Shea Levy
e4a06f35b1 nixos: Don't evaluate twice to get the value of config.nixpkgs 2015-03-12 23:42:57 +01:00
Shea Levy
1d62ad4746 modules.nix: Generate the extra argument set from the configuration
This allows for module arguments to be handled modularly, in particular
allowing the nixpkgs module to handle the nixpkgs import internally.
This creates the __internal option namespace, which should only be added
to by the module system itself.
2015-03-12 23:42:57 +01:00
Shea Levy
9255c48a06 Move property processing, type checking, and merge code into a function
This makes the relationship between property types clearer, and more
importantly will let option types parameterized by other option types
reuse the code for delegated type checking and merging.
2015-03-12 23:42:57 +01:00
Nicolas B. Pierron
d7f29acd48 modules: Extract mkAliasDefinition from the rename.nix NixOS module. 2014-12-22 22:38:38 +01:00
Luca Bruno
350fa1f775 nixos: Try to show an helpful message when the user sets config. or options.
Feel free to improve or remove :-)
2014-11-01 23:33:24 +01:00
Eelco Dolstra
97220c973f Replace hasAttr/getAttr calls with the ? and . operators
For NixOS evaluation, this gives a ~21% reduction in the number of
values allocated and a ~4% speedup. It's also more readable.
2014-10-05 01:11:06 +02:00
Eelco Dolstra
6c2bf141cf lib: Use arithmetic operators rather than builtins.add etc. 2014-10-05 01:10:06 +02:00
Nicolas Pierron
b5f0cc3cda Merge options having the submodule type.
Now we should be able to have multiple declaration of the same option as
long as all declarations have the same type.  If the type has a sub module,
then it is merged with the submodules of other declarations, as done with
option sets.

In addition, the file of the option declaration is passed into the
submodule, such as the documentation can display it correctly.
2014-09-07 19:03:20 +02:00
Nicolas Pierron
bb944b4dc8 Annotate option-set options with the file in which they are declared.
This modification improves NixOS manual by listing in which file, each
submodule option is declared.  This solve the issue that files are not
reported when looking at options such as fileSystems.<name?>.neededForBoot
2014-09-07 19:03:20 +02:00
Nicolas Pierron
eb7a17a1cf Add error an message to prevent use of useless submodules. 2014-08-29 18:54:15 +02:00
Jan Malakhovski
0ea84c4445 minor fix in documentation
Signed-off-by: Domen Kožar <domen@dev.si>
2014-06-26 11:13:15 +02:00
Rob Vermaas
90a7711e08 Re-introduce (marked as obsolete) mkStrict function, to allow old nixops deployments to keep working. 2014-05-05 12:29:38 +02:00
Eelco Dolstra
0469f92faf Bring back mkOrder 2014-03-30 20:35:25 +02:00
Shea Levy
2deb26bd4a Pass lib to modules
Since mkOption, types, etc. are defined there, lib is really part of the interface
2014-02-11 13:51:54 -05:00
Eelco Dolstra
785eaf2cea Add some primops to lib 2013-11-12 13:48:30 +01:00
Eelco Dolstra
a61b800da5 Fix backward compatibility with Nix < 1.6
"with" used to be less lazy, so don't rely on that.  Also don't use
the "<" operator.
2013-10-30 19:12:25 +01:00
Eelco Dolstra
800f9c2037 Show correct position info for errors in submodules
E.g.

  The unique option `fileSystems./.device' is defined multiple times, in `/etc/nixos/configuration.nix' and `/etc/nixos/foo.nix'.

This requires passing file/value tuples to the merge functions.
2013-10-30 14:57:43 +01:00
Eelco Dolstra
c7f7ceefd6 Export only the files of the active definitions 2013-10-30 14:57:42 +01:00
Eelco Dolstra
89b1dd8dde Fix environment.checkConfigurationOptions
This requires delaying the declaredness check until later, otherwise
we get an infinite recursion querying
environment.checkConfigurationOptions.
2013-10-29 16:18:23 +01:00
Eelco Dolstra
85b69834e7 fixMergeModules shouldn't check whether options are declared 2013-10-29 14:34:39 +01:00
Eelco Dolstra
be33a68177 Add fixMergeModules back in
NixOps uses it.
2013-10-29 14:23:10 +01:00
Eelco Dolstra
9143910139 Support module keys that are paths 2013-10-29 14:15:33 +01:00
Eelco Dolstra
adc1b38b85 Add a priority level for overrides in VM tests
Now that overriding fileSystems in qemu-vm.nix works again, it's
important that the VM tests that add additional file systems use the
same override priority.  Instead of using the same magic constant
everywhere, they can now use mkVMOverride.

http://hydra.nixos.org/build/6695561
2013-10-29 13:14:30 +01:00
Eelco Dolstra
3115addf4c Fix nixos-option
In particular, it no longer produces an "infinite recursion" error
when run with no arguments.
2013-10-28 22:45:58 +01:00
Eelco Dolstra
73f32d0375 Show precise error messages in option merge failures
For instance, if time.timeZone is defined multiple times, you now get
the error message:

  error: user-thrown exception: The unique option `time.timeZone' is defined multiple times, in `/etc/nixos/configurations/misc/eelco/x11vnc.nix' and `/etc/nixos/configuration.nix'.

while previously you got:

  error: user-thrown exception: Multiple definitions of string. Only one is allowed for this option.

and only an inspection of the stack trace gave a clue as to what
option caused the problem.
2013-10-28 22:45:57 +01:00
Eelco Dolstra
1b2006270f Support mkOverride in non-leaf nodes 2013-10-28 22:45:57 +01:00
Eelco Dolstra
1367074940 Allow imports in plain modules 2013-10-28 22:45:57 +01:00
Eelco Dolstra
1e24ce2a9b Remove debug code 2013-10-28 22:45:57 +01:00
Eelco Dolstra
e28ea1239f Fix evaluation of environment.variables 2013-10-28 22:45:57 +01:00
Eelco Dolstra
9a8516438e Fix NixOps evaluation 2013-10-28 22:45:57 +01:00
Eelco Dolstra
44d6d88739 Fix option renaming 2013-10-28 22:45:56 +01:00
Eelco Dolstra
f4a418761b Check for undeclared options 2013-10-28 22:45:56 +01:00
Eelco Dolstra
c263b5b284 Show error locations in submodules 2013-10-28 22:45:56 +01:00