Commit Graph

3042 Commits

Author SHA1 Message Date
Graham Christensen
c8cebff38b maintainers: remove longkeyid
see https://dkg.fifthhorseman.net/blog/openpgp-key-ids-are-not-useful.html
2022-06-20 22:20:26 +02:00
Robert Hensing
3c4a49f506 lib/modules: Throw earlier when module function does not return attrs
`m` must always be an attrset at this point. It is basically always
evaluated. This will make it throw when any of the attrs is accessed,
rather than just `config`. We assume that this will improve the error
message in more scenarios.
2022-06-14 23:23:41 +02:00
Robert Hensing
dfd98a5da2 lib.deferredModule: Make it properly singular 2022-06-14 23:01:27 +02:00
Robert Hensing
19a069ab8b lib.types: Add deferredModuleWith 2022-06-14 23:01:27 +02:00
Robert Hensing
781c2e0789 lib.types.deferredModule: Allow path-typed module references 2022-06-14 23:01:26 +02:00
Robert Hensing
a2c29561e7 lib.types.deferredModule: Improve reported location 2022-06-14 23:01:26 +02:00
Robert Hensing
38b7709a6f lib/test/modules.sh: Test deferredModule error location file 2022-06-14 23:01:26 +02:00
Robert Hensing
4746f6d03e lib.types: Add deferredModule 2022-06-14 23:01:23 +02:00
Robert Hensing
9dead5565a lib/types, lib/modules: Remove unused extensionOffset 2022-06-14 17:25:06 +02:00
Robert Hensing
d4a84aeeca lib/types: Use map instead of imap1 in submoduleWith 2022-06-14 17:09:05 +02:00
Silvan Mosberger
907627f656 lib/types: Simplify submoduleWith shorthandOnlyDefinesConfig handling
The module system already uses the parent module's _file as a fallback,
so we don't need to inject the file in a weird way
2022-06-14 17:07:33 +02:00
Silvan Mosberger
79441600c2 lib/tests: Add submodule file propagation test 2022-06-14 17:01:58 +02:00
pennae
320aa2a791 treewide: attempt at markdown option docs 2022-06-12 12:44:38 +02:00
Robert Hensing
b37801bc3f
Merge pull request #157480 from MatthewCroughan/in-pure-eval-mode
lib: add inPureEvalMode
2022-06-10 16:31:31 +02:00
Robert Hensing
d9e71531a0 lib/modules: Fix missing prefix in extendModules when unset in both eval- and extend- 2022-06-10 12:21:23 +02:00
Robert Hensing
ec82f36ab6
Merge pull request #173621 from ncfavier/submodule-description
lib/types: allow custom `submoduleWith` descriptions
2022-06-10 11:10:20 +02:00
Silvan Mosberger
53ee7c4879
Merge pull request #177061 from ckiee/bitXOr-typo
lib/zip-int-bits: fix typo: bitXOR -> bitXor
2022-06-09 19:06:32 +02:00
ckie
00a46966be
lib/zip-int-bits: fix typo: bitXOR -> bitXor 2022-06-09 20:04:37 +03:00
Alyssa Ross
74562a214e
lib.systems.amd64-netbsd: remove
This has been deprecated for a long time, and it's doubtful it had any
users to start with.  And having an undisablable warning when
enumarating platforms is not good.
2022-06-08 17:14:05 +00:00
github-actions[bot]
68b515131f
Merge master into haskell-updates 2022-06-01 00:15:07 +00:00
github-actions[bot]
5250c9bcbc
Merge master into haskell-updates 2022-05-31 00:12:58 +00:00
michaelmouf
b1aa4a7f25
Fix typo in compareLists docstring 2022-05-30 12:14:45 +02:00
Robert Scott
ae0df5d38a lib.sourceTypes: simplify implementation
Co-authored-by: Alexander Foremny <aforemny@posteo.de>
2022-05-30 16:27:34 +08:00
Robert Scott
da9162f667 add mechanism for handling meta.sourceProvenance attributes
heavily based on patterns used by licenses infrastructure, so may
appear overengineered for its initial level of use
2022-05-30 16:27:34 +08:00
sternenseemann
90099ac5fa haskell.compiler: ghc922 -> ghc923
https://www.haskell.org/ghc/download_ghc_9_2_3.html

