Commit graph

2523 commits

Author SHA1 Message Date
Silvan Mosberger 8dea4df903
lib/modules: Remove _module.checks.*.triggerPath as it's not necessary
Previously this option was thought to be necessary to avoid infinite
recursion, but it actually isn't, since the check evaluation isn't fed
back into the module fixed-point.
2020-11-30 23:51:42 +01:00
Silvan Mosberger c9cc8969b4
lib/modules: Rename _module.assertions to _module.checks 2020-11-30 23:51:41 +01:00
Silvan Mosberger 3e39d6efdf
lib/tests: Add tests for module-builtin assertions 2020-11-30 23:51:23 +01:00
Silvan Mosberger 900c4a5abd
lib/tests: Implement generalized checkConfigCodeOutErr for module tests 2020-11-30 23:51:23 +01:00
Silvan Mosberger 3759a77fcd
nixos/modules: Expose the internal module in the top-level documentation 2020-11-30 23:51:23 +01:00
Silvan Mosberger 1e6a84b7af
nixos/modules: Allow options to be coerced to a string for convenience 2020-11-30 23:51:23 +01:00
Silvan Mosberger 20131348db
lib/modules: Use module-builtin assertions for mkRemovedOptionModule and co. 2020-11-30 23:51:23 +01:00
Silvan Mosberger 9523df7eb6
nixos/assertions: Use module-builtin assertion implementation 2020-11-30 23:51:22 +01:00
Silvan Mosberger df5ba82f74
lib/modules: Implement module-builtin assertions
This implements assertions/warnings supported by the module system directly,
instead of just being a NixOS option (see
nixos/modules/misc/assertions.nix).

This has the following benefits:
- It allows cleanly redoing the user interface. The new
  implementation specifically allows disabling assertions or
  converting them to warnings instead.
- Assertions/warnings can now be thrown easily from within
  submodules, which previously wasn't possible and needed workarounds.
2020-11-30 23:51:19 +01:00
Silvan Mosberger 0b61ed7af9
lib/options: Don't show internal suboption in the manual
Initially https://github.com/NixOS/nixpkgs/pull/82897 prevented
non-visible options from being rendered in the manual, but
visible-but-internal options were still being recursed into. This fixes
this, aligning the recurse condition here with the one in
make-options-doc/default.nix
2020-11-30 22:51:34 +01:00
Silvan Mosberger e08182020c
Merge pull request #99115 from Infinisil/toString-module-files
lib/modules: Make sure to not import module _file's into the store
2020-11-30 21:00:59 +01:00
Sandro 97cce3214f
Merge pull request #103884 from djanatyn/pkg/xlife 2020-11-26 01:55:25 +01:00
John Ericson d19b920c60
Merge pull request #102503 from siraben/remarkable-init
Initial implementation of remarkable1 cross-compile
2020-11-24 10:03:54 -05:00
adisbladis 85605c8a29
lib.lists.unique: Switch from recursive function to using a fold
This improves performance by ~30-40% for smaller test cases and makes
larger cases where my laptop would OOM pass in seconds.
2020-11-24 14:31:54 +01:00
Ben Siraphob 77e00150ba Initial implementation of remarkable1 cross-compile 2020-11-23 21:18:54 +07:00
John Ericson a6218c058b lib: Create makeScopeWithSplicing
It's ugly as hell, but I suppose it is needed to codify how to make
spliced package sets.
2020-11-19 00:07:14 -05:00
Frederik Rietdijk 986c2d36da Merge master into staging-next 2020-11-16 09:01:53 +01:00
Jonathan Strickland 986e9cfd6c licenses: add HPND-sell-variant 2020-11-15 03:11:05 -05:00
John Ericson 86fedc3a92
Merge pull request #102766 from siraben/mmix
Initial implementation of cross-compilation to Knuth's MMIX
2020-11-14 12:46:24 -05:00
Joe Hermaszewski c3b35f21f7 lib: Add composeManyExtensions 2020-11-13 21:37:57 +01:00
Frederik Rietdijk 4076ffe580 Merge staging-next into staging 2020-11-11 16:00:34 +01:00
Eelco Dolstra f9dd8f04a0
Merge pull request #44928 from vcunat/p/configure-assert
lib/strings: guard against an easy mistake
2020-11-11 11:14:12 +01:00
Samuel Dionne-Riel 6d8327ea96 Initial support for OpenRISC 1000 (or1k) 2020-11-09 22:32:11 -05:00
Ben Siraphob 445dde6304 Initial implementation of mmix cross-compile 2020-11-09 19:49:55 +07:00
V 3e1652f8f0 lib/sources.nix: fix incorrect inherit
split comes from builtins, not lib.

	error: attribute 'split' missing, at /nix/path/nixpkgs/lib/sources.nix:4:4
	(use '--show-trace' to show detailed location information)
