Commit Graph

231 Commits

Author SHA1 Message Date
Graham Christensen
9ed793229c teams/maintainers list: show instructions for validating the contents 2022-06-20 22:20:26 +02:00
Graham Christensen
ff38ee15c2 maintainer teams: check them in lib tests 2022-06-20 22:20:26 +02:00
Graham Christensen
3ac995a568 maintainer lib test: extract maintainer module 2022-06-20 22:20:26 +02:00
Graham Christensen
c8cebff38b maintainers: remove longkeyid
see https://dkg.fifthhorseman.net/blog/openpgp-key-ids-are-not-useful.html
2022-06-20 22:20:26 +02:00
Robert Hensing
3c4a49f506 lib/modules: Throw earlier when module function does not return attrs
`m` must always be an attrset at this point. It is basically always
evaluated. This will make it throw when any of the attrs is accessed,
rather than just `config`. We assume that this will improve the error
message in more scenarios.
2022-06-14 23:23:41 +02:00
Robert Hensing
dfd98a5da2 lib.deferredModule: Make it properly singular 2022-06-14 23:01:27 +02:00
Robert Hensing
781c2e0789 lib.types.deferredModule: Allow path-typed module references 2022-06-14 23:01:26 +02:00
Robert Hensing
a2c29561e7 lib.types.deferredModule: Improve reported location 2022-06-14 23:01:26 +02:00
Robert Hensing
38b7709a6f lib/test/modules.sh: Test deferredModule error location file 2022-06-14 23:01:26 +02:00
Robert Hensing
4746f6d03e lib.types: Add deferredModule 2022-06-14 23:01:23 +02:00
Silvan Mosberger
79441600c2 lib/tests: Add submodule file propagation test 2022-06-14 17:01:58 +02:00
Silvan Mosberger
4b2827e6a1
Merge pull request #168374 from Ma27/special-attrs-in-with-recursion
lib/generators: withRecursion: don't break attr-sets with special attrs
2022-05-23 17:55:18 +02:00
Robert Hensing
2d1a34b8cc
Merge pull request #172813 from hercules-ci/functionTo-properly
`lib.types.functionTo` type merging and docs
2022-05-17 22:22:21 +02:00
Silvan Mosberger
e06f66e73c
Merge pull request #170561 from klemensn/types-description
lib/types: Drop misleading plural from type descriptions
2022-05-16 17:03:37 +02:00
adisbladis
161776ec1e Revert "lib: init flakes.nix"
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-15 22:39:46 +12:00
Robert Hensing
81a0a8be29 lib/tests/modules: Test functionTo submodule merging too 2022-05-13 09:09:16 +02:00
Robert Hensing
06da97fc3a lib.types.functionTo: Support type merging 2022-05-13 09:01:05 +02:00
Naïm Favier
4d2ea62d82
lib/strings/toShellVars: handle derivations as strings 2022-05-07 17:01:51 +02:00
Robert Hensing
9252a7daa8 lib/tests/modules.sh: Fix for singular type descriptions 2022-05-02 10:41:47 +02:00
Robert Hensing
761c21a16a
Merge pull request #170090 from danth/has-infix-toString
lib/strings: call toString within hasInfix
2022-05-02 09:47:15 +02:00
Daniel Thwaites
7b5be1a0f8 lib/tests: add tests for hasInfix
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-05-02 09:05:56 +02:00
Artturi
a5357d06e4
Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlake
lib: add callLocklessFlake
2022-05-01 23:06:17 +03:00
Alyssa Ross
2a6288d9b9 lib.systems: add riscv{32,64} sets and filters
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-28 08:17:02 +00:00
Alyssa Ross
ed24c902d0 lib/tests: add RISC-V test 2022-04-28 08:17:02 +00:00
Naïm Favier
226bc99659
lib/strings: add toShellVars
A straightforward piece of plumbing to safely inject Nix variables into
shell scripts:

''
  ${lib.toShellVars { inherit foo bar; }}
  cmd "$foo" --bar "$bar"
