Commit graph

2960 commits

Author SHA1 Message Date
Adam Joseph 998fd408e0 remove float = "hard" from mips entries 2022-03-10 20:30:18 -08:00
Adam Joseph e748e1fd18 https://github.com/NixOS/nixpkgs/pull/161158#pullrequestreview-903824553 2022-03-10 20:30:18 -08: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
github-actions[bot] 966cf602cc
Merge master into haskell-updates 2022-03-10 00:10:28 +00:00
sternenseemann 47f837f5e8 haskell.compiler: ghc921 -> ghc922
https://www.haskell.org/ghc/download_ghc_9_2_2.html
2022-03-09 16:42:07 +01:00
Robert Hensing 3ddac7a41a lib.isDerivation: Simplify 2022-03-09 15:48:30 +01:00
Robert Hensing 7377ea57ff lib: Add mkRenamedOptionModuleWith
Adds support for sinceRelease
2022-03-09 14:50:51 +01:00
Levi Wright 752a8c516d
lib/systems: Fix uclibc float-abi being flipped
uclibceabihf and uclibceabi's float hardness was flipped, which causes many headaches
2022-03-07 17:05:51 +00:00
Robert Hensing c4b38702e5 lib/modules.nix: Add comment about internal shorthand null value 2022-03-07 11:23:24 +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 e162ed8a14 lib/modules.nix: Move comment to the actual legacy code 2022-03-07 11:21:19 +01:00
Robert Hensing 02de37ca07 lib/modules.nix: Optimize optionSet legacy compat code
It's still in the hot path.
2022-03-07 11:07:50 +01:00
Robert Hensing db08290453 Revert "lib.modules: Remove redundant fixupOptionType in option injection"
This reverts commit 6b077c47ff.

Thanks Infinisil for discovering this problem:

> After a lot of trial and error, trying to prove why fixupOptionType should
> be used here or not, I figured it out: It's needed for the sake of file
> locations in error messages.
2022-03-07 10:59:03 +01:00
Robert Hensing 2050669922 lib.modules: Inline a private function
This should save about four calls per module.
2022-03-03 00:29:15 +01:00
Robert Hensing 28aeae2126 lib.modules: Default shorthandOnlyDefinesConfig to true when null 2022-03-03 00:29:14 +01:00
Robert Hensing 6b077c47ff lib.modules: Remove redundant fixupOptionType in option injection 2022-03-03 00:29:14 +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 81f342d1f3 lib.modules: Explain why options can only be merged into submodules 2022-03-03 00:28:35 +01:00
Robert Hensing 0c09eb343d lib.modules: Refactor option scanning slightly
This scans the options with fewer function calls, improving performance.

It also removes a let Env from the happy flow of the new logic.
2022-03-03 00:28:35 +01:00
Robert Hensing 58a8a48e9d lib.types.submodule: Remove redundant isSubmodule attr 2022-03-03 00:28:35 +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 6bcfd61109
Merge pull request #162283 from Infinisil/functionTo.description
lib/types: Fix functionTo description
2022-03-02 19:42:48 +01:00
Silvan Mosberger c1dfec2be6
Merge pull request #149689 from Infinisil/types-type
Introduce `types.optionType` and use it for `freeformType`
2022-03-02 18:29:44 +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
Silvan Mosberger 5cbeddfde4 lib.types: Introduce types.optionType
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-03-01 19:31:00 +01:00
Silvan Mosberger fb023114ed lib/types: Fix functionTo description 2022-03-01 02:04:35 +01:00
Janne Heß 0c766a100e lib/options: Throw error for options without a type
Makes all options rendered in the manual throw an error if they don't
have a type specified.

