Commit Graph

2497 Commits

Author SHA1 Message Date
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
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
Silvan Mosberger
910dfdc41e
lib/modules: Evaluate single defs for readOnly error
If multiple definitions are passed, this evaluates them all as if they
were the only one, for a better error message. In particular this won't
show module-internal properties like `_type = "override"` and co.
2020-09-21 18:24:52 +02:00
Silvan Mosberger
bdfcee2590
lib/modules: Improve error messages using showDefs 2020-09-21 18:24:52 +02:00
Silvan Mosberger
7c20e68f6b
lib/options: Introduce showDefs
For pretty-printing definitions, including file and values
2020-09-21 18:24:50 +02:00
Silvan Mosberger
2ff7c3e2e1
lib/types: Remove unreachable if branch
The type's check function already ensured that it can't be passed
non-lists
2020-09-21 17:13:06 +02:00
Silvan Mosberger
366a677dbb
Merge pull request #97133 from Infinisil/improved-toPretty
Improve `generators.toPretty`
2020-09-21 17:11:49 +02:00
Robert Hensing
f3893d8b53
Merge pull request #97119 from Infinisil/types.anything
Introduce `types.anything`
2020-09-21 08:49:24 +02:00
WORLDofPEACE
34aaac6d7c Merge branch 'staging-next' into staging 2020-09-20 18:41:15 -04:00
Gabriel Ebner
de3cc475e0
Merge pull request #81014 from fgaz/platforms/endianness
platforms: add bigEndian and littleEndian
2020-09-20 17:03:55 +02:00
Francesco Gazzetta
4fc8c5098d platforms: add bigEndian and littleEndian 2020-09-20 16:12:58 +02:00
Silvan Mosberger
15c5ba9d28
lib/generators.toPretty: functors should print as functions
Not attribute sets. So move the function case forward
2020-09-17 18:20:43 +02:00
Silvan Mosberger
05e4d371ef
lib/generators.toPretty: Print [] and {} compactly 2020-09-17 18:20:39 +02:00
Silvan Mosberger
d0be9e9810
lib/generators.toPretty: Switch away from δ and λ
- These symbols can be confusing for those not familiar with them
- There's no harm in making these more obvious
- Terminals may not print them correctly either

Also changes the function argument printing slightly to be more obvious
2020-09-17 18:20:35 +02:00
Silvan Mosberger
073e9b2aed
lib/generators.toPretty: Improved string printing, handling newlines 2020-09-17 18:20:31 +02:00
Silvan Mosberger
47f2eb89c1
lib/generators.toPretty: Implement multiline printing 2020-09-17 18:20:25 +02:00
Silvan Mosberger
4811f54e94
lib/generators.toPretty: Wrap in a go function
As a preparation to the following commit
2020-09-17 18:20:18 +02:00
Silvan Mosberger
0f6231702f
lib/generators.toPretty: Only quote attribute names if necessary 2020-09-17 18:20:08 +02:00
Silvan Mosberger
6a7d250007
lib/tests: Add tests for types.anything 2020-09-15 21:06:05 +02:00
Silvan Mosberger
67551f46fb
lib/types: Introduce types.anything
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
2020-09-15 21:01:07 +02:00
Silvan Mosberger
6e7bc2c6c9
lib/options: Fix mergeEqualOption for singular functions
Previously it would error out for a single function definition
2020-09-15 21:01:07 +02:00
Vladimír Čunát
4cf1247851
Merge branch 'staging-next' into staging 2020-09-13 08:21:17 +02:00
Geoffrey Huntley
bc62fff2cf
lib.licenses: add Prosperity-3.0.0 license (#97832) 2020-09-12 22:13:27 +02:00
zimbatm
035627dff2
lib: allow to import JSON and TOML files
The vision here is that configuration tools can generate .json or .toml
files, which can be plugged into an existing configuration.

Eg:

    { lib, ... }:
    {
      imports = [
        (lib.modules.importJSON ./hardware-configuration.json)
      ];
    }
2020-09-12 16:37:50 +02:00
zimbatm
947a7d33f9
lib: add importTOML
Complements the `lib.importJSON`. `builtins.readTOML` has been
introduced in Nix 2.1.
2020-09-12 16:37:50 +02:00
Frederik Rietdijk
37d29394ec Merge staging-next into staging 2020-09-12 10:00:45 +02:00
Matthew Bauer
86d8c55470
Merge branch 'staging' into ios-13 2020-09-10 23:24:26 -05:00