Commit graph

2903 commits

Author SHA1 Message Date
Ryan Burns 525c69e724 lib/systems: fix scaleway-c1 platform
This regressed in 9c213398b3

The recursiveUpdate gave the platform both gcc.cpu and gcc.arch attrs
instead of only gcc.cpu. This is invalid; gcc configuration fails with:

```
Switch "--with-arch" may not be used with switch "--with-cpu"
```

So we revert to using `//` to retain only gcc.cpu
(which is more specific than the processor arch).
2021-08-18 21:52:14 -07:00
lassulus 229ff549e6 lib: inherit mkImageMediaOverride 2021-08-18 14:21:16 +02:00
Lassulus 6a74d5562e
Merge pull request #132583 from blaggacao/fix/soft-force-the-file-system-layout-for-boot-media
nixos/boot-media: soft-force entire fs layout
2021-08-17 22:36:41 +02:00
Robert Hensing fbafeb7ad5 treewide: runCommandNoCC -> runCommand
This has been synonymous for ~5y.
2021-08-15 17:36:41 +02:00
Victor Borja 9a62c51fdf
Fix import path.
Trying to create a simple flake with input:

```
{
     inputs.nixpkgs-lib.url = "github:NixOS/nixpkgs?dir=lib";
     outputs = {nixpkgs-lib, ...}: { };
}
```

Fails when trying to evaluate the nixpkgs-lib flake with an error like:

```
error: getting status of '/nix/store/xxxx-source/lib/lib': No such file or directory
(use '--show-trace' to show detailed location information)
```
2021-08-14 14:46:00 -05:00
Robert Hensing 38819cd2f2
Merge pull request #133508 from Infinisil/toPretty-no-drvPath
lib.generators: Handle no drvPath in toPretty
2021-08-13 12:14:44 +02:00
Kevin Cox 5059cdaa60
Merge pull request #130862 from Atemu/licenses-redistributable-attr
lib.licenses: cleanup, consistency and redistributable attribute
2021-08-11 13:48:25 -04:00
Atemu 5e2c05abc3 lib.licenses: mark a few unfree redistributable licenses as such
I'm sure there are more but it's not feasible for a single person to check all
of them
2021-08-11 19:07:47 +02:00
Atemu 16fb392853 lib.licenses: introduce redistributable attribute
Allows for distinction of licenses that are unfree overall but do grant the
right to redistribute. Defaults to the freeness of the license.

Note: Many unfree but are redistributable licenses aren't marked as such.
I expect that to be fixed in a distributed manner over time.

Closes https://github.com/NixOS/nixpkgs/pull/97789
2021-08-11 19:07:45 +02:00
Atemu 48797d7114 lib.licenses: make all licenses have free and deprecated attrs
This makes them consistent which eases more complex operations on licenses such
as filtering etc.
2021-08-11 19:07:02 +02:00
Atemu 65c605a662 lib.licenses: refactor common attribute application
This is cleaner and makes common attribute application more expandable
2021-08-11 19:06:57 +02:00
Silvan Mosberger 307c0237d7 lib.generators: Handle no drvPath in toPretty
Previously, if a derivation without a `drvPath` was handled, an error
would be thrown:

    nix-repl> lib.generators.toPretty {} { type = "derivation"; }
    error: attribute 'drvPath' missing, at /home/infinisil/src/nixpkgs/lib/generators.nix:251:24

With this commit it doesn't anymore:

    nix-repl> lib.generators.toPretty {} { type = "derivation"; }
    "<derivation ???>"

This matches what `nix repl` outputs:

    nix-repl> { type = "derivation"; }
    «derivation ???»
2021-08-11 15:52:30 +02:00
Silvan Mosberger 998a9c1707 lib/options: Better mergeEqualOption error for uncomparable types
For an option definition that uses `lib.options.mergeEqualOption`
underneath, like `types.anything`, an error is thrown when multiple
functions are assigned, indicating that functions can't be compared for
equivalence:

  error: The option `test' has conflicting definition values:
  - In `xxx': <function>
  - In `xxx': <function>
  (use '--show-trace' to show detailed location information)

However, the error message didn't use the correct files. While above
error indicates that both definitions are in the xxx file, that's in
fact not true. Above error was generated with

  options.test = lib.mkOption {
    type = lib.types.anything;
  };

  imports = [
    {
      _file = "yyy";
      test = y: y;
    }
    {
      _file = "xxx";
      test = x: x;
    }
  ];

With this change, the error uses the correct file locations:

  error: The option `test' has conflicting definition values:
  - In `xxx': <function>
  - In `yyy': <function>
  (use '--show-trace' to show detailed location information)
2021-08-10 19:54:32 +02:00
David Arnold 9e42d02047
lib/modules: add mkImageMediaOverride
so the underlaying use case of the preceding commit is so
generic, that we gain a lot in reasoning to give it an
appropriate name.