This is a follow-up to #76184

Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2022-02-28 22:51:41 +01:00
0x4A6F 3362ff0f7b
Merge pull request #157301 from pennae/lib-add-mkPackageOption
lib: add mkPackageOption to default.nix
2022-02-28 20:37:59 +01:00
Silvan Mosberger ff13cd5d3e lib/modules: Use types.raw for _module.args
Fixes https://github.com/NixOS/nixpkgs/issues/53458, as types.raw
doesn't allow setting multiple values
2022-02-22 15:54:45 +01:00
Silvan Mosberger 665344f148 lib/types: Introduce types.raw for unprocessed values 2022-02-22 15:54:44 +01:00
Silvan Mosberger b333395be5 lib/tests: Add tests for emptyValue 2022-02-17 18:48:30 +01:00
Silvan Mosberger 382289027f lib/types: Fix emptyValue of listOf and nonEmptyListOf
An empty list is [], not {}!

Also, non-empty lists shouldn't have a default of an empty list!
2022-02-17 18:48:27 +01:00
Renaud 980ed8dd76
Merge pull request #155707 from 06kellyjac/feh
feh: correct license
2022-02-16 13:31:43 +01:00
Jonathan Ringer 12fd8a77e1
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/top-level/aliases.nix
2022-02-10 09:21:09 -08:00
John Rinehart 5688e7ff35 fix: typo in lib/attrsets.nix 2022-02-10 01:16:20 +02:00
Jonathan Ringer 46fd0afcb3
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/development/python-modules/pysdl2/default.nix
	pkgs/top-level/aliases.nix
2022-02-06 18:36:59 -08:00
Robert Hensing 8403e02a5d
Merge pull request #126769 from ncfavier/nixosSystem-lib
nixos: move default module location logic to `eval-config.nix`
2022-02-06 22:49:17 +01:00
Jonathan Ringer e680c83323
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/tools/graphics/scrot/default.nix
2022-02-06 10:36:30 -08:00
Jan Tojnar 1e1396aafc lib.sources: Improve docs
Change comment type so than nixdoc picks them up into Nixpkgs manual.
Also improve phrasing a bit and move stuff around so that it is formatted better.
2022-01-30 02:04:51 +01:00
Jan Tojnar 2f012d93ed lib.trivial: Change comment type before concat function
C-style comment was being picked up by nixdoc as a documentation comment for the function.
2022-01-30 02:02:09 +01:00
pennae 1c0918d828 lib: add mkPackageOption to default.nix
this was forgotten in #155669
2022-01-29 18:28:20 +01:00
06kellyjac e98d8f7207 feh: correct license 2022-01-28 14:23:25 +00:00
Naïm Favier 5a07097772
lib/modules: introduce setDefaultModuleLocation
Wraps a module with a default location for reporting errors.
2022-01-27 22:12:53 +01:00
Dmitry Kalinkin 0693fd77f7
Merge branch 'staging-next' into staging
Conflicts:
	nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
	nixos/doc/manual/release-notes/rl-2205.section.md
	pkgs/development/python-modules/aioesphomeapi/default.nix
	pkgs/development/python-modules/mat2/default.nix
	pkgs/development/python-modules/pydevccu/default.nix
	pkgs/development/python-modules/pywlroots/default.nix
	pkgs/development/python-modules/rokuecp/default.nix
2022-01-27 00:54:10 -05:00
Robert Hensing 8919495cac
Merge pull request #156503 from hercules-ci/nixos-add-system.build-options
nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error message
2022-01-25 14:13:24 +01:00
Jonathan Ringer e379e3d4bb
Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
	pkgs/development/python-modules/googleapis-common-protos/default.nix
2022-01-24 23:49:19 -08:00
Thiago Kenji Okada f0e9f54d6e lib/meta: fix typo in platformMatch comment 2022-01-24 12:54:22 -03:00
Alyssa Ross 1a60dd2adc
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/python-modules/cupy/default.nix
	pkgs/development/python-modules/staticjinja/default.nix
