aboutsummaryrefslogtreecommitdiff
path: root/lib/modules.nix (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib/modules: Use options `apply` function even if no values are definedSilvan Mosberger2019-08-101-10/+8
| | | | | | 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
* module system: revert "remove types.optionSet", just deprecate (#56857)Danylo Hlynskyi2019-03-071-2/+16
| | | | | | | | | | | | | | | | | | | | 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) ```
* Merge pull request #54528 from cdepillabout/module-alias-uses-prioritySilvan Mosberger2019-02-231-10/+4
|\ | | | | lib/modules: Change mkAliasOptionModule to use the priority for the alias
| * lib/modules: Change mkAliasOptionModule to use the priority for the alias.(cdep)illabout2019-01-241-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | types.optionSet: deprecate and remove last usagesdanbst2019-01-311-17/+2
| |
* | lib/modules.nix: small eval optimization (foldl' + foldl' + attrNames -> ā†µdanbst2019-01-301-12/+14
|/ | | | foldl' + mapAttrs)
* Pull out defaultPriority to a top-level definition.(cdep)illabout2019-01-061-5/+5
|
* lib/modules: Add a function to create an option alias that respects the priority(cdep)illabout2019-01-041-3/+27
| | | | | | | | | | | | | | | | | 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.
* module system: rework module mergingSymphorien Gibol2018-08-271-21/+45
| | | | The asymptotic complexity is now much lower.
* [bot]: remove unreferenced codevolth2018-07-201-1/+0
|
* Merge pull request #42138 from NixOS/yegortimoshenko-patch-6xeji2018-06-271-1/+1
|\ | | | | lib/modules: decrease mkOptionDefault priority to 1500
| * lib/modules: bump mkOptionDefault priority to 1500Yegor Timoshenko2018-06-171-1/+1
| |
* | lib: fix and simplify `doRename`Jan Malakhovski2018-06-111-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 = {}; }; }`.
* | lib: simplify `mkAliasAndWrapDefinitions`Jan Malakhovski2018-06-111-3/+1
|/
* Merge pull request #34805 from rycee/fix/dorenameMatthew Justin Bauer2018-05-141-0/+1
|\ | | | | lib: make use of visible variable in doRename
| * lib: make use of visible variable in doRenameRobert Helgesson2018-02-101-0/+1
| | | | | | | | | | | | The `visible` variable was not hooked up previously. It is used to determine whether the renamed option should be shown in the documentation.
* | lib: modules: propagate `highestPrio`Jan Malakhovski2018-05-121-8/+19
| | | | | | | | | | Yeah, it's ugly. But it's the minimal change that doesn't break anything else.
* | lib/debug: deprecate `addErrorContextToAttrs`Profpatsch2018-04-271-2/+2
| | | | | | | | | | | | 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.
* | lib: make extensibleSilvan Mosberger2018-04-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 = ...; }
* | lib/modules: fix typoFranz Pletz2018-03-281-1/+1
|/
* Add setFunctionArgs lib function.Shea Levy2018-01-311-1/+1
| | | | | | Among other things, this will allow *2nix tools to output plain data while still being composable with the traditional callPackage/.override interfaces.
* lib/modules: Change type error to be gramatically nicerProfpatsch2017-11-051-1/+1
| | | | | | | | | | | 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.
* Convert libs to a fixed-pointGraham Christensen2017-09-161-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 )
* lib: introduce imap0, imap1 (#25543)zimbatm2017-07-041-1/+1
| | | | | | | | | | | | | | | | * 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 https://github.com/NixOS/nixpkgs/commit/c71e2d42359f9900ea2c290d141c0d606471da16#commitcomment-21873221 * replace uses of lib.imap * lib: move imap to deprecated.nix
* lib: trivial spelling fixesTom Saeger2017-04-191-1/+1
|
* lib: fix mixed tab/space indents, trailing whitespace, etcBenjamin Staffin2017-03-111-4/+4
| | | | | | 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.
* modules: add support for module replacement with disabledModulesDaiderd Jordan2017-03-031-7/+17
| | | | | | | | 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
* Revert "modules: add support for module replacement with disabledModules"VladimĆ­r ČunĆ”t2017-03-011-17/+7
| | | | | This reverts commit 3f2566689d14f1d7778d55ca807d1dad2f4695d1 for now. Evaluation of the tested job got broken, blocking nixos-unstable.
* modules: add support for module replacement with disabledModulesDaiderd Jordan2017-02-281-7/+17
| | | | | This is based on a prototype Nicolas B. Pierron worked on during a discussion we had at FOSDEM.
* modules lib: type description in type error messageNikolay Amiantov2017-02-031-1/+1
|
* mkIf: Check whether the condition is a BooleanEelco Dolstra2016-11-211-3/+6
| | | | | | | | | | | | | 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
* module system: extensible option typesEric Sagnes2016-11-061-11/+21
|
* lib/module: add mkChangedOptionModule functionEric Sagnes2016-09-241-0/+26
|
* lib/module: add mkMergedOptionModule functionEric Sagnes2016-09-241-0/+53
|
* Merge pull request #15025 from ericsagnes/modules/manualDomen Kožar2016-08-281-3/+7
|\ | | | | manual: automatically generate modules documentation
| * modules: move meta at top levelEric Sagnes2016-08-111-3/+7
| |
* | Merge pull request #14311 from Profpatsch/mkRemovedOptionModule-replacementDomen Kožar2016-08-281-4/+10
|\ \ | |/ |/| mkRemovedOptionModule: add replacement argument
| * modules/mkRemovedOptionModule: add replacement docProfpatsch2016-05-291-4/+10
| | | | | | | | | | | | | | | | | | | | | | 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
* | Fix display of deprecated option definition warningsEelco Dolstra2016-06-011-2/+0
|/ | | | | Looks like this was accidentally left commented out by 5f077e229625583072ebf63ea48b11170771b0ed.
* Revert "Add the tool "nixos-typecheck" that can check an option declaration to:"Eelco Dolstra2016-03-011-82/+17
| | | | | | This reverts commit cad8957eabcbf73062226d28366fd446c15c8737. It breaks NixOps, but more importantly, such major changes to the module system really need to be reviewed.
* Add the tool "nixos-typecheck" that can check an option declaration to:Thomas Strobel2016-02-291-17/+82
| | | | | | | | | | | | | | - 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.
* Factor out option renamingEelco Dolstra2015-10-141-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Update option-usages.nix expression to work with newer version of the module ā†µNicolas B. Pierron2015-08-091-1/+1
| | | | system.
* Module system: Fix ā€˜definitionsā€™ fieldEelco Dolstra2015-08-051-1/+1
| | | | Fixes https://github.com/NixOS/nixops/issues/325.
* Add read-only optionsEelco Dolstra2015-07-301-3/+8
| | | | | These are options that can have only one definition, regardless of priority.
* Remove superfluous copy of "min"Eelco Dolstra2015-07-281-1/+0
|
* Minor module system evaluation speedupsEelco Dolstra2015-07-281-23/+26
| | | | | | This gives about a 5% speedup. Issue #8152.
* Fix indentationEelco Dolstra2015-07-281-32/+33
|
* concatLists (map ...) -> concatMapEelco Dolstra2015-07-231-4/+4
|
* Use foldl' instead of fold in some placesEelco Dolstra2015-07-231-7/+7
|