Commit Graph

2615 Commits

Author SHA1 Message Date
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
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
Emery Hemingway
1cd48efa96 lib/generators: add toDhall 2021-04-01 14:29:57 +02: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 9c213398b312e0f0bb9cdf05090fd20223a82ad0 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 d9a7d03da8c58aa863911506ae3153729f8931da.

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
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