2022-01-24 15:39:34 +00:00
Robert Hensing 8691ab3d47 lib.modules: Define mergeOneOption in terms of mergeUniqueOption 2022-01-24 16:23:18 +01:00
Robert Hensing ba3e91ed43 lib.types: Add unique like uniq, but custom errors
Couldn't extend types.uniq and it had a silly name anyway.
Now we can have better error messages.
2022-01-24 16:14:55 +01:00
pennae 865a9ed3f5
Merge pull request #155669 from schuelermine/patch-mkPackageOption
lib/options: Add mkPackageOption
2022-01-24 13:35:32 +00:00
Martin Weinelt 6d2ded1012
Merge pull request #156215 from Atemu/update/svt-av1 2022-01-24 01:30:16 +01:00
Anselm Schüler c008b3d100 nixos/docs/option-declarations: Document mkEnableOption and mkPackageOption
This is a squashed commit. These are the original commit messages:

lib/option: Improve comment

better comment

Update documentation

Updated nixos/doc/manual/development/options-declarations.md with info on mkEnableOption and mkPackageOption.
Updated the comment on mkEnableOption in lib/options.nix

remove trailing whitespace

nixos/doc/option-declarations: Update IDs & formatting

nixos/docs/option-declarations: Escape angle brackets

Build DB from MD

(Amended) Fix typo
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>

(Amended) Build DB from MD (again)
2022-01-23 19:44:21 +01:00
c0bw3b f4d82e40e8 lib.licenses: add MIT-advertising 2022-01-23 18:06:50 +01:00
Anselm Schüler fdf7ede344 lib/options: Add mkPackageOption
This is a squashed commit. These are the original commit messages:

lib/options: Add mkPackageOption

lib/options: Add missing semicolon

lib/options.nix: Make mkPackageOption more complicated

lib/options: Fix indent. & spacing

lib/options.nix: Remove example and align comment

lib/options: ravenous overuse of arguments

lib/options: Format better

lib/options: Add default examplePath decl

lib/options: Make better mkPackageOption function

lib/options: Remove trailing whitespace

lib/options: Improve mkPackageOptions

lib/options: Remove pkgs prefixing
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>

lib/options: Slim down mkPackageOption further

lib/options: mkPackageOption: Add "pkgs." to example

lib/options: mkPackageOption: Make name & pkgs single arguments

lib/options: mkPackageOption: Swap name & pkgs

lib/options: Remove unnecessary import
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
2022-01-23 14:23:03 +01:00
Atemu 52bec72f73 licenses: add Alliance for Open Media Patent License 1.0 2022-01-22 22:15:50 +01:00
c0bw3b 3ec5a9f36b lib.licenses: add Imlib2 2022-01-22 18:50:40 +01:00
Robert Hensing c4a5efa965
Merge pull request #155522 from Julow/single_line_str
types.singleLineStr: strings that don't contain '\n'
2022-01-21 17:39:13 +01:00
Jules Aguillon 1394bfc32a types.singleLineStr: Improve description
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
2022-01-21 09:16:56 +01:00
Jules Aguillon 4baf8548fb types.singleLineStr: Allow and trim trailing \n
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).
2022-01-20 18:49:54 +01:00
sternenseemann 48965506a1 lib/asserts: use throw to display message for assertMsg
`assert` has the annoying property that it dumps a lot of code at the
user without the built in capability to display a nicer message. We have
worked around this using `assertMsg` which would *additionally* display
a nice message. We can do even better: By using `throw` we can make
evaluation fail before assert draws its conclusions and prevent it from
displaying the code making up the assert condition, so we get the nicer
message of `throw` and the syntactical convenience of `assert`.

Before:

    nix-repl> python.override { reproducibleBuild = true; stripBytecode = false; }
    trace: Deterministic builds require stripping bytecode.
    error: assertion (((lib).assertMsg  (reproducibleBuild -> stripBytecode))  "Deterministic builds require stripping bytecode.") failed at /home/lukas/src/nix/nixpkgs/pkgs/development/interpreters/python/cpython/2.7/default.nix:45:1

After:

    nix-repl> python.override { reproducibleBuild = true; stripBytecode = false; }
    error: Deterministic builds require stripping bytecode.