''
2022-04-27 16:04:17 +02:00
Robert Hensing
224426ba6d lib.types.submoduleWith: Avoid _key collisions after extendModules 2022-04-24 00:07:59 +02:00
matthewcroughan
3f128cc024 lib/tests: evaluate value from subflake with callLocklessFlake 2022-04-12 21:22:36 +01:00
matthewcroughan
ec59145c3b lib/tests: use subflake to test callLocklessFlake 2022-04-12 20:38:55 +01:00
matthewcroughan
cc052779fb lib/tests: add test for callLocklessFlake 2022-04-12 19:47:48 +01:00
Maximilian Bosch
7203788068
lib/generators: withRecursion: don't break attr-sets with special attrs
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-12 12:34:23 +02:00
Silvan Mosberger
180173a1c4
Merge pull request #164088 from Profpatsch/lib.generators-add-toINIWithGlobalSection
lib.generators: add toINIWithGlobalSection
2022-04-06 19:02:36 +02:00
Robert Hensing
c705953267
Merge pull request #165540 from Infinisil/module-args-docs
lib/modules: Document `_module.args`
2022-04-05 21:51:46 +02:00
Robert Hensing
559ac3c9e7
Merge pull request #166383 from hercules-ci/always-sanitize-derivation-name
Always sanitize derivation name
2022-04-05 20:05:33 +02:00
Silvan Mosberger
25de2935ef lib/modules: Document _module.args
Documents the _module.args option, motivated by many usages in Flakes,
especially with the deprecation of extraArgs
(78ada83361)

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-05 18:26:40 +02:00
Silvan Mosberger
f8c1aee5da lib/tests: Add tests for levenshtein functions 2022-04-01 22:03:05 +02:00
Robert Hensing
2999ab114e lib.sanitizeDerivationName: Test with unicode 2022-03-31 18:31:11 +02:00
Robert Hensing
5ff918bf55
Merge pull request #147077 from Infinisil/updateAttrPaths
Introduce `lib.updateManyAttrsByPath`
2022-03-19 19:00:03 +01:00
Silvan Mosberger
85003ecdbb lib.attrsets: Introduce updateManyAttrsByPath 2022-03-18 00:08:29 +01:00
Silvan Mosberger
1ad7812c4a lib.lists: Use builtins.groupBy for lib.groupBy
builtins.groupBy is much more performant. It was introduced in
https://github.com/NixOS/nix/pull/5715
2022-03-18 00:05:10 +01:00
Silvan Mosberger
71b130c581 lib.attrsets: Introduce showAttrPath 2022-03-18 00:05:08 +01:00
John Ericson
111839dcf6
Merge pull request #161158 from a-m-joseph/mips64el-support-first-steps
mips64el support
2022-03-17 17:43:24 -04:00
Silvan Mosberger
b97742c66c
Merge pull request #156533 from hercules-ci/issue-146882-transparent-submodule-options
lib.modules: Let module declare options directly in bare submodule
2022-03-16 21:44:35 +01:00
Profpatsch
ab03ddc8f4 lib.generators: add toINIWithGlobalSection
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-14 10:21:15 +01:00
Adam Joseph
12371a51e6 lib/systems: add mips64el definitions
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-10 20:30:16 -08:00
Robert Hensing
55ee7ab4a6 lib.types.optionType: Only merge when necessary 2022-03-10 20:25:49 +01:00
Robert Hensing
c90844aeb9 lib/tests/modules: Add test case for duplicate option error file location 2022-03-07 11:21:23 +01:00
Robert Hensing
8baea8b82c lib.modules: Make option injection work when shorthandOnlyDefinesConfig 2022-03-03 00:29:14 +01:00
Robert Hensing
11537c9c02 lib.modules: Improve option-is-prefix error message 2022-03-03 00:29:11 +01:00
Robert Hensing
d030e2109f lib.modules: Let module declare options directly in bare submodule
... 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-03 00:28:35 +01:00
Silvan Mosberger
023fa7b923 lib.modules: Use types.optionType for _module.freeformType
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-01 19:31:02 +01:00