As the comment states:
image media needs to override host config short of mkForce
2021-08-03 18:28:14 -05:00
Silvan Mosberger f0fda3bf55
Merge pull request #131267 from blaggacao/fix-functionArgs
lib: fix functionArgs for functors
2021-08-04 00:02:57 +02:00
David Arnold cf8e219b7e
lib: fix functionArgs for functors
`functionArgs` should give valid results on
functions that have been identified with `lib.isFunction`
instead of erroring out.
2021-08-03 16:40:58 -05:00
Alyssa Ross 3669b12f35 lib.systems: add m68k-netbsd support
m68k was recently added for Linux and none, but NetBSD also supports
m68k.  Nothing will build yet, but I want to make sure we at least
encode the existence of NetBSD support for every applicable
architecture we support for other operating systems.
2021-08-01 15:27:12 +00:00
Alyssa Ross 173a37e7b5 lib.systems.doubles: re-sort
These were alphabetically sorted until m68k and s390 were added.
2021-08-01 15:27:12 +00:00
Ben Wolsieffer e2d5af502a lib/systems/platforms: armv7l-hf-multiplatform: fix kernel build
autoModules triggers a build system bug where ks8851_mll needs to be built-in if
ks8851 is also built-in.
2021-07-30 14:08:02 -04:00
Ben Siraphob b63a54f81c
Merge pull request #110742 from siraben/deprecate-fold 2021-07-27 15:13:31 +07:00
Ben Siraphob 0f1204bd2b Initial implementation of s390 cross-compile 2021-07-25 10:12:18 +07:00
John Ericson c5a8d45d41
Merge pull request #131310 from siraben/m86k-cross
Initial implementation of m68k cross-compile
2021-07-24 09:25:53 -06:00
Ben Siraphob 407953e9df Initial implementation of m68k cross-compile 2021-07-24 14:37:35 +07:00
Robert Hensing 98352288bd
Merge pull request #128032 from Artturin/add-swap-options
nixos/swap: add options option
2021-07-23 10:45:53 +02:00
Artturin a3c5f0cba8 lib/types.nix: add nonEmptyStr 2021-07-20 20:51:27 +03:00
Robert Hensing 6d29becbd3
Merge pull request #124353 from hercules-ci/small-enum-description
lib.types.enum: Improve description for lengths 0 and 1
2021-07-18 19:08:49 +02:00
Robert Hensing cad20d8983 lib.mkFixStrictness: Deprecate 2021-07-12 07:31:29 +02:00
Robert Hensing 99bc203025 Partially revert "lib/modules: Drop mkStrict and mkFixStrictness"
mkFixStrictness was never properly deprecated and should only be
removed after warning for some time.

This partially reverts commit 8fb9984690.
2021-07-12 07:25:52 +02:00
Niklas Hambüchen 5db6b909cd
strings.nix: Fix overly monomorphic type signature comments
These functions work on lists of anything, not just lists of strings.
2021-07-04 20:52:48 +02:00
Robert Hensing 4c4c00e9f1
Merge pull request #124875 from hercules-ci/lib-sources
lib.sources: docs, tests, refactoring
2021-06-28 14:02:37 +02:00
github-actions[bot] e8122c3628
Merge master into staging-next 2021-06-23 00:09:33 +00:00
Silvan Mosberger b3e9073c48
Merge pull request #125991 from helsinki-systems/drop/mkStrict
lib/modules: Drop mkStrict and mkFixStrictness
2021-06-23 00:48:59 +02:00
Martin Weinelt eef9694ebc
Merge branch 'master' into staging-next 2021-06-22 00:58:31 +02:00
Pavol Rusnak 68889ed61f
treewide: use quotes for url 2021-06-20 16:26:23 +02:00
Zhaofeng Li afe09e41df mesaPlatforms: Welcome riscv64-linux to the family 2021-06-12 20:45:35 -07:00
tomberek 3a745b2c2c
Merge pull request #125942 from musfay/rlottie
rlottie: 0.1 -> 0.2
2021-06-07 01:08:30 -04:00
Janne Heß 8fb9984690
lib/modules: Drop mkStrict and mkFixStrictness
This was deprecated in 2014 and is not used anywhere in the tree.
2021-06-06 20:53:05 +02:00
Alyssa Ross 4d6a0bb966 lib.systems.parsed: add "elf" for some NetBSD archs
In Autoconf, some old NetBSD targets like "i686-unknown-netbsd" are
interpreted as a.out, not elf, and virtually nothing supports it.  We
need to specify e.g. "i686-unknown-netbsdelf" to get the right
behaviour.
2021-06-06 18:52:58 +00:00
Alyssa Ross 5a8372d04e lib.systems.parse.kernels: fix typo in comment 2021-06-06 18:52:58 +00:00
Mustafa Çalışkan 642dce498a
rlottie: 0.1 -> 0.2 2021-06-06 14:15:36 +03:00
Sandro 870dce75e3
Merge pull request #82642 from magnetophon/faustPhysicalModeling 2021-06-06 01:39:04 +02:00
Michael Weiss ed8115ef5b
Merge pull request #124992 from primeos/android-tools
android-tools: init at 31.0.0p1
2021-06-02 21:06:00 +02:00
Michael Weiss c57b309d32
android-tools: init at 31.0.0p1
lowPrio is used to avoid collisions with the simg2img package.
Licensing information is in share/licenses/android-tools/AOSP_LICENSE.
2021-06-02 12:08:01 +02:00
Zhaofeng Li e2aee93caf platforms: Enable ftrace support for RISC-V
Support has landed in mainline for a while.
2021-06-01 19:49:30 -07:00
Zhaofeng Li 805e9ce9ea platforms: Build flat kernel image for RISC-V
Newer bootloaders for RISC-V (i.e., OpenSBI + U-Boot) support
flat and compressed kernel images but not vmlinux. Therefore,
let's build "Image" like what we do with aarch64.

Also copy DTBs while we are at it.
2021-06-01 19:49:30 -07:00
Robert Hensing 4cf56e5640 lib.sources.trace: init 2021-05-29 16:03:55 +02:00
Robert Hensing 970273023a lib.sources.sourceFilesBySuffices: Improve doc 2021-05-29 16:03:54 +02:00
Robert Hensing d14be76615 lib/tests/sources.sh: init 2021-05-29 14:32:56 +02:00
Robert Hensing dfd2b1bd90 lib/sources: Internal representation for cleanSourceWith 2021-05-29 14:32:56 +02:00
Robert Hensing 285632320d lib.types.enum: Improve description for lengths 0 and 1 2021-05-25 10:53:04 +02:00
Anderson Torres 41d76a33eb
Merge pull request #119967 from xoe-labs/da/add-lib-flake
init: lib/flake
2021-05-24 02:06:19 -03:00
Jonathan Ringer 11a9ac00fc
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
 pkgs/tools/networking/xh/default.nix