Since the tarball is generated by Hadrian, neither autoreconf nor ./boot
is executed so ./configure and ghc.mk is missing.
2022-05-28 21:11:07 +02:00
sternenseemann
d01774baa3
Merge pull request #174917 from alyssais/scaleway-c1
lib.systems: drop scaleway-c1
2022-05-27 14:52:42 +02:00
Alyssa Ross
089ff89f49
lib.systems: drop scaleway-c1
These servers apparently no longer exist, since September 2, 2021[1].
If somebody needs this for non-Scaleway machines, they should suggest
its reintroduction with a different name.

[1]: https://news.ycombinator.com/item?id=27192757
2022-05-27 12:02:39 +00:00
Adam Joseph
c0085404bd lib/systems/inspect.nix: remove isPowerPC
Very confusingly, the `isPowerPC` predicate in
`lib/systems/inspect.nix` does *not* match `powerpc64le`!

This is because `isPowerPC` is defined as

  isPowerPC      = { cpu = cpuTypes.powerpc; };

Where `cpuTypes.powerpc` is:

  { bits = 32; significantByte = bigEndian; family = "power"; };

This means that the `isPowerPC` predicate actually only matches the
subset of machines marketed under this name which happen to be 32-bit
and running in big-endian mode which is equivalent to:

  with stdenv.hostPlatform; isPower && isBigEndian && is32bit

This seems like a sharp edge that people could easily cut themselves
on.  In fact, that has already happened: in
`linux/kernel/common-config.nix` there is a test which will always
fail:

  (stdenv.hostPlatform.isPowerPC && stdenv.hostPlatform.is64bit)

A more subtle case of the strict isPowerPC being used instead of the
moreg general isPower accidentally are the GHC expressions:

  Update pkgs/development/compilers/ghc/8.10.7.nix
  Update pkgs/development/compilers/ghc/8.8.4.nix
  Update pkgs/development/compilers/ghc/9.2.2.nix
  Update pkgs/development/compilers/ghc/9.0.2.nix
  Update pkgs/development/compilers/ghc/head.nix

Since the remaining legitimate use sites of isPowerPC are so few, remove
the isPowerPC predicate completely. The alternative expression above is
noted in the release notes as an alternative.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2022-05-25 09:45:42 +02:00
Robert Hensing
40b6089f21
Merge pull request #171014 from hercules-ci/nixpkgs-warn-undeclared-options
pkgs/top-level/config.nix: Add warnUndeclaredOptions
2022-05-25 08:37:15 +02:00
Nick Cao
eef4bbd82f
stdenv: fix evaluation of platform emulator 2022-05-24 12:01:56 +08:00
sternenseemann
82c434b3de lib.systems: inform isCompatible users about removal 2022-05-23 21:26:03 +02:00
sternenseemann
acb063701a lib.systems.elaborate: expose canExecute predicate over isCompatible
canExecute is like isCompatible, but also checks that the Kernels are
_equal_, i.e. that both platforms use the same syscall interface. This
is crucial in order to actually be able to execute binaries for the
other platform.

isCompatible is dropped, since it has changed semantically and there's
no use case left in nixpkgs.
2022-05-23 21:25:04 +02:00
sternenseemann
fe836f3564 lib/systems/parse: don't consider mode switching CPUs compatible
Since we (exclusively) use isCompatible to gauge whether platform a can
execute binaries built for platform b, mode switching CPUs are not to be
considered compatible for our purposes: Switching the mode of a CPU
usually requires a reset. At the very least we can't execute a mix of
executables for the two modes which would usually be the case in nixpkgs
where we may want to execute buildInputs for the hostPlatform in
addition to nativeBuildInputs for the buildPlatform.
2022-05-23 21:25:04 +02:00
Janne Heß
bfdfe12c78
22.11 is Raccoon 2022-05-23 20:08:07 +02:00
Silvan Mosberger
4b2827e6a1
Merge pull request #168374 from Ma27/special-attrs-in-with-recursion
lib/generators: withRecursion: don't break attr-sets with special attrs
2022-05-23 17:55:18 +02:00
sternenseemann
168b926435 lib.systems: remove supported, replace with flakeExposed
Since the list only gates the platforms the nixpkgs flake exposes
packages to build on, the `hydra` label made little sense. It was also
only used for this purpose, so the `tier*` attributes were largely
unnecessary.

