Commit Graph

2803 Commits

Author SHA1 Message Date
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