summary refs log tree commit diff
path: root/lib/modules.nix
Commit message (Collapse)AuthorAge
* module system: rework module mergingSymphorien Gibol2018-08-27
| | | | The asymptotic complexity is now much lower.
* [bot]: remove unreferenced codevolth2018-07-20
|
* Merge pull request #42138 from NixOS/yegortimoshenko-patch-6xeji2018-06-27
|\ | | | | lib/modules: decrease mkOptionDefault priority to 1500
| * lib/modules: bump mkOptionDefault priority to 1500Yegor Timoshenko2018-06-17
| |
* | lib: fix and simplify `doRename`Jan Malakhovski2018-06-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11
|/
* Merge pull request #34805 from rycee/fix/dorenameMatthew Justin Bauer2018-05-14
|\ | | | | lib: make use of visible variable in doRename
| * lib: make use of visible variable in doRenameRobert Helgesson2018-02-10
| | | | | | | | | | | | 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-12
| | | | | | | | | | Yeah, it's ugly. But it's the minimal change that doesn't break anything else.
* | lib/debug: deprecate `addErrorContextToAttrs`Profpatsch2018-04-27
| | | | | | | | | | | | 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-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-28
|/
* Add setFunctionArgs lib function.Shea Levy2018-01-31
| | | | | | 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-05
| | | | | | | | | | | 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-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-04
| | | | | | | | | | | | | | | | * 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-19
|
* lib: fix mixed tab/space indents, trailing whitespace, etcBenjamin Staffin2017-03-11
| | | | | | 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-03
| | | | | | | | 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-01
| | | | | 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-28
| | | | | 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-03
|
* mkIf: Check whether the condition is a BooleanEelco Dolstra2016-11-21
| | | | | | | | | | | | | 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-06
|
* lib/module: add mkChangedOptionModule functionEric Sagnes2016-09-24
|
* lib/module: add mkMergedOptionModule functionEric Sagnes2016-09-24
|
* Merge pull request #15025 from ericsagnes/modules/manualDomen Kožar2016-08-28
|\ | | | | manual: automatically generate modules documentation
| * modules: move meta at top levelEric Sagnes2016-08-11
| |
* | Merge pull request #14311 from Profpatsch/mkRemovedOptionModule-replacementDomen Kožar2016-08-28
|\ \ | |/ |/| mkRemovedOptionModule: add replacement argument
| * modules/mkRemovedOptionModule: add replacement docProfpatsch2016-05-29
| | | | | | | | | | | | | | | | | | | | | | 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-01
|/ | | | | 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-01
| | | | | | 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-29
| | | | | | | | | | | | | | - 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-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-09
| | | | system.
* Module system: Fix ‘definitions’ fieldEelco Dolstra2015-08-05
| | | | Fixes https://github.com/NixOS/nixops/issues/325.
* Add read-only optionsEelco Dolstra2015-07-30
| | | | | These are options that can have only one definition, regardless of priority.
* Remove superfluous copy of "min"Eelco Dolstra2015-07-28
|
* Minor module system evaluation speedupsEelco Dolstra2015-07-28
| | | | | | This gives about a 5% speedup. Issue #8152.
* Fix indentationEelco Dolstra2015-07-28
|
* concatLists (map ...) -> concatMapEelco Dolstra2015-07-23
|
* Use foldl' instead of fold in some placesEelco Dolstra2015-07-23
|
* NixOS modules: Add error context on module arguments evaluation.Nicolas B. Pierron2015-07-14
|
* types.uniq types.bool -> types.boolEelco Dolstra2015-06-15
|
* Bring an importable modulesPath back from the dead, in the only way I knowDan Peebles2015-06-08
|
* Document and rename internal option of modules.Nicolas B. Pierron2015-03-15
|
* Share common code for merging option definitions.Nicolas B. Pierron2015-03-12
| | | | | | | 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 == []`.
* Rename mergeDefinitions internal steps to functions which are independent of ↵Nicolas B. Pierron2015-03-12
| | | | each others.
* Expose submodule arguments to builtins.functionArgs before applying the ↵Nicolas B. Pierron2015-03-12
| | | | | | | | | 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.
* Add comment about limitation on __internal.checkShea Levy2015-03-12
|