2022-01-19 00:50:06 +01:00
Jules Aguillon f25a13212b types.singleLineStr: Disallow \r 2022-01-18 23:56:50 +01:00
Jules Aguillon df590070b0 types.singleLineStr: strings that don't contain '\n'
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.
2022-01-18 22:06:34 +01:00
pennae 6d44bc5b90
Merge pull request #152392 from polykernel/attrset-optimizations-patch-1
lib/attrset: various function optimizations
2022-01-11 16:01:52 +00:00
Robert Hensing f1c69cb52d
Merge pull request #152046 from pennae/optimize-modules-byName
lib/modules: optimize byName
2022-01-10 14:02:39 +01:00
José Romildo 4fc67da841 lib.checkListOfEnum: init 2022-01-09 19:21:08 -03:00
Robert Hensing c253b04a2f
Merge pull request #151748 from hercules-ci/check-nixpkgs-overlays-type
Check nixpkgs overlays argument types
2022-01-05 12:40:51 +01:00
pennae fc614c37c6 nixos/documentation: split options doc build
most modules can be evaluated for their documentation in a very
restricted environment that doesn't include all of nixpkgs. this
evaluation can then be cached and reused for subsequent builds, merging
only documentation that has changed into the cached set. since nixos
ships with a large number of modules of which only a few are used in any
given config this can save evaluation a huge percentage of nixos
options available in any given config.

in tests of this caching, despite having to copy most of nixos/, saves
about 80% of the time needed to build the system manual, or about two
second on the machine used for testing. build time for a full system
config shrank from 9.4s to 7.4s, while turning documentation off
entirely shortened the build to 7.1s.
2022-01-02 19:46:13 +01:00
pennae 0de4ecff8c lib/modules: extract multiply-used value in byName
module.${attr} is used at least twice, so it must be evaluated at least
twice (and since it's a function argument, be turned into a thunk
twice).
2021-12-28 16:53:50 +01:00
polykernel 63ce7d3184 lib/attrset: miscellaneous optimizations
- Eta reduce `mapAttrsRecursiveCond`, `foldAttrs`, `getAttrFromPath`.
- Modify `matchAttrs` to use `elemAt` instead of `head (tail xs)` to access
  elements.