2021-05-22 18:19:10 -07:00
Jonathan Ringer ff1ded3e20 21.11 is Porcupine! 2021-05-22 18:14:06 -07:00
Andrew Childs 755d980440 darwin: use "11.0" as sdk and minimum version on aarch64-darwin 2021-05-17 00:27:03 +09:00
Andrew Childs 23cae56ca7 lib/systems/platforms: add Apple M1 2021-05-17 00:27:03 +09:00
Moritz Angermann 3a3df3146e Add crossPkgs.aarch64-darwin 2021-05-17 00:27:02 +09:00
Matthew Bauer a6753d0c42 lib/systems: add aarch64-darwin to mesaPlatforms 2021-05-17 00:27:02 +09:00
github-actions[bot] 78ae7ac75e
Merge staging-next into staging 2021-05-15 06:22:25 +00:00
John Ericson 18c38f8aee treewide: All the linker to be chosen independently
This will begin the process of breaking up the `useLLVM` monolith. That
is good in general, but I hope will be good for NetBSD and Darwin in
particular.

Co-authored-by: sterni <sternenseemann@systemli.org>
2021-05-14 21:29:51 +00:00
Ben Siraphob f986333023 lib/systems/parse: make isCompatible description clearer and more useful
Stating that CPUs and the isCompatible relation forms a category (or
preorder) is correct but overtly technical.  We can state it more
clearly for readers unfamiliar with mathematics while retaining some
keywords to be useful to technical readers.
2021-05-14 13:23:28 -07:00
s1341 1e1d29c2af treewide: Support aarch64-android using minimal prebuilt components
This PR adds a new aarch64 android toolchain, which leverages the
existing crossSystem infrastructure and LLVM builders to generate a
working toolchain with minimal prebuilt components.

The only thing that is prebuilt is the bionic libc. This is because it
is practically impossible to compile bionic outside of an AOSP tree. I
tried and failed, braver souls may prevail. For now I just grab the
relevant binaries from https://android.googlesource.com/.

I also grab the msm kernel sources from there to generate headers. I've
included a minor patch to the existing kernel-headers derivation in
order to expose an internal function.

Everything else, from binutils up, is using stock code. Many thanks to
@Ericson2314 for his help on this, and for building such a powerful
system in the first place!

