Commit graph

164 commits

Author SHA1 Message Date
Silvan Mosberger 130a0c9878
lib/modules: Move the isDefined check into mergedValue
Without this change, accessing `mergedValue` from `mergeDefinitions` in
case there are no definitions will throw an error like

  error: evaluation aborted with the following error message: 'This case should never happen.'

This change makes it throw the appropriate error

  error: The option `foo' is used but not defined.

This is fully backwards compatible.
2020-01-10 16:19:54 +01:00
Silvan Mosberger e0ea5f4d9b
lib/modules: Fix store imports
This fixes imports from the store not being possible, which was caused by
https://github.com/NixOS/nixpkgs/pull/76857

E.g. such a case:

  imports = [ "${home-manager}/nixos" ];
2020-01-10 04:13:28 +01:00
Silvan Mosberger e9c16ec186
Merge pull request #76857 from Infinisil/recursive-disableModules
Apply `disabledModules` recursively
2020-01-09 18:20:12 +01:00
Silvan Mosberger de5f73d434
lib/modules: Recursive disabledModules
With this change, disabledModules applies recursively, meaning if you
have a module "foo.nix" with

    imports = [ ./bar.nix ];

then setting

  disabledModules = [ "foo.nix" ];

will disable both "foo.nix" and "bar.nix", whereas previously only
"foo.nix" would be disabled.

This change along with https://github.com/NixOS/nixpkgs/pull/61570 allows
modules to be fully disabled even when they have some `mkRenamedOption`
imports.
2020-01-09 17:26:05 +01:00
Silvan Mosberger b46776d14e
Clarify error message of 'assigning to top-level attribute' (#76702)
Clarify error message of 'assigning to top-level attribute'
2020-01-08 17:36:43 +01:00
Arnout Engelen 43ef3a8d00 lib/modules: clarify error message of 'assigning to top-level attribute'
If I understand correctly, the problem isn't so much that you're assigning to
that top-level attribute, but that the assignment to the attribute (or any
child of the attribute) introduces the 'config' object and prevents 'lifting'
all settings to a generated 'config' object.
2020-01-05 10:22:32 +01:00
Silvan Mosberger 5414b4018b
lib/modules: Don't pack submodules specially
This has the beneficial side effect of allowing paths to be used as modules in
types.{submodule,submoduleWith}
2020-01-01 01:13:03 +01:00
Silvan Mosberger 3cc77ce756
lib/modules: Make unifyModuleSyntax fully idempotent
Because why not
2019-12-05 05:51:44 +01:00
Silvan Mosberger aa613427b7
lib/modules: file -> _file for a more idempotent unifyModuleSyntax
This will be useful for doing more complicated module evaluations
2019-12-05 05:51:44 +01:00
Chuck 4ded9beea2 Add note: Keep error message in sync with nixos-option 2019-11-04 15:11:45 +01:00
Silvan Mosberger 2b1e2f2e97
Merge pull request #69746 from Infinisil/rem-opt-usage-message
lib.mkRemovedOptionModule: Show replacement for option usage too
2019-10-02 23:11:41 +02:00
Robin Gloster b08b0bcbbe mkRemovedOptionModule: assert on removed options
We don't want to ignore config that can mess up machines. In general
this should always fail evaluation, as you think you are changing
behaviour and don't, which can easily create run-time errors we can
catch early.
2019-09-30 12:07:13 +02:00
Silvan Mosberger ebb136da9f
lib.mkRemovedOptionModule: Show replacement for option usage too
Previously mkRemovedOptionModule would only show the replacement
instructions when the removed option was *defined*. With this change, it
also does so when an option is *used*.

This is essential for options that are only intended to be used such as
`security.acme.directory`, whose replacement instructions would never
trigger without this change because almost everybody only uses the
option and isn't defining it.
2019-09-28 04:10:22 +02:00
Silvan Mosberger de9cb24938
lib/modules: Use options apply function even if no values are defined
This allows `apply` functions to return a valid value if they completely
ignore their argument, which is the case for the option renaming
functions like `mkAliasOptionModule`. Therefore this solves issue #63693
2019-08-10 00:56:56 +02:00
Danylo Hlynskyi 60e8fcf0e5
module system: revert "remove types.optionSet", just deprecate (#56857)
The explicit remove helped to uncover some hidden uses of `optionSet`
in NixOps. However it makes life harder for end-users of NixOps - it will
be impossible to deploy 19.03 systems with old NixOps, but there is no
new release of NixOps with `optionSet` fixes.

Also, "deprecation" process isn't well defined. Even that `optionSet` was
declared "deprecated" for many years, it was never announced. Hence, I
leave "deprecation" announce. Then, 3 releases after announce,
we can announce removal of this feature.

This type has to be removed, not `throw`-ed in runtime, because it makes
some perfectly fine code to fail. For example:
```
$ nix-instantiate --eval -E '(import <nixpkgs/lib>).types' --strict
trace: `types.list` is deprecated; use `types.listOf` instead
error: types.optionSet is deprecated; use types.submodule instead
(use '--show-trace' to show detailed location information)
```
2019-03-07 21:28:09 +02:00
Silvan Mosberger d3216be6d9
Merge pull request #54528 from cdepillabout/module-alias-uses-priority
lib/modules: Change mkAliasOptionModule to use the priority for the alias
2019-02-23 16:43:05 +01:00
danbst 27982b408e types.optionSet: deprecate and remove last usages 2019-01-31 00:41:10 +02:00
danbst aa2e63ce5e lib/modules.nix: small eval optimization (foldl' + foldl' + attrNames -> foldl' + mapAttrs) 2019-01-30 15:26:44 +02:00
(cdep)illabout 81fa1e392b lib/modules: Change mkAliasOptionModule to use the priority for the alias.
This commit changes the `mkAliasOptionModule` function to make sure that
the priority for the aliased option is propagated to the non-aliased
option.

This also affects the `mkRenamedOptionModule` function in a similar
fashion.

This also removes the `mkAliasOptionModuleWithPriority` function, since
its functionality is now subsumed by `mkAliasOptionModule`.

This change was recommended by @nbp:
https://github.com/NixOS/nixpkgs/pull/53397#discussion_r245487432
2019-01-24 13:02:16 +09:00
(cdep)illabout f24e2d0721
Pull out defaultPriority to a top-level definition. 2019-01-06 17:48:37 +09:00
(cdep)illabout b81b3ad1b0
lib/modules: Add a function to create an option alias that respects the priority
This commit adds a function `mkAliasOptionModuleWithPriority`.  This
function will make an alias to an existing option and copy over the
priority.

This functionality is needed for PRs like #53041.  In that case
`nixos-generate-config` added an option to `hardware-configuration.nix`
with `mkDefault`.  That option was then changed and an alias created for
the old name.

The end user should be able to set the non-alias option in their
`configuration.nix` and have everything work correctly.  Without this
function, the priority for the option won't be copied over correctly
and the end-user will get a message saying they have the same option
set to two different values.
2019-01-04 18:35:10 +09:00
Symphorien Gibol 526d604670 module system: rework module merging
The asymptotic complexity is now much lower.
2018-08-27 17:11:58 +02:00
volth 87f5930c3f [bot]: remove unreferenced code 2018-07-20 18:48:37 +00:00
xeji 249be1c560
Merge pull request #42138 from NixOS/yegortimoshenko-patch-6
lib/modules: decrease mkOptionDefault priority to 1500
2018-06-27 20:29:39 +02:00
Yegor Timoshenko 441796cb16
lib/modules: bump mkOptionDefault priority to 1500 2018-06-17 23:29:16 +03:00
Jan Malakhovski 449d43fe01 lib: fix and simplify doRename
Before this change `mkRenamedOptionModule` would override option defaults
even when the old option name is left unused. For instance

```nix
{
  optios = {
    services.name.new = mkOption {
      default = { one = {}; };
    };
  };
  imports = [
    (mkRenamedOptionModule [ "services" "name" "old" ] [ "services" "name" "new" "two" ])
  ];
  config = {};
}
```

would evaluate to

`{ config.services.name.new = { two = {}; }; }`

when you'd expect it to evaluate to

`{ config.services.name.new = { one = {}; }; }`.
2018-06-11 15:06:27 +00:00
Jan Malakhovski c0c43e9c07 lib: simplify mkAliasAndWrapDefinitions 2018-06-11 15:06:27 +00:00
Matthew Justin Bauer 165c151f7a
Merge pull request #34805 from rycee/fix/dorename
lib: make use of visible variable in doRename
2018-05-14 18:08:26 -05:00
Jan Malakhovski 4017fdcafd lib: modules: propagate highestPrio
Yeah, it's ugly. But it's the minimal change that doesn't break anything
else.
2018-05-12 19:27:09 +00:00
Profpatsch fd54a946ca lib/debug: deprecate addErrorContextToAttrs
The function isn’t used anywhere and `addErrorContext` is an undocumented
builtin.
The builtin is explicitely qualified at its two uses in the module system.
2018-04-27 18:59:39 +02:00
Silvan Mosberger e1dee4efcb lib: make extensible
This allows the lib fixed point to be extended with

  myLib = lib.extend (self: super: {
    foo = "foo";
  })

With this it's possible to have the new modified lib attrset available to all
modules when using evalModules

  myLib.evalModules {
    modules = [ ({ lib, ... }: {
      options.bar = lib.mkOption {
	default = lib.foo;
      };
    }) ];
  }

  => { config = { bar = "foo"; ... }; options = ...; }
2018-04-07 13:21:49 -04:00
Franz Pletz e6f4614e85
lib/modules: fix typo 2018-03-28 02:28:15 +02:00
Robert Helgesson a7ed44ccad
lib: make use of visible variable in doRename
The `visible` variable was not hooked up previously. It is used to
determine whether the renamed option should be shown in the
documentation.
2018-02-10 10:29:33 +01:00
Shea Levy 943592f698
Add setFunctionArgs lib function.
Among other things, this will allow *2nix tools to output plain data
while still being composable with the traditional
callPackage/.override interfaces.
2018-01-31 14:02:19 -05:00
Profpatsch af424a607c lib/modules: Change type error to be gramatically nicer
Before:
  <x> is not a integer between 0 and 100 (inclusively).
(notice that “a” is wrong, it should be “an”)
Now:
  <x> is not of type `integer between 0 and 100 (inclusively)'.