- Modify `matchAttrs` to use `any id` instead of `foldr and true`.
2021-12-27 22:24:28 -05:00
polykernel a54f2231c9 lib/attrset: optimize element access in recursiveUpdateUntil
- Eta reduce formal arguments of `recursiveUpdate'.
- Access elements in `recursiveUpdateUntil` using `elemAt` and `head`
  directly instead of `head (tail xs)` which copies a singleton unnecessarily.
  (`elemAt` is used instead of `last` to save a primitive call to `length`,
  this is possible because the 2-tuple structure is guranteed)
- Use `length` instead of comparison to empty list to save a copy.
2021-12-27 18:17:52 -05:00
pennae 2dcae7d82f lib/attrsets: use builtins.zipAttrsWith if available 2021-12-25 15:20:26 +01:00
pennae afecbb2f75 lib/modules: optimize byName
the foldl is equivalent to a zip with concat. list concatenation in nix
is an O(n) operation, which makes this operation extremely inefficient
when large numbers of modules are involved.

this change reduces the number of list elements by 7 million on the
system used to write this, total memory spent on lists by 58MB, and
total memory allocated on the GC heap by almost 100MB (with a similar
reduction in GC heap size). it's also slightly faster.
2021-12-25 00:19:44 +01:00
Robert Hensing f2c5c706f4 lib.throwIfNot: init 2021-12-22 13:13:50 +01:00
Graham Christensen 06edb74413
Merge pull request #148785 from pennae/more-option-doc-staticizing
treewide: more defaultText for options
2021-12-17 11:14:08 -05:00
sternenseemann 9066c52e5a lib.systems.supported: remove aarch64-darwin from Tier 3 list
While it is a fact of life that aarch64-darwin is built on Hydra, it has
never formally been elevated from the Tier 7 state it was originally
assigned in RFC 0046. Since platform Tier status is not only
descriptive, but also normative, a consensus to commit to supporting
aarch64-darwin would need to be reached.
2021-12-16 17:51:21 +01:00
zimbatm 22991521eb
lib: fix flake check
`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-13 12:03:40 +01:00
Jörg Thalheim 108ca3d04b
Merge pull request #149924 from Mic92/aarch64be-embedded
pkgsCross.aarch64be-embedded: fix eval
2021-12-09 22:11:37 +00:00
Jörg Thalheim a8c277c8a8 pkgsCross.x86_64-netbsd-llvm: mark as broken 2021-12-09 23:08:40 +01:00
Jörg Thalheim 41a1e7fc36 pkgsCross.ppcle-embedded: fix eval 2021-12-09 22:23:15 +01:00
Jörg Thalheim ce33ed7545 pkgsCross.aarch64be-embedded: fix eval 2021-12-09 21:49:19 +01:00
Silvan Mosberger 6d80d3c964 nixos/modules: Allow options to be coerced to a string for convenience 2021-12-08 21:41:17 +01:00
Silvan Mosberger ae0b7d6db0
Merge pull request #144022 from hercules-ci/lib-modules-optimize-unmatchedDefns
lib/modules: Short-circuit unmatchedDefns when configs is empty
2021-12-07 19:38:43 +01:00
Silvan Mosberger d2c50190b7
Merge pull request #141856 from ShamrockLee/lib-spdx-license
lib/meta: add getLicenseFromSpdxId function (resumed)
2021-12-07 18:37:13 +01:00
Robert Hensing 260b941dd0 lib/modules: Deprecate args and check 2021-12-02 18:23:43 +00:00
Robert Hensing b37f099ae7 lib/modules: Pass legacy args argument along through extendModules 2021-12-02 17:45:48 +00:00
Shamrock Lee 60950f739e lib/meta: add getLicenseFromSpdxId function
Move function spdxLicense, internally used in yarn2nix
to lib/meta.nix, and
rename to getLicenseFromSpdxId

A similar function is implemented in poetry2nix,
but the one originally in yarn2nix seems beter.
since it falls back to an license-like attrset
for mismatched case
instead of a plain string
2021-12-02 18:33:48 +08:00
Victor Engmark 44a15ab801 lib/tests: Use standard test syntax
For consistency.
2021-11-26 11:03:40 +13:00
Victor Engmark b8f8589e9a lib/tests: Anchor config output regexes
Strengthens the tests by making sure the whole line is matched.
2021-11-26 11:02:41 +13:00
Victor Engmark 989f034ff1 lib/tests: Set hardening pragmas
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-26 10:55:14 +13:00
Victor Engmark bfc580f54f lib/tests: Don't return non-zero values from checks
The exit codes aren't used for anything.
2021-11-26 10:52:28 +13:00
Victor Engmark 40ae711f73 lib/tests: Avoid assigning an array to a string
As per <https://github.com/koalaman/shellcheck/wiki/SC2124>.
2021-11-26 10:52:27 +13:00
Victor Engmark 04223a0d43 lib/tests: Remove redundant semicolons 2021-11-26 10:51:56 +13:00
Victor Engmark 41fd1d8626 lib/tests: Clarify assignment
The extra equal sign was confusing, and doesn't seem to be relevant.
2021-11-26 10:51:12 +13:00
Victor Engmark 5e85cd86af lib/tests: Use correct shebang line
The script uses plenty of non-POSIX features, such as referencing
`$BASH_SOURCE`.
2021-11-26 10:51:12 +13:00
Victor Engmark 40d1c87bea lib/tests: Quote variable references 2021-11-26 10:51:12 +13:00
Victor Engmark 6d53055cb7 lib/tests: export separately from assignment
Avoids hiding the exit code from the assignment. See
<https://github.com/koalaman/shellcheck/wiki/SC2155>.
2021-11-26 09:30:10 +13:00
Timothy DeHerrera 2768bc07f7
add release notes for 22.05 and update codename 2021-11-22 15:10:53 -07:00
Robert Hensing d464ccfdd9 modules: Add moduleType to module arguments 2021-11-22 16:50:50 +01:00
Robert Hensing 426ab31fde modules: Document that extendModules is also a module argument 2021-11-22 16:10:18 +01:00
Taeer Bar-Yam 0bef0c38f7 lib.modules: add mkDerivedConfig
mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b