One motivation for this is to be able to build a toolchain which will
work on an aarch64 linux machine. To my knowledge, there is no existing
toolchain for an aarch64-linux builder and an aarch64-android target.
2021-05-11 15:39:08 +00:00
Erlend Pedersen 3452a739d1
nixpkgs-manual: lib.attrsets.mapAttrsToList returns a list (#122179) 2021-05-08 13:55:11 +02:00
Silvan Mosberger fb1969806f
Merge pull request #117888 from kvtb/patch-3
types.nix: fix outdated comment
2021-05-08 05:46:10 +02:00
Silvan Mosberger 08d94fd2b0
Merge pull request #114374 from oxalica/lib/platform-support-check
lib.meta: introduce `availableOn` to check package availability on given platform
2021-05-08 03:54:36 +02:00
Silvan Mosberger 527861959b
Merge pull request #119406 from sternenseemann/toDerivation-list
lib/attrsets: make toDerivation x always work when isStorePath x
2021-05-07 02:09:05 +02:00
Robert Hensing 0633b6aa74
Merge pull request #121870 from Pacman99/pass-specialargs
lib/modules: pass specialArgs to modules
2021-05-07 01:54:48 +02:00
sternenseemann f39a5c4e50 lib/strings: forbid lists in isStorePath
When a list is passed to isStorePath this is most likely a mistake and
it is therefore better to just return false. There is one case where
this theoretically makes sense (if a list contains a single element for
which isStorePath elem), but since that case is also probably seldomly
intentional, it may save someone from debbuging unclear evaluation
errors.
2021-05-07 01:22:30 +02:00
sternenseemann 326d0970e0 lib/strings: fix example for isStorePath
Since it checks if dirOf x is the nix store dir, a trailing slash will
break this check and make it return false.
2021-05-07 01:22:30 +02:00
Pacman99 c949e60220 lib/modules: pass specialArgs as a module argument 2021-05-06 16:04:08 -07:00
John Ericson 470640e7fe treewide: Do a number of no-op cleanups for cross and darwin
I am taking the non-invasive parts of #110914 to hopefully help out with #111988.

In particular:

 - Use `lib.makeScopeWithSplicing` to make the `darwin` package set have
   a proper `callPackage`.

 - Adjust Darwin `stdenv`'s overlays keeping things from the previous
   stage to not stick around too much.

 - Expose `binutilsNoLibc` / `darwin.binutilsNoLibc` to hopefully get us
   closer to a unified LLVM and GCC bootstrap.
2021-05-06 11:17:26 -04:00
Silvan Mosberger 98c77a0b2d lib/modules: Small optimization 2021-05-06 04:59:27 +02:00
Silvan Mosberger f445acbe0a
Merge pull request #114955 from berbiche/fix/modules-imports-list
lib/modules: provide a better error message when "imports" contains a list
2021-05-05 23:20:39 +02:00
Nicolas Berbiche 810c9c6a0e
lib/modules: provide error message when imports contains a list 2021-05-05 14:15:04 -04:00
Robert Hensing a36e6760e9 Revert "lib/modules: Issue type deprecation warnings recursively"
This reverts commit 4b54aedee5.
2021-05-05 18:53:34 +02:00
Robert Hensing e7412dde1f Revert "lib/tests: Add type deprecation tests"
This reverts commit 8b957e3b30.
2021-05-05 18:53:28 +02:00
Silvan Mosberger 8b957e3b30 lib/tests: Add type deprecation tests 2021-05-03 22:16:06 +02:00
Silvan Mosberger 4b54aedee5 lib/modules: Issue type deprecation warnings recursively
Previously, an option of type

  attrsOf string

wouldn't throw a deprecation warning, even though the string type is
deprecated. This was because the deprecation warning trigger only looked
at the type of the option itself, not any of its subtypes.

This commit fixes this, causing each of the types deprecationMessages to
trigger for the option. This relies on the subtypes mkOptionType
attribute introduced in 26607a5a2e06653fec453c83d063cdfc4b59185f
2021-05-03 22:16:02 +02:00
Silvan Mosberger ce5e3113c3 lib/tests: Make sure the submodule type description can be evaluated
In 2d45a62899, the submodule type
description was amended with the freeformType description. This causes
all the modules passed to the submodule to be evaluated once on their
own, without any extra definitions from the config section. This means
that the specified modules need to be valid on their own, without any
undeclared options.

This commit adds a test that evaluates a submodules option description,
which would trigger the above problem for one of the tests, if it were
not fixed by this commit as well.

This is done because the next commit makes option evaluation a bit more
strict, which would also trigger this test failure, even though it's not
related to the change at all.
2021-05-03 22:15:33 +02:00
Silvan Mosberger 68955fe612 lib/types: Introduce mkOptionType occurringTypes argument
This will be used to issue deprecation warnings recursively in the next
commit

In addition, this allows easily getting nested types of other options, which
is useful when you want to create an option that aliases a part of
another one.
2021-05-03 22:15:30 +02:00
Silvan Mosberger 680a901ae1
Merge pull request #120774 from sternenseemann/shellpackage-fix-check
lib/types: only accept derivations for shellPackage
2021-05-03 16:42:08 +02:00
Lennart Spitzner 8c70a1a989
lib: fix documented type of fixedWidthString (#121396) 2021-05-01 17:29:00 +02:00
Alyssa Ross a8afbb45c1 treewide: use lib.warnIf where appropriate 2021-04-28 21:44:21 +00:00
Alyssa Ross 81e1e68eaf lib.trivial.warnIf: init
It's a common pattern in Nixpkgs to want to emit a warning in certain
cases, but not actually change behaviours.

This is often expressed as either
	if cond then lib.warn "Don't do that thing" x else x
Or
	(if cond then lib.warn "Don't do that thing" else lib.id) x

Neither of which really expresses the intent here, because it looks
like 'x' is being chosen conditionally.

To make this clearer, I introduce a "warnIf" function, which makes it
clear that the only thing being affected by the condition is whether
the warning is generated, not the value being returned.
2021-04-28 21:44:21 +00:00
David Arnold 2cd41fb432
init: lib/flake
A subflake that can be indidividually accessed without also providing
an interface to the whole of nixpkgs.

Usage:
inputs.nixpkgs-lib.url = "github:NixOS/nixpkgs?dir=lib"
2021-04-28 14:21:27 -05:00
sternenseemann 8a83d611f5 lib/types: only accept derivations for shellPackage
Since shellPackage actually requires the value to be an attribute set
(i. e. an derivation in this case), we cannot re-use the package.check
type checker since it also allows strings or things that are coercible
to strings as long as they look like store paths.
2021-04-26 20:43:43 +02:00
Jan Tojnar 0f1c4558d3
Merge branch 'master' into staging-next
Choose binwalk 2.3.1, 27 is legacy version for Python 2.
2021-04-25 02:50:48 +02:00
github-actions[bot] 6e7c70d02d
Merge master into staging-next 2021-04-24 00:16:17 +00:00
Alyssa Ross 532493b508
lib.systems.doubles.netbsd: expand
These are all the architectures supported by Nixpkgs on other
platforms, that are also supported by NetBSD.  (So I haven't added
any architectures that are new to Nixpkgs here, even though NetBSD
supports some that we don't have.)
2021-04-23 22:23:25 +00:00
Alyssa Ross cf5d480a06
lib.systems.doubles.all: reorganize
The previous mess was partially grouped by OS, and partially grouped
by architecture, which made it very difficult to know where to add new
entries.

I've chosen to group by OS entirely, because OSes are likely to
maintain exhaustive lists of supported architectures, but it's far
less likely we'd be able to find exhaustive lists of supported OSes
for every architecture.
2021-04-23 13:19:00 +00:00
github-actions[bot] 9c190d28df
Merge master into staging-next 2021-04-15 12:06:13 +00:00
Alyssa Ross 9767460d00 lib.systems.examples.amd64-netbsd: add warning
Otherwise, nobody will know it's deprecated!
2021-04-15 10:45:04 +00:00
github-actions[bot] 8b35f0c117
Merge master into staging-next 2021-04-15 06:05:40 +00:00
John Ericson a2650e1257 lib: Adjust NetBSD example systems
Deprecate the odd one so no breaking change.
2021-04-15 04:38:17 +00:00
Luke Granger-Brown 08b22e605b Merge remote-tracking branch 'upstream/staging-next' into down-integrate-staging 2021-04-12 18:49:01 +00:00
John Ericson 82ca81cd62
Merge pull request #111988 from thefloweringash/darwin-platform-versions
Darwin platform versions
2021-04-12 11:40:16 -04:00
Sandro 9f198c1423
Merge pull request #116495 from r-burns/ppc64
lib/systems: remove powerpc64 elfv1 support
2021-04-12 16:44:14 +02:00
Andrew Childs d0418480f1 lib.systems: add darwinPlatform where necessary 2021-04-11 09:47:10 +09:00
Andrew Childs 6c4ce7960e bintools-wrapper, cc-wrapper: parameterize darwin min version variable
These variables are the ones that the standard toolchain uses, so we
should use those and not always use MACOSX_DEPLOYMENT_TARGET.

See 236a426c12/cctools/ld64/src/ld/PlatformSupport.cpp (L54-L55)
2021-04-11 09:47:10 +09:00
ajs124 ff2e6fcf37 lib.licenses: add bsdOriginalUC (BSD 4-Clause University of California-Specific) 2021-04-09 19:42:27 +00:00
Milan Pässler 5f7aa7a973 systems: add appropriate rustc.config for android
Rust doesn't like the `-unknown` vendor component in the target triple.
2021-04-09 12:09:06 +02:00
Alyssa Ross fae6b04160
lib.trivial: fix typo "nixpks" -> "nixpkgs" 2021-04-05 10:13:33 +00:00
oxalica 354d262db8
lib.meta: introduce availableOn 2021-04-02 19:20:23 +08:00
Emery Hemingway 1cd48efa96 lib/generators: add toDhall 2021-04-01 14:29:57 +02:00
kvtb 1c0d31d042
types.nix: types.ints.s32 and types.ints.u32 do work 2021-03-30 15:03:53 +00:00
kvtb 3131cdf05b
types.nix: fix outdated comment
Nix's `int` is always 64-bit
2021-03-28 14:04:39 +00:00
Léo Gaspard 144a997c8e
lib: fix commitIdFromGitRepo (#117752)
When in the presence of worktrees, it happens that /commondir has a
trailing slash.

In these circumstances, it can lead to `lib.pathType` being passed paths
like `/foo/bar/.git/`, which in turn lead to
`error: attribute '.git' missing`.

With this change, we now make sure send properly-formatted paths to all
other functions.

This, in particular, fixes running NixOS tests on worktrees created by
libgit2 on my machine. (Worktrees created by git itself appear to not
hit the issue.)
2021-03-27 21:16:31 +01:00
Andrew Childs 44f09ccabf darwin: move deployment target and sdk version to platform config 2021-03-26 15:10:22 +09:00
Silvan Mosberger 3d19f1d574
Merge pull request #115919 from Ma27/module-error-improvement
lib/modules: better error message if an attr-set of options is expected
2021-03-26 00:27:35 +01:00
John Ericson c82066e585
Merge pull request #113212 from lopsided98/kernel-arm-fix
lib/systems/platforms: remove TI_CPTS override
2021-03-21 13:22:53 -04:00
Jan Tojnar 2445e9a681
Merge branch 'master' into staging-next 2021-03-18 19:24:39 +01:00
Aaron Andersen 7f70d66a53 licenses.odbl: init at 1.0 2021-03-17 21:52:19 -04:00
Ryan Burns 8ea1660b9e lib/systems: remove powerpc64 elfv1 support
I was specifying the ELF ABI using -elfv1 and -elfv2 target config
suffixes, which are nonstandard and no longer work with gnu-config.
2021-03-15 19:27:41 -07:00
Maximilian Bosch e878fc4aac
lib/modules: better error message if an attr-set of options is expected
I recently wrote some Nix code where I wrongly set a value to an option
which wasn't an actual option, but an attr-set of options. The mistake I
made can be demonstrated with an expression like this:

    {
      foo = { lib, pkgs, config, ... }: with lib; {
        options.foo.bar.baz = mkOption {
          type = types.str;
        };
        config.foo.bar = 23;
      };
    }

While it wasn't too hard to find the cause of the mistake for me, it was
necessary to have some practice in reading stack traces from the module
system since the eval-error I got was not very helpful:

    error: --- TypeError --------------------------------------------------------- nix-build
    at: (323:25) in file: /nix/store/3nm31brdz95pj8gch5gms6xwqh0xx55c-source/lib/modules.nix

       322|         foldl' (acc: module:
       323|                 acc // (mapAttrs (n: v:
          |                         ^
       324|                                    (acc.${n} or []) ++ f module v

    value is an integer while a set was expected
    (use '--show-trace' to show detailed location information)

I figured that such an error can be fairly confusing for someone who's
new to NixOS, so I decided to catch this case in th `byName` function in
`lib/modules.nix` by checking if the value to map through is an actual
attr-set. If not, a different error will be thrown.
2021-03-11 14:55:56 +01:00
Andrew Childs 1303257d88 lib/systems: add darwinArch 2021-03-02 17:13:15 +09:00
sternenseemann 7f7d5bcd90 lib/licenses: fix regression removing shortName for some licenses
Usually we ensure using the mapAttrs call wrapping the license set that
every license has an associated shortName. A change related to legacy
aliases most likely introduced the removal of the shortName attribute
for all the legacy license names by splitting the set into two sets
connected by a record update operator -- leading to mapAttrs only
affecting the first set.

Since it used to be a valid assumption to have that every license had a
shortName attribute, we reintroduce this attribute for the legacy
aliases as well.
2021-02-25 23:01:09 +01:00
Ben Wolsieffer 7b573e8051 lib/systems/platforms: remove TI_CPTS override
Forcing the module to be builtin breaks 5.10, which wants to compile it as a
module (probably due to dependencies). There doesn't seem to be a need to have
it builtin anymore, so we can just remove the override.
2021-02-15 11:23:17 -05:00
Ben Wolsieffer 1e1588898b lib/systems/platforms: note that RPi 3 fixes aren't needed for kernel >=4.17 2021-02-15 11:23:17 -05:00
Michael Raskin 5a1a7a359f
Merge pull request #112885 from alyssais/wiktionary
dictdDBs.wiktionary: 20161001 -> 20210201; refactor
2021-02-12 19:12:45 +00:00
Alyssa Ross 56de41bc80
lib.licenses.fdl11Plus: init 2021-02-11 15:08:59 +00:00
Philipp Adolf 408ae0b13a lib: fix typo in platforms.nix
In 9c213398b3 kernelPreferBuiltin was
moved/renamed to linux-kernel.preferBuiltin. However, for
armv7l-hf-multiplatform the new option was written with an uppercase P,
which made the kernel build process ignore it.
2021-02-11 08:58:04 +01:00
Bernardo Meurer 6ca28ab28e
lib: remove mention of flashplayer in docs 2021-02-08 09:38:41 -08:00
Fabian Affolter f5a0053546 lib.licenses: add bsd1 (BSD 1-Clause License) 2021-02-02 14:37:19 +01:00
sternenseemann 06d3b28987 Revert "lib/generators: fix toPretty throwing on (partially applied) builtins"
This reverts commit d9a7d03da8.

Reason for this is that it actually doesn't migitate the issue on nix
stable for another reason: builtins.tryEval doesn't prevent the error
generated by builtins.functionArgs from halting evaluation:

> builtins.tryEval (builtins.functionArgs builtins.functionArgs)
error: 'functionArgs' requires a function, at (string):1:19

Thus it seems that there is no workaround to make
lib.generators.toPretty work with nix stable and primops since there is
no way to distinguish between primops and lambdas in nix.
2021-02-01 16:27:38 +01:00
Silvan Mosberger 59b45d66b2
Merge pull request #111469 from sternenseemann/topretty-fix-currying
lib/generators: fix toPretty throwing on (partially applied) builtins
2021-01-31 21:20:17 +01:00
Fritz Otlinghaus e0215b3175
lib/types: add description for functionTo 2021-01-31 15:59:13 +01:00
sternenseemann d9a7d03da8 lib/generators: fix toPretty throwing on (partially applied) builtins
An high level example case of this problem occuring can be found below:

nix-repl> lib.generators.toPretty {} (lib.concatStringsSep "\n")
error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42

However this does not happen on other partially applied functions:

nix-repl> lib.generators.toPretty {} (lib.concatMapStringsSep "\n")
"<function>"

The issue, as it turns out is that while builtins are functions,
builtins.functionArgs throws if is passed a builtin or a partially
applied builtin:

nix-repl> lib.generators.toPretty {} builtins.toString
error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42

nix-repl> lib.generators.toPretty {} (builtins.foldl' (a: b: a + b))
error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42

I'm pretty sure this qualifies as a nix bug and should be filed
accordingly, but we can work around it in lib.generators.toPretty by
using tryEval and falling back to {} which functionArgs _should_ return
for builtins.

The nix behavior is inconsistent to say the least:

nix-repl> builtins.functionArgs builtins.functionArgs
error: 'functionArgs' requires a function, at (string):1:1

nix-repl> builtins.typeOf builtins.functionArgs
"lambda"

builtins.functionArgs (a: 1 + a)
{ }

nix-repl> builtins.typeOf (a: 1 + a)
"lambda"
2021-01-31 15:35:17 +01:00
John Ericson 5fc5e83808
Merge pull request #111345 from r-burns/ppc64-big-endian
Enable PPC64 (big-endian)
2021-01-30 16:26:06 -05:00
Ryan Burns 72b3badb61 lib.systems: add powerpc64-linux
PPC64 supports two ABIs: ELF v1 and v2.

ELFv1 is historically what GCC and most packages expect, but this is
changing because musl outright does not work with ELFv1. So any distro
which uses musl must use ELFv2. Many other platforms are moving to ELFv2
too, such as FreeBSD (as of v13) and Gentoo (as of late 2020).

Since we use musl extensively, let's default to ELFv2.

Nix gives us the power to specify this declaratively for the entire
system, so ELFv1 is not dropped entirely. It can be specified explicitly
in the target config, e.g. "powerpc64-unknown-linux-elfv1". Otherwise the
default is "powerpc64-unknown-linux-elfv2". For musl,
"powerpc64-unknown-linux-musl" must use elfv2 internally to function.
2021-01-30 12:34:24 -08:00
Silvan Mosberger aa48e205a2
Merge pull request #110787 from tfc/cartesian-product
lib/attrsets: add cartesianProductOfSets function
2021-01-29 20:22:12 +01:00
Alexander Foremny 75e2f7ce63 gcc: fix armhf target
Fixes #96921
2021-01-29 10:48:23 +01:00
Jacek Galowicz 577d58a8e0 Deprecate lib.crossLists 2021-01-28 23:49:05 +01:00
Jacek Galowicz 123045a570 lib/attrsets: add cartesianProductOfSets function 2021-01-28 23:08:59 +01:00
Robert Hensing d2a41be2f3
Merge pull request #110707 from Infinisil/functionTo
Bring back `types.functionTo`
2021-01-27 10:50:13 +01:00
Silvan Mosberger c2f3556dc7
lib/tests: More functionTo tests 2021-01-27 00:17:56 +01:00
Silvan Mosberger e9101d4a3b
lib/types: Improved functionTo merging
Now type checks the resulting function values and allows mkMerge and co.
Also indicates that the type check is done in the function body

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2021-01-27 00:16:23 +01:00
Ben Siraphob 1c2a2b0a08 treewide: fold -> foldr 2021-01-26 10:57:07 +07:00
Ryan Burns 8baac2af75 lib/systems: fix linuxArch for power + riscv
Looks like these got left behind in the
kernelArch -> linuxArch migration.

Fixes:
* pkgsCross.powernv.linuxHeaders
* pkgsCross.riscv64.linuxHeaders
* pkgsCross.riscv32.linuxHeaders
and dependees
2021-01-25 17:57:05 -08:00
Silvan Mosberger 9ba1f22982
Merge pull request #110672 from Profpatsch/lib-add-traceFnSeqN
lib/debug: add traceFnSeqN
2021-01-25 20:17:56 +01:00
Profpatsch 41e13149f7 lib/debug: add traceFnSeqN
Immensely helpful when you want to see the changes a function makes to
its value as it passes through.

Example:

```
$ nix-instantiate --strict --eval -E '(with import ./lib; traceFnSeqN 2 "id" (x: x) { a.b.c = 3; })'
trace: {
  fn = "id";
  from = {
    a = {
      b = {…};
    };
  };
  to = {
    a = {
      b = {…};
    };
  };
}
{ a = { b = { c = 3; }; }; }
```
2021-01-25 19:25:50 +01:00
Bas van Dijk 43243539b3
lib/tests/modules: add a test for the functionTo type
(cherry picked from commit 478af112e83df806bd8a51174834d2a130fbdeb9)
2021-01-24 16:56:45 +01:00
Bas van Dijk b454af298d
Revert "Remove types.functionTo."
This reverts commit 4ff1ab5a56.

We need this to type options like:
services.xserver.windowManager.xmonad.extraPackages that specify functions that
take an attribute set containing packages / plugins and return a list containing
a selection of the values in this set.

The reason we need a dedicated type for this is to have the correct merge
behaviour. Without the functionTo type merging multiple function option
definitions results in an evaluation error. The functionTo type merges
definitions by returning a new function that applies the functions of all the
definitions to the given input and merges the result.

(cherry picked from commit 7ed41ff5e7e633dd64866398ee497ac02736a3a5)
2021-01-24 16:56:33 +01:00
volth bc0d605cf1 treewide: fix double quoted strings in meta.description
Signed-off-by: Ben Siraphob <bensiraphob@gmail.com>
2021-01-24 19:56:59 +07:00
Matthew Bauer 84408a6ad0
Merge pull request #100687 from spease/add-newer-xcode-hashes
darwin: update xcode versions
2021-01-23 20:04:50 -06:00
John Ericson 9c213398b3 lib: Clean up how linux and gcc config is specified
Second attempt of 8929989614589ee3acd070a6409b2b9700c92d65; see that
commit for details.

This reverts commit 0bc275e634.
2021-01-23 10:01:28 -05:00
Jonathan Ringer 0bc275e634
Revert "lib: Clean up how linux and gcc config is specified"
This is a stdenv-rebuild, and should not be merged
into master

This reverts commit 8929989614.
2021-01-22 14:07:06 -08:00
John Ericson d95aebbe0e
Merge pull request #107214 from Ericson2314/linux-config-cleanup
lib: Clean up how linux and gcc config is specified
2021-01-22 15:15:58 -05:00
John Ericson 8929989614 lib: Clean up how linux and gcc config is specified
The `platform` field is pointless nesting: it's just stuff that happens
to be defined together, and that should be an implementation detail.

This instead makes `linux-kernel` and `gcc` top level fields in platform
configs. They join `rustc` there [all are optional], which was put there
and not in `platform` in anticipation of a change like this.

`linux-kernel.arch` in particular also becomes `linuxArch`, to match the
other `*Arch`es.

The next step after is this to combine the *specific* machines from
`lib.systems.platforms` with `lib.systems.examples`, keeping just the
"multiplatform" ones for defaulting.
2021-01-21 22:44:09 -05:00
Silvan Mosberger 7f2fcc45f7
lib/modules: Set submodule type for renamed option sets
For renames like

  mkAliasOptionModule [ "services" "compton" ] [ "services" "picom" ]

where the target is an option set (like services.picom) instead of a single
option (like services.picom.enable), previously the renamed option type
was unset, leading to it being `types.unspecified`.

This changes it to be `types.submodule {}` instead, which makes more
sense.
2021-01-21 21:57:48 +01:00
Steven Pease 0fdab8d560 Merge branch 'master' into add-newer-xcode-hashes 2021-01-19 20:42:30 -08:00
Steven Pease d8c1c0dc50 Update to XCode 12.3 2021-01-19 20:41:39 -08:00
John Ericson 19852e3dc6
Merge pull request #104648 from samueldr/cleanup/kernelMajor
platforms.nix: Remove now unused kernelMajor
2021-01-18 14:08:30 -05:00
Jan Tojnar 2a5b2df11d
Merge pull request #107417 from jtojnar/deprecate-unclear-gpl-licenses
licenses: Mark unclear GPL licenses explicitly deprecated
2021-01-01 23:49:44 +01:00
John Ericson 15cb12178a
Merge pull request #107999 from andir/platforms-arm-trusted-platform
lib/systems/platforms: treat missing cpu version as generic pcBase
2020-12-31 13:52:09 -05:00
Ben Siraphob b77ca83282 lib/systems: add emulator for mmix 2020-12-31 13:22:12 +07:00
Andreas Rammhold a44aec2b1b
lib/systems/platforms: treat missing cpu version as generic pcBase
Since 40e7be1 all ARM platforms that didn't have a parsed cpu version
(e.g. arm-none-eabi) would be handled as armv7l-hf-multiplatform which
did break building arm-trusted-platform packages for some targets (e.g.
rk3399).

Using pcBase as fallback, instead of armv7l-hf-multiplatform,
corresponds with the behaviour we had before 40e7be1.
2020-12-31 00:12:07 +01:00
Fabián Heredia Montiel 2a9ac172c1 lib.systems: update processor architecture info 2020-12-23 18:57:59 -06:00
Jan Tojnar 9d5bd8b835
licenses: Mark unclear GPL licenses explicitly deprecated
We recently switched to more explicit GPL license names in line
with the SPDX change and GNU Foundation recommendations:
https://www.gnu.org/licenses/identify-licenses-clearly.html

This followed up older change to use the recommended SPDX ID
18a5e8c36b
but using the `-only` variant for these deprecated licenses too
makes it harder to check for them automatically.

Let’s switch to the appropriate SPDX ID again.
2020-12-22 19:25:33 +01:00
Linus Heckemann b1fc183639
Merge pull request #97145 from lheckemann/initrd-improvements
Initrd improvements
2020-12-18 18:15:27 +01:00
Silvan Mosberger 9e6737710c Revert "Module-builtin assertions, disabling assertions and submodule assertions" 2020-12-18 16:44:37 +01:00
Silvan Mosberger 7698aa9776
Merge pull request #97023 from Infinisil/module-assertions
Module-builtin assertions, disabling assertions and submodule assertions
2020-12-18 14:17:52 +01:00
Doron Behar 15edb396ca
Merge pull request #104118 from LibreCybernetics/add-parity-license
lib.licenses: add Parity-7.0.0 license
2020-12-18 11:55:21 +02:00
Silvan Mosberger a6a70d14a9
lib/modules: Prefix mkRemovedOptionModule & co. check names
To avoid name clashes

Co-authored-by: Robert Hensing <robert@roberthensing.nl>
2020-12-18 03:34:39 +01:00
Silvan Mosberger 767d80099c
lib/modules: Introduce _module.checks.*.check
Previously the .enable option was used to encode the condition as well,
which lead to some oddness:
- In order to encode an assertion, one had to invert it
- To disable a check, one had to mkForce it

By introducing a separate .check option this is solved because:
- It can be used to encode assertions
- Disabling is done separately with .enable option, whose default can be
  overridden without a mkForce
2020-12-17 21:52:24 +01:00
Linus Heckemann 2ee35e1fce lib/systems: fix kernelArch for x86_64
IA64 (Itanium) is something completely different and certainly not
what we want! x86_64 code lives in arch/x86 just like "classic" x86.
2020-12-17 11:10:38 +01:00
Sandro 8c321dd36b
Merge pull request #101248 from makefu/pkgs/pfsshell/init 2020-12-08 05:38:25 +01:00
Alex Brandt ff1700feda lib/string: drop redundant string in description of toInt.
Describing the string argument as a string is redundant and not needed
to describe what this function does.
2020-12-05 14:35:30 +00:00
Alex Brandt 4a5cb363ae lib/strings: fix typo in example
The example refers to a snake_case function name but Nix uses camelCase
function names.  This ensures the example is correct for the given
function.
2020-12-04 19:35:27 +00:00
Alex Brandt 2697a777e7 lib/strings: fix examples for enableFeatureAs
The As was missing in the examples on this library function.  This will
ensure the examples refer to the function they document.
2020-12-03 18:50:14 +00:00
John Ericson 8e21ce5fae
Merge pull request #105294 from Ericson2314/platform-config-improvements
Platform config improvements
2020-12-02 11:17:41 -05:00
Bart Brouns f3301f6789 licenses: add stk 2020-12-02 13:02:40 +01:00
John Ericson b1d16d8101
Merge pull request #105432 from tadfisher/remarkable-2-cross
Cross-compile configuration for reMarkable 2 tablet
2020-12-01 16:51:51 -05:00
makefu a8de2e3fb5
licenses: Add Academic Free License version 2.0 2020-12-01 11:16:44 +01:00
Silvan Mosberger 991dfccbd1
lib/modules: _module.check should always be internal
Honestly this option should probably just be removed
2020-11-30 23:51:42 +01:00
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
Tad Fisher 454df2b0c3
Cross-compiling configuration for reMarkable 2 tablet 2020-11-29 23:01:58 -08:00
John Ericson 9918ba2dba lib/systems/exmaple: riscv-multiplatform no longer needs parameter 2020-11-29 00:03:51 +00:00
John Ericson 04f6973200 lib, binutils: Move Risc-V bfdEmulation to be by the others 2020-11-29 00:03:51 +00:00
John Ericson 40e7be11c8 lib.systems.platforms: Make selection more flexible
We dont have to match on exact strings if we get accessed to `parsed`.

Co-authored-by: Matthew Bauer <mjbauer95@gmail.com>
2020-11-29 00:03:45 +00: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
Samuel Dionne-Riel 837fe2e491 platforms.nix: Remove now unused kernelMajor
The last use of `kernelMajor` in Nixpkgs was removed in 2018.

Even then, I'm not positive it was actually in an exercised code path.

AFAIUI this is now totally redundant and useless as it really was meant
for the 2.4 -> 2.6 transition.
2020-11-22 22:08:18 -05: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
Fabián Heredia Montiel 1b76d2a5ba lib.licenses: add Parity-7.0.0 license 2020-11-17 21:15:42 -06: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
Steven Pease 6217cc92b5 Add newer xcode versions 2020-10-15 23:17:55 -07: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
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