This sounds a bit more formal, but circumvents the grammatical problems.
Multi-word type descriptions are also easier to see.
2017-11-05 15:56:32 +01:00
Graham Christensen 152c63c9ff
Convert libs to a fixed-point
This does break the API of being able to import any lib file and get
its libs, however I'm not sure people did this.

I made this while exploring being able to swap out docFn with a stub
in #2305, to avoid functor performance problems. I don't know if that
is going to move forward (or if it is a problem or not,) but after
doing all this work figured I'd put it up anyway :)

Two notable advantages to this approach:

1. when a lib inherits another lib's functions, it doesn't
   automatically get put in to the scope of lib
2. when a lib implements a new obscure functions, it doesn't
   automatically get put in to the scope of lib

Using the test script (later in this commit) I got the following diff
on the API:

  + diff master fixed-lib
  11764a11765,11766
  > .types.defaultFunctor
  > .types.defaultTypeMerge
  11774a11777,11778
  > .types.isOptionType
  > .types.isType
  11781a11786
  > .types.mkOptionType
  11788a11794
  > .types.setType
  11795a11802
  > .types.types

This means that this commit _adds_ to the API, however I can't find a
way to fix these last remaining discrepancies. At least none are
_removed_.

Test script (run with nix-repl in the PATH):

  #!/bin/sh

  set -eux

  repl() {
      suff=${1:-}
      echo "(import ./lib)$suff" \
          | nix-repl 2>&1
  }

  attrs_to_check() {
      repl "${1:-}" \
          | tr ';'  $'\n' \
          | grep "\.\.\." \
          | cut -d' ' -f2 \
          | sed -e "s/^/${1:-}./" \
          | sort
  }

  summ() {
      repl "${1:-}" \
          | tr ' ' $'\n' \
          | sort \
          | uniq
  }

  deep_summ() {
      suff="${1:-}"
      depth="${2:-4}"
      depth=$((depth - 1))
      summ "$suff"

      for attr in $(attrs_to_check "$suff" | grep -v "types.types"); do
          if [ $depth -eq 0 ]; then
              summ "$attr" | sed -e "s/^/$attr./"
          else
              deep_summ "$attr" "$depth" | sed -e "s/^/$attr./"
          fi
      done
  }

  (
      cd nixpkgs

      #git add .
      #git commit -m "Auto-commit, sorry" || true
      git checkout fixed-lib
      deep_summ > ../fixed-lib
      git checkout master
      deep_summ > ../master
  )

  if diff master fixed-lib; then
      echo "SHALLOW MATCH!"
  fi

  (
      cd nixpkgs
      git checkout fixed-lib
      repl .types
  )