Create config definitions with the same priority as the definition of another option.
This should be used for option definitions where one option sets the value of another as a convenience.
For instance a config file could be set with a `text` or `source` option, where text translates to a `source`
value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.

It takes care of setting the right priority using `mkOverride`.
2021-11-15 07:03:41 -05:00
Jonathan Ringer dbe6e96d0a
lib/systems: add x86_64-darwin hostPlatform 2021-11-10 11:37:34 -08:00
Bernardo Meurer 90c1cdd93f
lib/tests/sources: update to Nix 2.4 cli syntax 2021-11-09 10:47:20 -08:00
Bernardo Meurer fd4390146e
lib/tests/modules.sh: update to Nix 2.4 syntax 2021-11-09 10:47:19 -08:00
Robert Hensing 844a9e746f lib/modules: Use strict fold' as recursiveUpdate is also strict
recursiveUpdate does not produce an attrset until it has evaluated
both its arguments to weak head normal form.

    nix-repl> lib.recursiveUpdate (throw "a") (throw "b")
    error: b

    nix-repl> lib.recursiveUpdate (throw "a") {}
    error: a
2021-11-03 19:47:03 +01:00
Robert Hensing 541ce53a3b lib/modules: Fix import* comments
Very confusing otherwise.
2021-11-03 19:39:31 +01:00
Robert Hensing 8b584158a5 lib/modules: Remove a lib.flip
In hot code, the overhead (envs, applies) can matter.
2021-11-03 19:34:27 +01:00
Robert Hensing e8d61a25fc lib/tests/modules: Test non-strictness some more
Doesn't seem to have been a problem actually, but now it won't
regress.
2021-11-03 19:19:41 +01:00
Robert Hensing bfaa9426c0 lib/modules: Short-circuit unmatchedDefns earlier 2021-11-03 19:05:26 +01:00
Robert Helgesson c7678aff1b
lib: fix escapeXML example in documentation
The previous example output was forgotten copy-paste from some other
function.
2021-11-02 22:43:25 +01:00
Ben Siraphob 481afad265
Merge pull request #144072 from polykernel/lib-lists-mutuallyexclusive-optimization 2021-11-02 02:46:27 -05:00
polykernel cd6397519f lib/lists: mutuallyExclusive function optimization
The current implementation of `mutuallyExclusive` builds a new list with
length subtracted by one on every recursive call which is expensive. When
b is empty, the function still traverses a in its entirety before returning
a result.

The new implementation uses `any` to check if each element of list b is in
list a using `elem`. This maintains short circuiting when list a or b is empty
and has a worst case time complexity of O(nm).
2021-11-01 16:29:01 -04:00
Robert Hensing 86f5136baf modules: Update evalModules doc 2021-11-01 09:38:51 +01:00
Robert Hensing 64dfd983df modules: Add visible = "shallow" to hide only sub-options 2021-11-01 09:34:07 +01:00
Robert Hensing 27644a82a9 modules: Add extendModules to module args 2021-11-01 09:34:07 +01:00
Robert Hensing dece37b83a lib.evalModules: Add extendModules and type to result
Allows the simultaneous construction of top-level invocations and
submodule types.

