about summary refs log tree commit diff
path: root/lib/tests
AgeCommit message (Collapse)AuthorFilesLines
2022-05-23Merge pull request #168374 from Ma27/special-attrs-in-with-recursionSilvan Mosberger1-0/+15
lib/generators: withRecursion: don't break attr-sets with special attrs
2022-05-17Merge pull request #172813 from hercules-ci/functionTo-properlyRobert Hensing2-0/+63
`lib.types.functionTo` type merging and docs
2022-05-16Merge pull request #170561 from klemensn/types-descriptionSilvan Mosberger1-1/+1
lib/types: Drop misleading plural from type descriptions
2022-05-15Revert "lib: init flakes.nix"adisbladis3-23/+0
This reverts commit PR #167947. Flakes aren't standardised and the `lib` namespace shouldn't be polluted with utilities that serve only experimental uses.
2022-05-13lib/tests/modules: Test functionTo submodule merging tooRobert Hensing2-8/+11
2022-05-13lib.types.functionTo: Support type mergingRobert Hensing2-0/+60
2022-05-07lib/strings/toShellVars: handle derivations as stringsNaïm Favier1-0/+12
2022-05-02lib/tests/modules.sh: Fix for singular type descriptionsRobert Hensing1-1/+1
2022-05-02Merge pull request #170090 from danth/has-infix-toStringRobert Hensing1-0/+30
lib/strings: call toString within hasInfix
2022-05-02lib/tests: add tests for hasInfixDaniel Thwaites1-0/+30
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-05-01Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlakeArtturi3-0/+22
lib: add callLocklessFlake
2022-04-28lib.systems: add riscv{32,64} sets and filtersAlyssa Ross1-0/+2
For other platforms like Intel and ARM, we can do e.g. lib.platforms.aarch64 to get only the 64-bit ARM platorms, but until now there were no equivalents for RISC-V.
2022-04-28lib/tests: add RISC-V testAlyssa Ross1-0/+1
2022-04-27lib/strings: add toShellVarsNaïm Favier1-0/+20
A straightforward piece of plumbing to safely inject Nix variables into shell scripts: '' ${lib.toShellVars { inherit foo bar; }} cmd "$foo" --bar "$bar" ''
2022-04-24lib.types.submoduleWith: Avoid _key collisions after extendModulesRobert Hensing2-1/+46
2022-04-12lib/tests: evaluate value from subflake with callLocklessFlakematthewcroughan3-8/+8
2022-04-12lib/tests: use subflake to test callLocklessFlakematthewcroughan3-3/+16
2022-04-12lib/tests: add test for callLocklessFlakematthewcroughan1-0/+9
2022-04-12lib/generators: withRecursion: don't break attr-sets with special attrsMaximilian Bosch1-0/+15
Closes #168327 The issue reported there can be demonstrated with the following expression: → nix-instantiate --eval -E "with import ./. {}; pkgs.lib.options.showDefs [ { file = \"foo\"; value = pkgs.rust.packages.stable.buildRustPackages; } ]" error: attempt to call something which is not a function but a string at /home/ma27/Projects/nixpkgs/lib/trivial.nix:442:35: 441| isFunction = f: builtins.isFunction f || 442| (f ? __functor && isFunction (f.__functor f)); | ^ 443| Basically, if a `__functor` is in an attribute-set at depth-limit, `__functor` will be set to `"<unevaluated>"`. This however breaks `lib.isFunction` which checks for a `__functor` by invoking `__functor` with `f` itself. The same issue - "magic" attributes being shadowed by `withRecursion` - also applies to others such as `__pretty`/`__functionArgs`/`__toString`. Since these attributes have a low-risk of causing a stack overflow (because these are flat attr-sets or even functions), ignoring them in `withRecursion` seems like a valid solution.
2022-04-06Merge pull request #164088 from ↵Silvan Mosberger1-0/+60
Profpatsch/lib.generators-add-toINIWithGlobalSection lib.generators: add toINIWithGlobalSection
2022-04-05Merge pull request #165540 from Infinisil/module-args-docsRobert Hensing1-1/+1
lib/modules: Document `_module.args`
2022-04-05Merge pull request #166383 from hercules-ci/always-sanitize-derivation-nameRobert Hensing1-0/+5
Always sanitize derivation name
2022-04-05lib/modules: Document _module.argsSilvan Mosberger1-1/+1
Documents the _module.args option, motivated by many usages in Flakes, especially with the deprecation of extraArgs (https://github.com/NixOS/nixpkgs/commit/78ada833615d241ed76463aa5a024b614150eb4d) The documentation rendering for this option had to be handled a bit specially, since it's not declared in nixos/modules like all the other NixOS options. Co-Authored-By: pennae <github@quasiparticle.net> Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2022-04-01lib/tests: Add tests for levenshtein functionsSilvan Mosberger1-0/+152
2022-03-31lib.sanitizeDerivationName: Test with unicodeRobert Hensing1-0/+5
2022-03-19Merge pull request #147077 from Infinisil/updateAttrPathsRobert Hensing1-0/+152
Introduce `lib.updateManyAttrsByPath`
2022-03-18lib.attrsets: Introduce updateManyAttrsByPathSilvan Mosberger1-0/+114
2022-03-18lib.lists: Use builtins.groupBy for lib.groupBySilvan Mosberger1-1/+17
builtins.groupBy is much more performant. It was introduced in https://github.com/NixOS/nix/pull/5715
2022-03-18lib.attrsets: Introduce showAttrPathSilvan Mosberger1-0/+22
2022-03-17Merge pull request #161158 from a-m-joseph/mips64el-support-first-stepsJohn Ericson1-2/+2
mips64el support
2022-03-16Merge pull request #156533 from ↵Silvan Mosberger8-0/+87
hercules-ci/issue-146882-transparent-submodule-options lib.modules: Let module declare options directly in bare submodule
2022-03-14lib.generators: add toINIWithGlobalSectionProfpatsch1-0/+60
As discussed in https://github.com/NixOS/nixpkgs/pull/118925#issuecomment-821112723, this is the best way of adding global sections to `toINI` without employing heuristics (i.e. checking whether something is an attrset).
2022-03-10lib/systems: add mips64el definitionsAdam Joseph1-2/+2
MIPS has a large space of {architecture,abi,endianness}; this commit adds all of them to lib/systems/platforms.nix so we can be done with it. Currently lib/systems/inspect.nix has a single "isMips" predicate, which is a bit ambiguous now that we will have both mips32 and mips64 support, with the latter having two ABIs. Let's add four new predicates (isMips32, isMips64, isMips64n32, and isMips64n64) and treat the now-ambiguous isMips as deprecated in favor of the more-specific predicates. These predicates are used mainly for enabling/disabling target-specific workarounds, and it is extremely rare that a platform-specific workaround is needed, and both mips32 and mips64 need exactly the same workaround. The separate predicates (isMips64n32 and isMips64n64) for ABI distinctions are, unfortunately, useful. Boost's user-scheduled threading (used by nix) does does not currently supports mips64n32, which is a very desirable ABI on routers since they rarely have more than 2**32 bytes of DRAM.
2022-03-10lib.types.optionType: Only merge when necessaryRobert Hensing2-0/+17
2022-03-07lib/tests/modules: Add test case for duplicate option error file locationRobert Hensing2-0/+11
2022-03-03lib.modules: Make option injection work when shorthandOnlyDefinesConfigRobert Hensing4-2/+11
2022-03-03lib.modules: Improve option-is-prefix error messageRobert Hensing2-0/+18
2022-03-03lib.modules: Let module declare options directly in bare submoduleRobert Hensing5-0/+49
... 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
2022-03-01lib.modules: Use types.optionType for _module.freeformTypeSilvan Mosberger2-0/+27
This ensures that the module file locations are propagated to the freeform type, which makes it so that submodules in freeform types now have their declaration location shown in the manual, fixing https://github.com/NixOS/nixpkgs/issues/132085. In addition, this also newly allows freeformTypes to be declared multiple times and all declarations being merged together according to normal option merging. This also removes some awkwardness regarding the type of `freeformType`
2022-03-01lib.types: Introduce `types.optionType`Silvan Mosberger3-0/+62
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`
2022-02-22lib/types: Introduce types.raw for unprocessed valuesSilvan Mosberger2-0/+36
2022-02-17lib/tests: Add tests for emptyValueSilvan Mosberger2-0/+45
2021-12-13lib: fix flake checkzimbatm1-1/+1
`builtins.currentSystem` is not available in pure eval. For this particular test, we don't really care since it's all about generating .drv files. Fixes the following error: $ nix flake check warning: unknown flake output 'lib' error: attribute 'currentSystem' missing at /nix/store/8wvnlbjxlr90kq2qa6d9zjpj8rqkilr5-source/lib/tests/misc.nix:499:73: 498| let 499| deriv = derivation { name = "test"; builder = "/bin/sh"; system = builtins.currentSystem; }; | ^ 500| in { (use '--show-trace' to show detailed location informat
2021-12-07Merge pull request #144022 from hercules-ci/lib-modules-optimize-unmatchedDefnsSilvan Mosberger2-2/+16
lib/modules: Short-circuit unmatchedDefns when configs is empty
2021-11-26lib/tests: Use standard test syntaxVictor Engmark1-1/+1
For consistency.
2021-11-26lib/tests: Anchor config output regexesVictor Engmark1-98/+98
Strengthens the tests by making sure the whole line is matched.
2021-11-26lib/tests: Set hardening pragmasVictor Engmark2-4/+8
Makes any programming errors more likely to show up early. Non-obvious changes because of this: - Ignore the `evalConfig` result in `reportFailure`; we're not checking it at that point. - Pre-increment `$fail` and `$pass` to make sure the arithmetic doesn't result in a zero, which would result in a non-zero exit code for the expression.
2021-11-26lib/tests: Don't return non-zero values from checksVictor Engmark1-5/+0
The exit codes aren't used for anything.
2021-11-26lib/tests: Avoid assigning an array to a stringVictor Engmark1-2/+2
As per <https://github.com/koalaman/shellcheck/wiki/SC2124>.
2021-11-26lib/tests: Remove redundant semicolonsVictor Engmark1-6/+6