2017-09-16 21:36:43 -04:00
zimbatm 4d545297d8 lib: introduce imap0, imap1 (#25543)
* lib: introduce imap0, imap1

For historical reasons, imap starts counting at 1 and it's not
consistent with the rest of the lib.

So for now we split imap into imap0 that starts counting at zero and
imap1 that starts counting at 1. And imap is marked as deprecated.

See c71e2d4235 (commitcomment-21873221)

* replace uses of lib.imap

* lib: move imap to deprecated.nix
2017-07-04 23:29:23 +01:00
Tom Saeger 5989515b94 lib: trivial spelling fixes 2017-04-19 19:37:55 -05:00
Benjamin Staffin d9123a2329 lib: fix mixed tab/space indents, trailing whitespace, etc
Nix style seems to have settled on not using spaces between bound
variable names and the lambda : so I also tried to make those somewhat
more consistent throughout.
2017-03-11 17:48:43 -05:00
Daiderd Jordan d88721e440
modules: add support for module replacement with disabledModules
This is based on a prototype Nicolas B. Pierron worked on during a
discussion we had at FOSDEM.

A new version with a workaround for problems of the reverted original.
Discussion: https://github.com/NixOS/nixpkgs/commit/3f2566689
2017-03-03 13:45:22 +01:00
Vladimír Čunát fcec3e1c72
Revert "modules: add support for module replacement with disabledModules"
This reverts commit 3f2566689d for now.
Evaluation of the tested job got broken, blocking nixos-unstable.
2017-03-01 21:56:01 +01:00
Daiderd Jordan 3f2566689d modules: add support for module replacement with disabledModules
This is based on a prototype Nicolas B. Pierron worked on during a
discussion we had at FOSDEM.
2017-02-28 00:14:48 +01:00
Nikolay Amiantov 5b759293e0 modules lib: type description in type error message 2017-02-03 11:28:33 +01:00
Eelco Dolstra a6bb468acf
mkIf: Check whether the condition is a Boolean
This gives a nicer error message than (say)

while evaluating the option `fileSystems':
while evaluating the attribute ‘isDefined’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:323:5:
while evaluating ‘filterOverrides’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:395:21, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:307:18:
while evaluating ‘concatMap’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/lists.nix:79:18, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:401:8:
while evaluating ‘concatMap’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/lists.nix:79:18, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:302:17:
while evaluating anonymous function at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:302:28, called from undefined position:
while evaluating ‘dischargeProperties’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:365:25, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:303:62:
value is a list while a Boolean was expected
2016-11-21 14:51:57 +01:00
Eric Sagnes e14de56613 module system: extensible option types 2016-11-06 00:05:58 +01:00
Eric Sagnes 26ea947d33 lib/module: add mkChangedOptionModule function 2016-09-24 21:10:29 +09:00
Eric Sagnes 13eefc3a31 lib/module: add mkMergedOptionModule function 2016-09-24 21:09:52 +09:00
Domen Kožar e01e92f12f Merge pull request #15025 from ericsagnes/modules/manual
manual: automatically generate modules documentation
2016-08-28 13:57:34 +02:00
Domen Kožar 4af09e0031 Merge pull request #14311 from Profpatsch/mkRemovedOptionModule-replacement
mkRemovedOptionModule: add replacement argument
2016-08-28 13:55:28 +02:00
Eric Sagnes 4cdfeb78f9 modules: move meta at top level 2016-08-11 00:29:48 +09:00
Eelco Dolstra 587473c574 Fix display of deprecated option definition warnings
Looks like this was accidentally left commented out by
5f077e2296.
2016-06-01 12:55:46 +02:00
Profpatsch 16c923cef2 modules/mkRemovedOptionModule: add replacement doc
When displaying a warning about a removed Option we should always
include reasoning why it was removed and how to get the same
functionality without it.

Introduces such a description argument and patches occurences (mostly
with an empty string).

startGnuPGAgent: further notes on replacement
2016-05-29 00:42:08 +02:00
Eelco Dolstra f3d94cfc23 Revert "Add the tool "nixos-typecheck" that can check an option declaration to:"
This reverts commit cad8957eab. It
breaks NixOps, but more importantly, such major changes to the module
system really need to be reviewed.
2016-03-01 20:52:06 +01:00
Thomas Strobel cad8957eab Add the tool "nixos-typecheck" that can check an option declaration to:
- Enforce that an option declaration has a "defaultText" if and only if the
   type of the option derives from "package", "packageSet" or "nixpkgsConfig"
   and if a "default" attribute is defined.

 - Enforce that the value of the "example" attribute is wrapped with "literalExample"
   if the type of the option derives from "package", "packageSet" or "nixpkgsConfig".

 - Warn if a "defaultText" is defined in an option declaration if the type of
   the option does not derive from "package", "packageSet" or "nixpkgsConfig".

 - Warn if no "type" is defined in an option declaration.
2016-02-29 01:09:00 +01:00
Eelco Dolstra 5f077e2296 Factor out option renaming
Option aliases/deprecations can now be declared in any NixOS module,
not just in nixos/modules/rename.nix. This is more modular (since it
allows for example grub-related aliases to be declared in the grub
module), and allows aliases outside of NixOS (e.g. in NixOps modules).

The syntax is a bit funky. Ideally we'd have something like:

  options = {
    foo.bar.newOption = mkOption { ... };
    foo.bar.oldOption = mkAliasOption [ "foo" "bar" "newOption" ];
  };

but that's not possible because options cannot define values in
*other* options - you need to have a "config" for that. So instead we
have functions that return a *module*: mkRemovedOptionModule,
mkRenamedOptionModule and mkAliasOptionModule. These can be used via
"imports", e.g.

  imports = [
    (mkAliasOptionModule [ "foo" "bar" "oldOption" ] [ "foo" "bar" "newOption" ]);
  ];

As an added bonus, deprecation warnings now show the file name of the
offending module.

Fixes #10385.
2015-10-14 18:18:47 +02:00
Nicolas B. Pierron c47e89623b Update option-usages.nix expression to work with newer version of the module system. 2015-08-09 17:52:34 +02:00
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