This helps structure configuration systems integration code.
2021-11-01 09:34:07 +01:00
Robert Hensing d6ebd537e5 lib/modules: Short-circuit unmatchedDefns when configs is empty 2021-10-31 22:28:42 +01:00
Ryan Burns 81ee86a2c6
Merge pull request #139284 from r-burns/powernv-kernel-config
lib/systems: update powernv kernel config
2021-10-28 13:53:16 -07:00
Silvan Mosberger 98f82e9c35
Merge pull request #141789 from pennae/eval-opt
lib: make extendDerivation lighter on eval
2021-10-21 20:17:32 +02:00
Markus S. Wamser 8e394b8533 licenses: add CAPEC 2021-10-15 23:10:34 +02:00
pennae dc895fb281 lib: make extendDerivation lighter on eval
the fix to extendDerivation in #140051 unwittingly worsened eval performance by
quite a bit. set elements alone needed over 1GB extra after the change, which
seems disproportionate to how small it was. if we flip the logic used to
determine which outputs to install around and keep a "this one exactly" flag in
the specific outputs instead of a "all of them" in the root we can avoid most
of that cost.
2021-10-15 16:39:10 +02:00
Robert Hensing a541ce1fe7
Merge pull request #140763 from hercules-ci/abort-on-warn
lib.warn: Add NIX_ABORT_ON_WARN for call traces
2021-10-13 22:43:39 +02:00
Robert Hensing c9b7cc79e6 lib.warn: Add NIX_ABORT_ON_WARN for call traces 2021-10-13 22:43:06 +02:00
zimbatm 60d3ef0484
lib.systems.supported.tier3: add aarch64-darwin
aarch64-darwin is getting built by hydra
2021-10-06 17:27:32 +02:00
Silvan Mosberger d193e632bc
Merge pull request #140284 from Infinisil/types-anything-lambdas
lib/types: Make types.anything merge functions
2021-10-05 13:50:42 +02:00
Jonas Chevalier 8377a7bca9
lib: add list of supported systems (#140428)
Adds the first 3 tiers of RFC0046 that are being used in flake.nix.
2021-10-05 11:14:47 +02:00
Robert Hensing 0699530f08
Merge pull request #136909 from ncfavier/cleanup-defaults-examples
nixos/doc: clean up defaults and examples
2021-10-04 20:37:42 +02:00
Michele Guerini Rocco dd7cbf0c59
Merge pull request #140136 from rnhmjoj/matrix-ids
maintainers/maintainers-list: add Matrix IDs
2021-10-03 23:40:49 +02:00
Naïm Favier 52a2e4136e
lib/options: add literalExpression and literalDocBook, deprecate literalExample 2021-10-03 17:19:19 +02:00
Robert Helgesson e75f346aa3
lib: add function escapeXML
Given a string, this function returns a string that can be inserted
verbatim in an XML document.
2021-10-03 11:28:03 +02:00
Silvan Mosberger 243a61e183
Merge pull request #140051 from pennae/extend-derivation
fix nested calls to extendDerivation
2021-10-02 17:03:24 +02:00
Silvan Mosberger 48293bd6b6 lib/types: Make types.anything merge functions
Previously it would give an error if there were multiple function
definitions.
2021-10-02 16:37:22 +02:00
rnhmjoj 35841653e1
lib/tests/maintainers: add matrix option 2021-10-01 21:27:00 +02:00
Delta 48eba3e35c ocamlPackages.lustre-v6: init at 6.103.3 2021-09-30 21:38:06 +02:00
pennae 9b3b8f74bb fix nested calls to extendDerivation
if extendDerivation is called on something that already had extendDerivation
called on it (eg a mkDerivation result) the second call will set
outputUnspecified=true on every output by way of propagating attributes of the
full derivation to the individual outputs. this in turn causes buildEnv--and
thus nix-shell and environment.systemPackages--to install every output of such a
derivation even when only a specific output was requested, which renders the
point of multiple outputs moot. this happens in python modules (see #139756),
though it seems that tcl and possibly others should also be affected.
2021-09-30 17:34:07 +02:00
Linus Heckemann a3df3d05e5
Merge pull request #131205 from Ma27/showdefs-overflow
lib/modules: improve errors for `options`/`config`-mixups
2021-09-29 11:03:31 +02:00
Ryan Burns 288cc2007b lib/systems: update powernv kernel config
PowerNV was looking for a nonexisting zImage file.
Remove unnecessary .file / .installTarget.

Also add config options needed for default minimal
NixOS config and QEMU VirtIO/VirtFS devices.
2021-09-28 17:41:13 -07:00
Maximilian Bosch 681758d415
lib/generators: fix error message 2021-09-28 22:26:51 +02:00
Alyssa Ross f446318916
lib.cleanSource: ignore sockets
I'm working on a project that involves running a virtual machine
monitor program, which creates a control socket in the project
directory (because it doesn't make sense to put it anywhere else).
This obviously isn't part of the source of my program, so I think
cleanSource should filter it out.
2021-09-17 10:03:00 +00:00
zimbatm f882fbcee0
lib.generators.toINI: serialize derivations to string
This is the common case when passing a derivation, we want to access the
store path.
2021-09-12 06:26:21 +02:00
zimbatm 9e90a400a5
lib.generators.toGitINI: don't traverse derivations
Consider a derivation a value to be serialized.

    nix-repl> lib.generators.toGitINI { hello = { drv = pkgs.hello; }; }
    error: evaluation aborted with the following error message: 'generators.mkValueStringDefault: attrsets not supported: <derivation /nix/store/533q15q67sl6dl0272dyi7m7w5pwkkjh-hello-2.10.drv>'

Fixes #137390
2021-09-12 06:26:20 +02:00
Sergei Trofimovich 34e468dc42 lib/systems: add minimal s390x-linux cross-compile support
Tested basic functionality as:

    $ nix-build --arg crossSystem '{ config = "s390x-unknown-linux-gnu"; }' -A re2c
    $ file ./result/bin/re2c
    $ ./result/bin/re2c: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV),
    dynamically linked, interpreter ...-gnu-2.33-50/lib/ld64.so.1, for GNU/Linux 2.6.32, not stripped
    $ qemu-s390x ./result/bin/re2c --version
    re2c 2.2
2021-09-09 10:58:47 +00:00
polykernel de81edf6ef lib/strings: fix infinite recursion on concatStringsSep fallback
The current implementation of the concatStringsSep fallback references
concatStrings whcih is just a partial application of concatStringsSep,
forming a circular dependency. Although this will almost never be
encountered as (assuming the user does not explicitly trigger it):
  1. the or operator will short circuit both in lazy and strict
     evaluation
  2. this can only occur in Nix versions prior to 1.10
     which is not compatible with various nix operations as of 2.3.15

However it is still important if scopedImport is used or the builtins
have been overwritten. lib.foldl' is used instead of builtins.foldl'
as the foldl' primops was introduced in the same release as concatStringsSep.
2021-08-26 20:08:05 -04:00
Robert Hensing cdf0aa2907
Merge pull request #135794 from shlevy/composeManyFlakeCompat
lib.compose{Many,}Extensions: Make compatible with nix flake check
2021-08-26 16:37:09 +02:00
Paul-Nicolas Madelaine fa61f7635d replace dead links 2021-08-26 23:14:50 +09:00
Shea Levy d09222e48f
lib.compose{Many,}Extensions: Make compatible with nix flake check 2021-08-26 09:12:17 -04:00
Maximilian Bosch b96101a35f
lib/modules: grammar fix in error msg 2021-08-26 00:37:33 +02:00
Maximilian Bosch 5773ae93f7
lib/generators: move limit detection into withRecursion
As suggested in #131205.

Now it's possible to pretty-print a value with `lib.generators` like
this:

    with lib.generators;
    toPretty { }
      (withRecursion { depthLimit = 10; } /* arbitrarily complex value */)

Also, this can be used for any other pretty-printer now if needed.
2021-08-26 00:28:49 +02:00