To reflect the intention more accurately, we expose
`lib.systems.flakeExposed` and use it to gate flake.nix's system list.
2022-05-23 15:27:30 +02:00
yvt
bf139d83ec
systems: support cross-compiling for Renesas RX microcontrollers (#173858) 2022-05-22 20:52:36 -04:00
Naïm Favier
ceebdcfc2c
lib/types: allow custom submoduleWith descriptions
Currently the only way to set the description for a submodule type is to
use `freeformType`. This is not ideal as it requires setting a
freeform type, and evaluates the submodule config unnecessarily.

Instead, add a `description` argument to `submoduleWith`.
2022-05-19 17:06:39 +02:00
Robert Hensing
2d1a34b8cc
Merge pull request #172813 from hercules-ci/functionTo-properly
`lib.types.functionTo` type merging and docs
2022-05-17 22:22:21 +02:00
Silvan Mosberger
e06f66e73c
Merge pull request #170561 from klemensn/types-description
lib/types: Drop misleading plural from type descriptions
2022-05-16 17:03:37 +02:00
adisbladis
161776ec1e Revert "lib: init flakes.nix"
This reverts commit PR #167947.

Flakes aren't standardised and the `lib` namespace shouldn't be
polluted with utilities that serve only experimental uses.
2022-05-15 22:39:46 +12:00
Robert Hensing
81a0a8be29 lib/tests/modules: Test functionTo submodule merging too 2022-05-13 09:09:16 +02:00
Robert Hensing
062bc5e74a lib.types.functionTo: Add pseudo-attr to generated docs 2022-05-13 09:01:05 +02:00
Robert Hensing
06da97fc3a lib.types.functionTo: Support type merging 2022-05-13 09:01:05 +02:00
Robert Hensing
f771d39750
Merge pull request #171946 from ncfavier/toShellVars-derivations
lib/strings/toShellVars: handle derivations as strings
2022-05-12 14:43:48 +02:00
Fabian Affolter
b544d177a2 lib.licenses: add DRL-1.0
https://spdx.org/licenses/DRL-1.0.html
https://github.com/SigmaHQ/sigma/blob/master/LICENSE.Detection.Rules.md
2022-05-10 11:11:40 +02:00
Robert Hensing
4d2237c841 lib.foldAttrs: Clarify example 2022-05-10 07:01:00 +02:00
Naïm Favier
4d2ea62d82
lib/strings/toShellVars: handle derivations as strings 2022-05-07 17:01:51 +02:00
matthewcroughan
4d9801a78f lib: add inPureEvalMode
This makes a value that is true if builtins does not contain the
currentSystem function, but false if it does.
2022-05-06 15:42:52 +01:00
Rick van Schijndel
b9e8ed239f
Merge pull request #161156 from a-m-joseph/abort-on-failed-platform-detection-instead-of-silently-assuming-pc
platforms.nix: use {} on failed detection instead of silently assuming pc
2022-05-04 05:37:16 +02:00
Adam Joseph
006c38fa53 platforms.nix: use {} on failed detection instead of silently assuming pc
This patch causes the autodetection code in lib/systems/platforms.nix
to return {} if it cannot detect the platform and one of the
platform.nix-detection-provided attributes (linux-kernel, gcc, and
rustc) are accessed, rather than silently assuming the "pc" platform
as was previously done.

It is definitely safe to assume that code using these attributes is
prepared to deal with `gcc` and `rustc` not being defined, because
many of the working entries in this file don't define it.

Regarding `linux-kernel` the situation is less certain, but some code
(`lib/systems/default.nix` for example) is already designed to deal
with that attribute being missing.  At worst it would result in an
"attribute not found" error.

While adding mips64el bootstrap support to nixpkgs, the silent
assumption that mips64el routers are actually Intel PCs caused
significant frustration.  This commit removes that assumption in order
to save people who port nixpkgs to new platforms in the future from
this frustration.
2022-05-03 13:31:41 -07:00
Robert Hensing
9252a7daa8 lib/tests/modules.sh: Fix for singular type descriptions 2022-05-02 10:41:47 +02:00
Robert Hensing
761c21a16a
Merge pull request #170090 from danth/has-infix-toString
lib/strings: call toString within hasInfix
2022-05-02 09:47:15 +02:00
Daniel Thwaites
7b5be1a0f8 lib/tests: add tests for hasInfix
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-05-02 09:05:56 +02:00
Artturi
a5357d06e4
Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlake
lib: add callLocklessFlake
2022-05-01 23:06:17 +03:00
Daniel Thwaites
e888c2133f
lib/strings: convert to string within hasInfix
This should fix the issue mentioned here:
https://github.com/NixOS/nixpkgs/pull/168175#issuecomment-1107830574
2022-05-01 17:39:42 +01:00
Robert Hensing
c2451ed1a2
Merge pull request #167776 from hercules-ci/lib-modules-allow-disable-_modules.args-docs-internal
lib.modules: Allow making _module.args internal
2022-04-30 13:43:08 +02:00
Alyssa Ross
2a6288d9b9 lib.systems: add riscv{32,64} sets and filters
For other platforms like Intel and ARM, we can do
e.g. lib.platforms.aarch64 to get only the 64-bit ARM platorms, but
until now there were no equivalents for RISC-V.
2022-04-28 08:17:02 +00:00
Alyssa Ross
ed24c902d0 lib/tests: add RISC-V test 2022-04-28 08:17:02 +00:00
Adam Joseph
3e60871330 lib/systems/platforms.nix: use "32" instead of "o32" for mips32 ABI
There is only one ABI for 32-bit MIPS chips.  Before mips64, it didn't
really have a name.

The 64-bit MIPS ABI comes in two flavors, "n64" and "n32".  It is
commonplace to refer to the old 32-bit ABI as "o32" (MIPS and SGI
documents do this).

However, when configuring gcc, one must use --with-abi=32, not
--with-abi=o32.

Let's keep GCC happy with this commit.
2022-04-27 23:46:02 -07:00
Robert Hensing
5f8cb21011
Merge pull request #170583 from ncfavier/mkShellVars
lib/strings: add toShellVars
2022-04-27 23:33:28 +02:00
Naïm Camille Favier
535997fa52
lib/strings: fix quoting of example
Co-authored-by: Silvan Mosberger <github@infinisil.com>
2022-04-27 19:42:40 +02:00
Naïm Favier
226bc99659
lib/strings: add toShellVars
A straightforward piece of plumbing to safely inject Nix variables into
shell scripts:

''
  ${lib.toShellVars { inherit foo bar; }}
  cmd "$foo" --bar "$bar"
''
2022-04-27 16:04:17 +02:00
Klemens Nanni
7bec3e60ef lib/types: Drop misleading plural from type descriptions #170561
Probably being the most prominent document demonstrating the problem,
configuration.nix(5) describes various types in plural, e.g.
- `           Type: list of strings`
- `           Type: list of systemd options`

However, there are other cases where appending "s" to the inner type
effectively changes the type, e.g.
- ```
           Type: list of string matching the pattern
           [a-zA-Z0-9@%:_.\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)s
```

This should've read "list of string[s]..." but instead changes the
regular expression.

Simply drop the best-effort plural in favour of correctness and
simplicity rather than adding more grammar related logic/trying to fix
this.
2022-04-27 05:59:46 +02:00
Artturi
c95f5e185e
Merge pull request #167247 from Artturin/addgetmainprog
lib/meta: add getExe to get the main program of a drv
2022-04-26 21:42:23 +03:00
Robert Hensing
27a62a9c60
Merge pull request #168778 from hercules-ci/issue-168767-extendModules-module-dedup-collision
`lib.types.submoduleWith`: Avoid `_key` collisions after `extendModules` (issue #168767)
2022-04-26 13:01:28 +02:00
Sandro
294ed1bed7
Merge pull request #168111 from a-m-joseph/lib-systems-inspect-powerpc
lib/systems/inspect.nix: add isPower64
2022-04-25 02:22:48 +02:00
Artturin
379b9c8be3 lib/meta: add getExe to get the main program of a drv 2022-04-24 04:19:49 +03:00
Robert Hensing
224426ba6d lib.types.submoduleWith: Avoid _key collisions after extendModules 2022-04-24 00:07:59 +02:00
Daniel Thwaites
4f9b8a0702
lib/strings: optimise hasInfix function (#168175)
* lib/strings: optimise hasInfix function

* lib/strings: optimise hasInfix further using regex

* rstudio: call hasInfix with a string

* lib/strings: remove let from hasInfix

Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>

Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
2022-04-22 12:43:25 -04:00
Artturin
4aab12d5a1 lib/systems/platforms: correctly import examples.nix
before: :p lib.systems failed with
error: getting status of '...examples': no such file or directory
2022-04-15 20:25:58 +03:00
matthewcroughan
3f128cc024 lib/tests: evaluate value from subflake with callLocklessFlake 2022-04-12 21:22:36 +01:00
matthewcroughan
ec59145c3b lib/tests: use subflake to test callLocklessFlake 2022-04-12 20:38:55 +01:00
matthewcroughan
cc052779fb lib/tests: add test for callLocklessFlake 2022-04-12 19:47:48 +01:00
matthewcroughan
cad8bbe589 lib: init flakes.nix
This commit creates flakes.nix, which is a library containing functions
which relate to interacting with flakes. It also moves related functions
from trivial.nix into it.
2022-04-12 19:28:23 +01:00
matthewcroughan
c190b08bb7 lib: add callLocklessFlake
This is essentially a copy of the function of the same name, from
flake-compat. callLocklessFlake is useful when trying to utilise a
flake.nix without a lock file, often for when you want to create a
subflake from within a parent flake.

Co-authored-by: Tom Bereknyei <tomberek@gmail.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-04-12 19:27:24 +01:00
Maximilian Bosch
7203788068
lib/generators: withRecursion: don't break attr-sets with special attrs
Closes #168327

The issue reported there can be demonstrated with the following
expression:

    → nix-instantiate --eval -E "with import ./. {}; pkgs.lib.options.showDefs [ { file = \"foo\"; value = pkgs.rust.packages.stable.buildRustPackages; } ]"
    error: attempt to call something which is not a function but a string

           at /home/ma27/Projects/nixpkgs/lib/trivial.nix:442:35:

              441|   isFunction = f: builtins.isFunction f ||
              442|     (f ? __functor && isFunction (f.__functor f));
                 |                                   ^
              443|

Basically, if a `__functor` is in an attribute-set at depth-limit,
`__functor` will be set to `"<unevaluated>"`. This however breaks
`lib.isFunction` which checks for a `__functor` by invoking `__functor`
with `f` itself.

The same issue - "magic" attributes being shadowed by `withRecursion` -
also applies to others such as
`__pretty`/`__functionArgs`/`__toString`.

Since these attributes have a low-risk of causing a stack overflow
(because these are flat attr-sets or even functions), ignoring them in
`withRecursion` seems like a valid solution.
2022-04-12 12:34:23 +02:00
Robert Hensing
14aa201b65 lib.modules: Allow making _module.args internal
This allows other module system consumers to
disable these docs via option merging.

For instance arion uses asciidoc instead of
docbook so that would look awful.
2022-04-11 11:17:34 +02:00
Adam Joseph
81afd541f9 lib/systems/inspect.nix: add isPower64
This commit adds an `isPower64` predicate to the two existing
predicates for this architecture (`isPower` and `isPowerPC`).

Note that `isPowerPC` matches only 32-bit machines, whereas `isPower`
matches both 64-bit and 32-bit machines.  Prior to this commit there
was no single `isXXX` predicate for `powerpc64le`.
2022-04-10 01:56:28 -07:00
Silvan Mosberger
180173a1c4
Merge pull request #164088 from Profpatsch/lib.generators-add-toINIWithGlobalSection
lib.generators: add toINIWithGlobalSection
2022-04-06 19:02:36 +02:00
Robert Hensing
c705953267
Merge pull request #165540 from Infinisil/module-args-docs
lib/modules: Document `_module.args`
2022-04-05 21:51:46 +02:00
Robert Hensing
559ac3c9e7
Merge pull request #166383 from hercules-ci/always-sanitize-derivation-name
Always sanitize derivation name
2022-04-05 20:05:33 +02:00
Robert Hensing
fffabe7500 lib.sanitizeDerivationName: Simplify regex
`^` and `$` are implicit in `match`.
2022-04-05 19:14:09 +02:00
Silvan Mosberger
25de2935ef lib/modules: Document _module.args
Documents the _module.args option, motivated by many usages in Flakes,
especially with the deprecation of extraArgs
(78ada83361)

The documentation rendering for this option had to be handled a bit
specially, since it's not declared in nixos/modules like all the other
NixOS options.

Co-Authored-By: pennae <github@quasiparticle.net>
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2022-04-05 18:26:40 +02:00
Silvan Mosberger
1c00bf3948 lib/customization: Improve callPackage error message for missing args
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With https://github.com/NixOS/nix/pull/3468 (in current nixUnstable) the error
message becomes even better, adding line location info
2022-04-01 22:03:05 +02:00
Silvan Mosberger
f8c1aee5da lib/tests: Add tests for levenshtein functions 2022-04-01 22:03:05 +02:00
Silvan Mosberger
975a1ae339 lib/strings: Add levenshtein distance functions
Adds some functions related to string similarity:
- lib.strings.commonPrefixLength
- lib.strings.commonSuffixLength
- lib.strings.levenshtein
- lib.strings.levenshteinAtMost
2022-04-01 22:03:05 +02:00
Robert Hensing
2999ab114e lib.sanitizeDerivationName: Test with unicode 2022-03-31 18:31:11 +02:00
Robert Hensing
342a3c32c9 lib.sanitizeDerivationName: Optimize the common case 2022-03-31 18:31:11 +02:00
github-actions[bot]
03106b0236
Merge master into haskell-updates 2022-03-29 00:12:40 +00:00
Robert Hensing
9dd71d8c50
Merge pull request #165956 from ncfavier/lib-warn-throw
lib/trivial: actually expose warnIfNot and throwIf
2022-03-28 14:07:53 +02:00
github-actions[bot]
f0839d8bcd
Merge master into haskell-updates 2022-03-28 00:11:42 +00:00
Naïm Favier
9f5796be49
lib/trivial: actually expose warnIfNot and throwIf 2022-03-27 16:48:33 +02:00
Sandro
ac5ea36581
Merge pull request #165672 from yoctocell/patatt-init 2022-03-27 14:53:39 +02:00
Sandro
3cc111d919
Merge pull request #165597 from ckiee/generaluser-init 2022-03-27 12:54:25 +02:00
sternenseemann
372d0a707e Merge remote-tracking branch 'origin/master' into haskell-updates 2022-03-26 09:59:28 +01:00
Silvan Mosberger
99d9d45630
Merge pull request #164651 from Infinisil/remove-optionSet
lib/modules: Finally remove deprecated types.optionSet
2022-03-25 17:41:57 +01:00
github-actions[bot]
79b7796557
Merge master into haskell-updates 2022-03-25 00:11:06 +00:00
Xinglu Chen
e13494d071
lib.licenses: add MIT-0
<https://spdx.org/licenses/MIT-0.html>
2022-03-24 18:49:26 +01:00
Robert Hensing
ce5a33e62b
Merge pull request #164660 from ncfavier/tests-restrict-arguments
nixos/testing: restrict arguments to makeTest
2022-03-24 17:01:47 +01:00