summary refs log tree commit diff
path: root/lib/types.nix
Commit message (Collapse)AuthorAge
* Merge pull request #156533 from ↵Silvan Mosberger2022-03-16
|\ | | | | | | | | hercules-ci/issue-146882-transparent-submodule-options lib.modules: Let module declare options directly in bare submodule
| * lib.modules: Inline a private functionRobert Hensing2022-03-03
| | | | | | | | This should save about four calls per module.
| * lib.modules: Default shorthandOnlyDefinesConfig to true when nullRobert Hensing2022-03-03
| |
| * lib.modules: Make option injection work when shorthandOnlyDefinesConfigRobert Hensing2022-03-03
| |
| * lib.types.submodule: Remove redundant isSubmodule attrRobert Hensing2022-03-03
| |
| * lib.modules: Let module declare options directly in bare submoduleRobert Hensing2022-03-03
| | | | | | | | | | | | | | | | | | | | ... where a bare submodule is an option that has a type like `submoduleWith x`, as opposed to `attrsOf (submoduleWith x)`. This makes migration unnecessary when introducing a freeform type in an existing option tree. Closes #146882
* | Merge pull request #163443 from ncfavier/fix-types-packageRobert Hensing2022-03-11
|\ \ | | | | | | lib.types.package: only call toDerivation when necessary
| * | lib.types.package: only call toDerivation when necessaryNaïm Favier2022-03-11
| |/ | | | | | | | | | | | | | | | | | | | | The current logic assumes that everything that isn't a derivation is a store path, but it can also be something that's *coercible* to a store path, like a flake input. Unnecessary uses of `lib.toDerivation` result in errors in pure evaluation mode when `builtins.storePath` is disabled. Also document what a `package` is.
* / lib.types.optionType: Only merge when necessaryRobert Hensing2022-03-10
|/
* Merge pull request #162283 from Infinisil/functionTo.descriptionSilvan Mosberger2022-03-02
|\ | | | | lib/types: Fix functionTo description
| * lib/types: Fix functionTo descriptionSilvan Mosberger2022-03-01
| |
* | lib.types: Introduce `types.optionType`Silvan Mosberger2022-03-01
|/ | | | | | This type correctly merges multiple option types together while also annotating them with file information. In a future commit this will be used for `_module.freeformType`
* lib/types: Introduce types.raw for unprocessed valuesSilvan Mosberger2022-02-22
|
* lib/types: Fix emptyValue of listOf and nonEmptyListOfSilvan Mosberger2022-02-17
| | | | | | An empty list is [], not {}! Also, non-empty lists shouldn't have a default of an empty list!
* lib.types: Add unique like uniq, but custom errorsRobert Hensing2022-01-24
| | | | | Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages.
* types.singleLineStr: Improve descriptionJules Aguillon2022-01-21
| | | | Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
* types.singleLineStr: Allow and trim trailing \nJules Aguillon2022-01-20
| | | | | | | | | | | | Allow a \n character at the end of the string and remove it during the merge function. An option of this type will resolve to the value "foo" whether it is set to "foo" or "foo\n". This is useful when using 'builtins.readFile' or ''-strings, which might add an unintended newline (for example, bash trim the final newline from a subshell).
* types.singleLineStr: Disallow \rJules Aguillon2022-01-18
|
* types.singleLineStr: strings that don't contain '\n'Jules Aguillon2022-01-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new type, inheriting 'types.str' but checking whether the value doesn't contain any newline characters. The motivation comes from a problem with the 'users.users.${u}.openssh.authorizedKeys' option. It is easy to unintentionally insert a newline character at the end of a string, or even in the middle, for example: restricted_ssh_keys = command: keys: let prefix = '' command="${command}",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding ''; in map (key: "${prefix} ${key}") keys; The 'prefix' string ends with a newline, which ends up in the middle of a key entry after a few manipulations. This is problematic because the key file is built by concatenating all the keys with 'concatStringsSep "\n"', with result in two entries for the faulty key: '' command="...",options... MY_KEY '' This is hard to debug and might be dangerous. This is now caught at build time.
* lib.evalModules: Add extendModules and type to resultRobert Hensing2021-11-01
| | | | | | | Allows the simultaneous construction of top-level invocations and submodule types. This helps structure configuration systems integration code.
* lib/types: Make types.anything merge functionsSilvan Mosberger2021-10-02
| | | | | Previously it would give an error if there were multiple function definitions.
* Merge pull request #128032 from Artturin/add-swap-optionsRobert Hensing2021-07-23
|\ | | | | nixos/swap: add options option
| * lib/types.nix: add nonEmptyStrArtturin2021-07-20
| |
* | lib.types.enum: Improve description for lengths 0 and 1Robert Hensing2021-05-25
|/
* Merge pull request #117888 from kvtb/patch-3Silvan Mosberger2021-05-08
|\ | | | | types.nix: fix outdated comment
| * types.nix: types.ints.s32 and types.ints.u32 do workkvtb2021-03-30
| |
| * types.nix: fix outdated commentkvtb2021-03-28
| | | | | | Nix's `int` is always 64-bit
* | lib/types: Introduce mkOptionType occurringTypes argumentSilvan Mosberger2021-05-03
| | | | | | | | | | | | | | | | | | This will be used to issue deprecation warnings recursively in the next commit In addition, this allows easily getting nested types of other options, which is useful when you want to create an option that aliases a part of another one.
* | lib/types: only accept derivations for shellPackagesternenseemann2021-04-26
|/ | | | | | | Since shellPackage actually requires the value to be an attribute set (i. e. an derivation in this case), we cannot re-use the package.check type checker since it also allows strings or things that are coercible to strings as long as they look like store paths.
* lib/types: add description for functionToFritz Otlinghaus2021-01-31
|
* lib/types: Improved functionTo mergingSilvan Mosberger2021-01-27
| | | | | | | Now type checks the resulting function values and allows mkMerge and co. Also indicates that the type check is done in the function body Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
* Revert "Remove types.functionTo."Bas van Dijk2021-01-24
| | | | | | | | | | | | | | | | | This reverts commit 4ff1ab5a56f1280d2de319ad4eb4b2796e07ed35. We need this to type options like: services.xserver.windowManager.xmonad.extraPackages that specify functions that take an attribute set containing packages / plugins and return a list containing a selection of the values in this set. The reason we need a dedicated type for this is to have the correct merge behaviour. Without the functionTo type merging multiple function option definitions results in an evaluation error. The functionTo type merges definitions by returning a new function that applies the functions of all the definitions to the given input and merges the result. (cherry picked from commit 7ed41ff5e7e633dd64866398ee497ac02736a3a5)
* lib/types.nix: fix missing inheritKeshav Kini2020-10-26
| | | | | | | I think there was a silent (i.e. semantic) merge conflict between PR #101139 and PR #100456. This commit should fix the error, which manifests as follows: error: undefined variable 'boolToString' at /home/kkini/src/nixpkgs/lib/types.nix:552:42
* Merge pull request #101139 from roberth/lib-use-static-scope-checkingRobert Hensing2020-10-26
|\ | | | | lib: Use Nix's static scope checking, fix error message, optimize
| * lib: Use Nix's static scope checking, fix error message, optimizeRobert Hensing2020-10-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension.
| * lib/types.nix: Use // instead of mergeAttrsRobert Hensing2020-10-22
| |
* | treewide: De-inline uses of lib.boolToStringMalte Brandy2020-10-14
|/ | | | This commit should not change eval results
* lib/types: Fix type description of bool enum valuesSilvan Mosberger2020-10-03
| | | | Previously bool values would show as <bool>
* lib/types: Remove unreachable if branchSilvan Mosberger2020-09-21
| | | | | The type's check function already ensured that it can't be passed non-lists
* Merge pull request #97119 from Infinisil/types.anythingRobert Hensing2020-09-21
|\ | | | | Introduce `types.anything`
| * lib/types: Introduce types.anythingSilvan Mosberger2020-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | This new type has unsurprising merge behavior: Only attribute sets are merged together (recursively), and only if they don't conflict. This is in contrast to the existing types: - types.attrs is problematic because later definitions completely override attributes of earlier definitions, and it doesn't support mkIf and co. - types.unspecified is very similar to types.attrs, but it has smart merging behavior that often doesn't make sense, and it doesn't support all types
* | Merge pull request #97114 from Infinisil/type-deprecationSilvan Mosberger2020-09-07
|\ \ | | | | | | Better type deprecation messages
| * | lib/types: Set deprecationMessage for types.optionSetSilvan Mosberger2020-09-07
| | |
| * | lib/types: Set deprecationMessage for types.loaOfSilvan Mosberger2020-09-07
| | |
| * | lib/types: Set deprecationMessage for types.stringSilvan Mosberger2020-09-07
| | |
| * | lib/types: Remove types.list, it's been deprecated long enoughSilvan Mosberger2020-09-07
| | | | | | | | | | | | | | | Has been deprecated since fd803fce606a007403ba6d05f09ed2e6a3371830 (2013-08-22)
| * | lib/types: Allow types to emit a deprecation warningSilvan Mosberger2020-09-07
| |/ | | | | | | | | | | | | | | | | | | | | | | Previously the only way to deprecate a type was using theType = lib.warn "deprecated" (mkOptionType ...) This caused the warning to be emitted when the type was evaluated, but the error didn't include which option actually used that type. With this commit, types can specify a deprecationMessage, which when non-null, is printed along with the option that uses the type
* | Merge pull request #97042 from Infinisil/freeform-option-docsSilvan Mosberger2020-09-07
|\ \ | |/ |/| Show sub options of freeform types
| * lib/types: Show sub options of freeform typesSilvan Mosberger2020-09-03
| | | | | | | | | | Previously if you set the freeform type to e.g. attrsOf (submodule ..), those submodule options wouldn't be shown in the manual.
* | treewide: completely remove types.loaOfrnhmjoj2020-09-02
|/