2020-10-30 23:19:22 +01:00
Keshav Kini a456ccb0c8 lib/types.nix: fix missing inherit
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
2020-10-26 00:50:06 -07:00
Robert Hensing 7102388834
Merge pull request #101139 from roberth/lib-use-static-scope-checking
lib: Use Nix's static scope checking, fix error message, optimize
2020-10-26 06:59:17 +01:00
Gabriel Ebner a8a018ddc0
Merge pull request #101409 from rycee/dbus-warning 2020-10-25 09:16:28 +01:00
Andreas Rammhold 250fb4611f
Merge pull request #100456 from maralorn/boolToString
treewide: De-inline uses of lib.boolToString
2020-10-25 00:45:11 +02:00
Robert Helgesson e0fa72d04d
docs: update documentation of mkRemovedOptionModule
Since b08b0bcbbe, the function actually
causes an assertion error, not a warning.
2020-10-24 23:01:01 +02:00
Robert Hensing a4019a40b3 lib/sources.nix: Prefer lib for readFile inherit 2020-10-22 13:57:23 +02:00
Robert Hensing fe4a58eec0 lib: Add lib.trace for consistency
This puts it among the trace* family of functions derived from it.
2020-10-22 13:46:48 +02:00
Robert Hensing f8ab5fcd8d lib/modules: Simplify inherits 2020-10-22 13:46:48 +02:00
Robert Hensing 9a4bed1a80 lib: Add lib.isFloat for consistency
Unlike the other three is* functions in lib.trivial, it was only
available as lib.trivial.isFloat
2020-10-22 13:46:48 +02:00
Robert Hensing c9f8f66248 lib/options.nix: Use merge-friendly inherit syntax 2020-10-22 13:46:48 +02:00
Robert Hensing afa6c51f27 lib: Use Nix's static scope checking, fix error message, optimize
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.
2020-10-22 13:46:47 +02:00
Robert Hensing 5aa2a98dfa lib/types.nix: Use // instead of mergeAttrs 2020-10-22 13:46:47 +02:00
Robert Hensing 4d4682c2b6 lib/options.nix: Use head instead of elemAt _ 0 2020-10-22 13:46:47 +02:00
Silvan Mosberger a2fe9a7abc
Merge pull request #100953 from AtnNn/splitStrings
Implement splitString using builtins.split
2020-10-20 22:12:52 +02:00
Farid Zakaria 5f1d1bc57e lib: Add readTree function to filesystem
Add a friendly function to easily return a flattened list of files
within a directory.

This is useful if you want to easily iterate or concatSep the list of
files all found within a directory.
(i.e. when constructing Java's CLASSPATH)

Style improvements

Co-authored-by: Silvan Mosberger <github@infinisil.com>
2020-10-19 16:42:21 -07:00
Etienne Laurin d7464ab4bb lib.splitString: use builtin.split 2020-10-18 13:19:50 +00:00
Malte Brandy cebf9198f3
treewide: De-inline uses of lib.boolToString
This commit should not change eval results
2020-10-14 01:46:17 +02:00
Vladimír Čunát 338b25697c
Merge branch 'master' into staging-next
Quite many rebuilds from master:
> Estimating rebuild amount by counting changed Hydra jobs.
>    3926 x86_64-darwin
>    4645 x86_64-linux
2020-10-10 11:32:10 +02:00
zimbatm d8e4c8e612
Merge pull request #96641 from zimbatm/data-module-imports
nixos: Data module imports
2020-10-09 17:07:51 +00:00
Frederik Rietdijk 692d219a93 Merge staging-next into staging 2020-10-06 10:25:58 +02:00
Silvan Mosberger 769eac0740
lib/modules: Make sure to not import module _file's into the store
Previously if `_file` was specified by a module:
  trace: warning: The type `types.string' of option `foo' defined in `/nix/store/yxhm2il5yrb92fldgriw0wyqh2kk9qyc-bug.nix' is deprecated. See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types.

With this change:
  trace: warning: The type `types.string' of option `foo' defined in `/home/infinisil/src/nixpkgs/bug.nix' is deprecated. See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types.
2020-09-29 22:47:58 +02:00
Jan Tojnar d471c5d1f3
Merge branch 'staging-next' into staging 2020-09-24 23:09:00 +02:00
Frederik Rietdijk 7bff759fac Merge staging-next into staging 2020-09-22 18:31:56 +02:00
Silvan Mosberger 8908766165
lib/tests: Update for error message changes 2020-09-21 18:24:55 +02:00
Silvan Mosberger 4f0982b223
lib/tests: Allow grepping for newlines in error messages 2020-09-21 18:24:54 +02:00