Commit Graph

3384 Commits

Author SHA1 Message Date
github-actions[bot]
4688cd53b6
Merge master into staging-next 2023-02-23 18:01:15 +00:00
Alyssa Ross
7ce8e7c4cf lib.licenses.asl20-llvm: replace llvm-exception
LLVM-exception only makes sense when used with the Apache 2.0 license,
so let's combine them, so it's not possible to forget one of them like
happened with llvm_15.
2023-02-23 17:42:15 +00:00
github-actions[bot]
390b789c39
Merge master into staging-next 2023-02-23 12:01:07 +00:00
hsjobeki
09ee6241b5 improves: comprehensiveness 2023-02-23 11:24:47 +01:00
hsjobeki
70c36dcfb8 add better documentation comments to lib.runTests 2023-02-23 10:21:58 +01:00
github-actions[bot]
fd8dd0c966
Merge master into staging-next 2023-02-21 18:01:08 +00:00
Naïm Favier
f77c364def
Merge pull request #216983 from ncfavier/showOption-comment
lib/options: update showOption comment
2023-02-21 16:31:07 +01:00
Naïm Favier
6c7d4d4f9d
lib/options: update showOption comment 2023-02-18 18:13:11 +01:00
github-actions[bot]
bf5abe92d4
Merge master into staging-next 2023-02-15 18:01:14 +00:00
Sandro
d05e6727a2
Merge pull request #203539 from SuperSandro2000/architectures-expand-inferiors
lib/systems/architectures: expand inferiors
2023-02-15 16:27:00 +01:00
Silvan Mosberger
1a2c2846b0 lib.path.subpath.join: init
This function can be used to safely join subpaths together
2023-02-13 14:01:17 +01:00
github-actions[bot]
0417b0e54f
Merge staging-next into staging 2023-02-10 00:03:00 +00:00
Domen Kožar
844a738b1f
Merge pull request #215455 from domenkozar/module-errors
nixos: Improve module conflict error messages
2023-02-10 02:42:28 +07:00
OPNA2608
235d9e2187 lib/licenses.nix: Add cc-by-nc-nd-30 2023-02-09 15:50:20 +01:00
Domen Kožar
fe734efc9c types: suggest how to resolve the conflict 2023-02-09 08:24:12 +00:00
Domen Kožar
b3cc29c288 types: explicitly state unique options are expected to be unique 2023-02-09 07:25:50 +00:00
github-actions[bot]
371c2a6303
Merge staging-next into staging 2023-02-07 18:02:15 +00:00
markuskowa
5cf138823d
Merge pull request #214930 from sheepforce/nwchem
nwchem: init at 7.0.2
2023-02-07 17:30:02 +01:00
Silvan Mosberger
a770c0393c
Merge pull request #208887 from tweag/lib.path.append
lib.path.append: init
2023-02-07 17:27:37 +01:00
Phillip Seeber
acb812207f lib/licenses: add ecl20 2023-02-07 10:39:46 +01:00
github-actions[bot]
99cce0e1f1
Merge staging-next into staging 2023-02-07 06:02:00 +00:00
Silvan Mosberger
0a60663e67
Merge pull request #206611 from h7x4/lib-lists-add-repeat
lib.lists: add `replicate`
2023-02-07 06:16:09 +01:00
github-actions[bot]
d3648def80
Merge staging-next into staging 2023-02-07 00:02:46 +00:00
Bernardo Meurer
7b7b6c248c
Merge pull request #214856 from vamega/bencode-py 2023-02-06 15:58:58 -05:00
h7x4
7c4abbf80e
lib.lists: add replicate
`replicate` returns n copies of an element as a list.

Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2023-02-06 20:40:47 +01:00
Varun Madiath
dedb550ce6 bencode-py: init at 4.0.0 2023-02-06 12:14:15 -05:00
Artturi
dcc7df7fe6
Merge pull request #211685 from Artturin/splicingstuff1-split 2023-02-03 12:49:08 +02:00
Silvan Mosberger
50e4dbf35b
Merge pull request #205557 from ncfavier/concatLines
lib/strings: add `concatLines`
2023-01-31 18:05:53 +01:00
Silvan Mosberger
96d4702261
Merge pull request #213650 from urandom2/libdoc
lib: standardise attrset type syntax
2023-01-31 16:20:56 +01:00
github-actions[bot]
dd1ff149da
Merge master into staging-next 2023-01-31 00:02:31 +00:00
Colin Arnott
6ff66fcbd7
lib: standardise attrset type syntax
There are a number of different syntaxes used for attrset type
signatures in our doc strings, this change standardises upon one that
uses :: for specifying attribute type, and ; terminators to be
consistent with nix syntax. There are no bugs in the functions
themselves, just that different syntaxes may confuse new users.
2023-01-30 23:53:44 +00:00
Florian Klink
31931ffc35
Merge pull request #212939 from amjoseph-nixpkgs/pr/isStatic
meta: replace predicates with pattern over elaborated platform
2023-01-30 21:13:15 +01:00
Alyssa Ross
aa51704ba5
lib.systems.inspect.patterns.isEfi: drop ARMv5
I'm not aware of any ARMv5 EFI implementation.  gnu-efi doesn't
support it, so the build of systemd for armv5tel-linux is broken if
it's isEfi.
2023-01-30 19:54:06 +00:00
Robert Hensing
663c41affd
Merge pull request #212282 from hercules-ci/pkg-config-packages
defaultPkgConfigPackages: init
2023-01-30 09:48:53 +01:00
Robert Hensing
473ac9692e lib.hydraJob: Tolerate null
By allowing null, we allow code to avoid filterAttrs, improving
laziness in real world use cases.
Specifically, this strategy prevents infinite recursion errors,
performance issues and possibly other errors that are unrelated to
the user's code.
2023-01-30 00:35:34 +01:00
Alyssa Ross
4f8a5065d7
lib.systems.inspect.patterns.isEfi: remove "aarch64"
There is no "aarch64" CPU family — it counts as "arm", as can be seen
from the definition of isAarch64 above.

Checked that stdenv.hostPlatform.isEfi is still true on aarch64-linux.
2023-01-29 16:29:47 +00:00
Naïm Favier
0288ee587f
maintainers: clarify what fields are required 2023-01-27 18:05:28 +01:00
Naïm Favier
93dc2de29a
maintainers: disallow noreply.github.com emails 2023-01-27 18:05:28 +01:00
Naïm Favier
4e39849611
maintainers: make email optional
Not giving an email address is fine as long as the maintainer is
reachable through other means, such as GitHub or Matrix.
2023-01-27 18:04:20 +01:00
Adam Joseph
9c0a3417c8
Update lib/systems/inspect.nix
Co-authored-by: Naïm Favier <n@monade.li>
2023-01-27 11:56:20 +00:00
Adam Joseph
009a3f1857
Update lib/systems/inspect.nix
Co-authored-by: Naïm Favier <n@monade.li>
2023-01-27 11:16:35 +00:00
Adam Joseph
435618d9b3
Update lib/meta.nix
Co-authored-by: Naïm Favier <n@monade.li>
2023-01-27 11:16:29 +00:00
Adam Joseph
6f942d4a17
Update lib/meta.nix
Co-authored-by: Naïm Favier <n@monade.li>
2023-01-27 11:16:19 +00:00
Adam Joseph
ea0bcf2505 lib/systems/inspect.nix: add platformPatterns.isStatic 2023-01-27 02:21:23 -08:00
Adam Joseph
1690aa6858 lib/meta.nix: allow patterns over entire platform, not just .parsed 2023-01-27 02:19:30 -08:00
Adam Joseph
778419b9e6 Revert "lib/meta.nix: platformMatch: allow predicate functions"
This reverts commit b7d097438b.
2023-01-27 01:49:39 -08:00
Robert Hensing
683887a79c
Merge pull request #212189 from amjoseph-nixpkgs/pr/lib/mapAttrsRecursive/comment
attrsets: clarify that mapAttrs maps over *leaf* attrs
2023-01-25 10:18:38 +01:00
Adam Joseph
a4e3e16258
Update lib/attrsets.nix
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-01-25 02:52:54 +00:00
Pascal Wittmann
353e2d957c
Merge pull request #212408 from raboof/imapsync-fix-license
imapsync: fix license
2023-01-24 11:29:22 +01:00
Arnout Engelen
9b79245235
licenses: add NLPL 2023-01-24 11:24:04 +01:00
Sandro
9441b22187
Merge pull request #209769 from LoveIsGrief/simple-dlna-browser 2023-01-23 23:52:58 +01:00
Adam Joseph
ee00af7a32 attrsets: clarify that mapAttrs maps over *leaf* attrs 2023-01-22 15:19:09 -08:00
Adam Joseph
b7d097438b lib/meta.nix: platformMatch: allow predicate functions 2023-01-22 00:27:19 -08:00
Atemu
44e5b41871 lib/systems/parse: stop considering armv8a able to execute armv7l
In the past, most (if not all) armv8 CPUs could also execute armv7. However,
with the advent of Apple Silicon, aarch64 CPUs without any aarch32 capabilities
are now wide-spread among users.
2023-01-21 16:28:49 +01:00
Robert Hensing
5b2f597b11 lib.extendDerivation: Fix interaction between output selection and overrideAttrs 2023-01-20 02:45:34 +02:00
Robert Hensing
a1b2177ec4
Merge pull request #210976 from clhodapp/fix/extensible-sets
lib: make extender available on self-references
2023-01-20 01:08:16 +01:00
John Ericson
c1071e7804
Merge pull request #211622 from alyssais/valgrind-platforms
valgrind: make meta.platforms more accurate
2023-01-19 15:43:22 -05:00
Alyssa Ross
6d165a9474
lib.platforms.s390x: init 2023-01-19 17:43:50 +00:00
Alyssa Ross
541a2a5e91
lib.platforms.power: init 2023-01-19 17:43:49 +00:00
Alyssa Ross
48f3fd2d49
lib.platforms.armv7: init 2023-01-19 17:43:41 +00:00
Silvan Mosberger
eac2538707 lib.path.append: init
This function can be used to append strings to Nix path values in a
safe way.
2023-01-18 20:17:31 +01:00
Silvan Mosberger
5c4f616198 lib.path: Minor improvements
- Use isValid when possible instead of subpathInvalidReason: https://github.com/NixOS/nixpkgs/pull/209099#discussion_r1068714681
- Add documentation to function arguments
- Use newlines for error messages: https://github.com/NixOS/nixpkgs/pull/208887#discussion_r1069737602
- Add short comments for the unit test groups: https://github.com/NixOS/nixpkgs/pull/208887#discussion_r1072913051
- Slight formatting improvement for laws: https://github.com/NixOS/nixpkgs/pull/209099#discussion_r1068707955
2023-01-18 18:19:17 +01:00
Robert Hensing
415504e867 lib/tests/release.nix: Make nix a parameter + strictDeps
This makes bisecting nix a bit easier.

Example reproducer, invoked from nix directory:

```bash
nix-build ../nixpkgs/lib/tests/release.nix --arg nix '(builtins.getFlake "git+file://${toString ./.}").packages.x86_64-linux.default'
```
2023-01-18 01:39:38 +01:00
OPNA2608
991a22a7d0 licenses: Remove unnecessary archive.org link for APSL-1.0
SPDX has a copy of it, and the url gets overridden with the spdx.org one anyway.
2023-01-17 12:10:41 +01:00
Chris Hodapp
06f0e49dc6 lib: make extender available on self-references 2023-01-15 11:34:05 -08:00
Nick Cao
35bede2be5
Merge pull request #184521 from dramforever/riscv-isefi
lib/systems/inspect.nix: Add riscv to isEfi
2023-01-13 14:28:11 +08:00
Adam Joseph
098c6b0bec check-meta(hasUnsupportedPlatform): use lib.meta.availableOn
`hasUnsupportedPlatform` was not updated with #37395, so it does not
understand attrsets in `meta.[bad]platforms`.  In particular,
attrsets in `meta.badPlatforms` will "fail open" and be ignored.

Let's use `lib.meta.availableOn` instead of duplicating its logic.

Thanks to @alyssais for [noticing][1].

[1][https://github.com/NixOS/nixpkgs/pull/194148#discussion_r990817610]

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2023-01-11 19:31:52 +00:00
Adam Joseph
0b90e548b5 lib/meta(availableOn): handle missing meta and empty meta.platform 2023-01-11 19:31:52 +00:00
LoveIsGrief
346b939a09
lib/licenses add Fair license 2023-01-10 23:10:24 +01:00
Artturi
6ce54982ec
Merge pull request #209974 from amjoseph-nixpkgs/pr/close/209952 2023-01-10 18:33:27 +02:00
Silvan Mosberger
041b044a66 lib/path/tests: Fix property tests when "-n" is generated
When "-n" is generated by the property tests, it causes `echo` to not
output the string since it's interpreted as an option. Apparently
there's no good way to print "-n" with `echo` [1], so switching to
`printf` instead

[1]: https://unix.stackexchange.com/questions/85846/how-can-i-print-n-with-echo
2023-01-10 14:18:35 +01:00
Adam Joseph
06939ff3de add mipsisa{32,64}r6[el], closes 209952 2023-01-09 16:04:16 -08:00
Naïm Favier
fb1bc8de93
lib/modules: make mkAliasOptionModule emit DocBook
Follow-up to https://github.com/NixOS/nixpkgs/pull/208407

Removing `mdDoc` isn't enough, we need to emit actual DocBook.
2023-01-08 22:44:18 +01:00
Silvan Mosberger
d35cae9696
Merge pull request #208674 from YoshiRulz/yoshi-lib-docs
lib: Fix mismatched quotes in `lib.*` doc comments
2023-01-05 19:00:38 +01:00
pennae
e912c7bfe9 lib/modules: hide _module.args docs
unfortunately we can't unconditionally make this text markdown without
impacting downstream users of docs generation (as noted in #175586).
hide it entirely until the transition is complete.
2023-01-05 02:33:13 +01:00
pennae
9da5f12ecf modules: add mkPackageOptionMD
another transitional option factory, like mkAliasOptionModuleMD.
2023-01-05 02:33:13 +01:00
pennae
4c1cfbdb84 modules: add mkAliasOptionModuleMD
mkAliasOptionModule should not default to mdDoc descriptions because
that can break out-of-tree users of documentation infrastructure. add an
explicitly-MD variant for now, to be removed some time after the MD
transition is complete.
2023-01-05 02:33:13 +01:00
Robert Hensing
f61d4d346b
Merge pull request #205190 from NixOS/lib.path.relativeNormalise
lib.path.subpath.{isValid,normalise}: init
2023-01-03 13:46:11 +01:00
Silvan Mosberger
0667ef5dd5 lib.path.subpath.normalise: add property tests 2023-01-03 13:21:06 +01:00
Silvan Mosberger
63dd6d20db lib.path.subpath.normalise: init 2023-01-03 13:21:03 +01:00
Silvan Mosberger
98fbcf1788 lib.path.subpath.isValid: init
The first path library function
2023-01-03 13:20:36 +01:00
Silvan Mosberger
ba7ed22f84 lib.path: init README.md document
Adds initial work towards a `lib.path` library

Originally proposed in https://github.com/NixOS/nixpkgs/pull/200718, but has
since gone through some revisions

Co-Authored-By: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-01-03 13:19:42 +01:00
Martin Weinelt
b38111a665
Merge pull request #208698 from amjoseph-nixpkgs/pr/nss/ilp32 2023-01-03 07:00:45 +01:00
Adam Joseph
14f337afb6 lib/systems/inspect.nix: add isILP32 predicate
I've run into a few packages that need an extra flag on platforms
where `int` has more bits than `void*` does.  I know of three such
platforms:

* [aarch64ilp32], used on both Linux and also on the [Apple Watch]
* [x32], the x86 ILP32 ABI
* [mips64n32], used on [Longsoon] and Cavium Octeon routers.

This PR introduces a predicate so the package flags can be added in
a generic way.

[Apple Watch]: https://gist.github.com/woachk/943828f37c14563a607a26116435bf27#watch
[mips64n32]: https://en.wikipedia.org/wiki/MIPS_architecture#Calling_conventions
[Longsoon]: https://en.wikipedia.org/wiki/Loongson
[x32]: https://en.wikipedia.org/wiki/X32_ABI
2023-01-01 17:16:06 -08:00
Adam Joseph
de88969f12 lib/systems: fix uname.processor for powerpc{32,64}, mips64
Cross-compilation of anything downstream of gtk3 requires qemu (due to
gobject-introspection) with --target-list=*-linux-user.  Without this commit,
those qemu builds will fail on a powerpc64le host due to qemu being configured
with --cpu=powerpc64le instead of --cpu=ppc64le.  Unfortunately the build
failure message from qemu in this situation is extremely cryptic.

The root cause turns out not to be the qemu expression, but rather the fact that
on powerpc64le hostPlatform.uname.processor returns the gnu-name (powerpc64le)
for the cpu instead of the linux-name (ppc64le) for the cpu.

uname.processor on mips64el also needs adjustment -- the Linux-name is "mips64"
for both big and little endian (unlike powerpc64, where the Linux-name includes
a "le" suffix):

```
nix@oak:/tmp$ uname -m; lscpu | head -n2
mips64
Architecture:        mips64
Byte Order:          Little Endian
```

uname.processor on powerpc32 has also been adjusted.
2023-01-01 16:20:50 -08:00
YoshiRulz
7fba83890c
lib: Fix mismatched quotes in lib.* doc comments
caused problems for automated rich text generation such as
https://teu5us.github.io/nix-lib.html#customisation-functions
2023-01-02 08:25:17 +10:00
Martin Weinelt
192f844477
lib/trival: Bump oldestSupportedRelease to 2211 2023-01-01 14:57:25 +01:00
Naïm Favier
4af22aab8e
stdenv/check-meta: do deep type checks
Use a wrapper around `mergeDefinitions` to type-check values deeply, so
that e.g. `maintainers = [ 42 ];` is an error.
2023-01-01 14:10:42 +01:00
Naïm Favier
4df10debe7
lib/customisation.overrideDerivation: propagate evaluation condition
The new derivation should evaluate only if the old derivation does.

Sadly this means that the old derivation cannot depend on the new one
any more, which was used by xorgserver on Darwin. But this is not a
problem as `overrideAttrs` can (and should) usually be used instead.

This change allowed catching an invalid `meta.platforms` in the linux_rpi
kernels, which use `overrideDerivation`.
2023-01-01 14:10:42 +01:00
Robert Hensing
cb98e26aaf lib: Add isStringLike 2022-12-31 01:47:28 +01:00
Robert Hensing
d103811173 lib.isStringLike: Remove use of list
In the current implementation of Nix, this list would be allocated
over and over. Iirc pennae tried to optimize static list allocation,
but gained no significant performance improvement.
2022-12-31 01:33:47 +01:00
Robert Hensing
d0d0f7d0aa lib: Add isPath
Available since Nix 2.3, which is the Nixpkgs minimum version.
Thanks zimbatm!
2022-12-31 01:33:47 +01:00
Robert Hensing
23c25d5231 lib.strings.isConvertibleWithToString: Refactor to reuse isStringLike 2022-12-31 01:33:47 +01:00
Robert Hensing
834f0d660a lib.strings: isMoreCoercibleString -> isConvertibleWithToString
Yes, this function name is inconveniently long, but it is important
for the name to explicitly reference the function and not be mistaken
for the implicit string conversions, which only happen for a smaller
set of values.
2022-12-31 01:33:47 +01:00
Robert Hensing
872a24ebbc lib.strings: isSimpleCoercibleString -> isStringLike 2022-12-31 01:33:46 +01:00
Robert Hensing
29efb2c438 lib.types.path: Do not allow lists of strings 2022-12-31 01:03:24 +01:00
Robert Hensing
fed5dc66f8 treewide: isCoercibleToString -> isMoreCoercibleToString
No change in behavior.
2022-12-31 01:03:24 +01:00
Robert Hensing
68b6443ed6 lib.strings: Rename isCoercibleToString -> isMoreCoercibleToString 2022-12-31 01:03:24 +01:00
Robert Hensing
3a4c9bdbe6 lib.types.anything: Use isSimpleCoercibleToString
Expecting no change in behavior.
2022-12-31 01:03:24 +01:00
Robert Hensing
03063f65a5 lib.strings.toShellVar: Use isSimpleCoercibleString
Expecting no change in behavior.
2022-12-31 01:03:24 +01:00
Robert Hensing
2b4a8db032 lib.strings.isStorePath: Use isSimpleCoercibleToString
Expecting no change in behavior.
2022-12-31 01:03:24 +01:00
Robert Hensing
67cfc7a8f6 lib.strings: Add isSimpleCoercibleToString 2022-12-31 01:03:23 +01:00
Ryan Lahfa
30307eba48
Merge pull request #207453 from p-h/ulogd
ulogd: init at 2.0.8
2022-12-30 14:13:53 +01:00
Robert Hensing
ef9b04ec5f lib.types.loaOf: Update comment to say deprecate instead of remove 2022-12-29 00:49:32 +01:00
Robert Hensing
9af74cc709 Revert "lib/types: remove loaOf"
This reverts commit c8c538f2ab.

Reason: removal did not follow a deprecation process and it hurts
        nixops 1.7 users.
2022-12-29 00:48:22 +01:00
Philippe Hürlimann
c3161d81bd linuxdoc-tools: init at 0.9.82
Heavily based on original work by xvuko

Co-authored-by: xvuko <nix@vuko.pl>
2022-12-28 00:17:27 +01:00
Naïm Favier
3fc528ff7f
Merge pull request #207095 from ncfavier/linux-custom-kernel 2022-12-27 17:10:43 +01:00
Sandro
f3ae2deafb
Merge pull request #206809 from SuperSandro2000/loaOf 2022-12-25 21:39:52 +01:00
hsjobeki
5ff21bfc73 attrsets: fix and add some doc types 2022-12-24 14:08:11 +01:00
Naïm Favier
0355479715
lib/versions: add pad
Pad a version string with zeros to match a given number of components.
2022-12-21 12:58:21 +01:00
Sandro
708d255245
Merge pull request #205899 from drupol/font/add-garamond-libre
garamond-libre: init at 1.4
2022-12-20 15:56:47 +01:00
Naïm Favier
8b5deda7d8
lib/strings: replace poop emoji (#206999) 2022-12-20 13:48:09 +01:00
Pol Dellaiera
c690067fec
garamond-libre: init at 1.4 2022-12-20 08:35:00 +01:00
Robert Hensing
6db219730e
Merge pull request #205563 from hercules-ci/lib-modules-doc-default-and-example-error-context
lib.modules: Add error context to rendered default and example attrs
2022-12-19 23:58:50 +01:00
Sandro Jäckel
c8c538f2ab
lib/types: remove loaOf 2022-12-19 08:31:43 +01:00
figsoda
695d4bc76b lib: fix typos 2022-12-17 18:59:29 -05:00
Artturin
05a2dfd674 lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
2022-12-15 22:25:51 +02:00
Robert Hensing
efa1140e83
Merge pull request #205457 from h7x4/lib-strings-toInt-broken-for-negative-numbers
lib.strings: fix negative number handling for `toInt` and `toIntBase10`
2022-12-11 02:26:42 +01:00
Robert Hensing
1a44080088 lib.generators.toPretty: Add attribute name to error context 2022-12-10 23:36:46 +01:00
Robert Hensing
5fb20d2f8c lib.modules: Add error context to rendered default and example attrs 2022-12-10 23:23:42 +01:00
Naïm Favier
ed0b8c26f1
lib/strings: add concatLines
Like `unlines` from Haskell.

The aim is to replace the `concatStringsSep "\n"` pattern for generated
files, which doesn't add a final newline.
2022-12-10 15:56:30 +01:00
h7x4
62e863e98c
lib.strings: fix negative number handling for toInt and toIntBase10
The previous version would be unstable due to an input validation regex
not expecting a '-' in front of the number.
2022-12-10 13:16:45 +01:00
Valentin Gagarin
a2b6bd7b35
Merge pull request #126213 from ryantm/lib-doc-gen
doc: auto-generate asserts and attrset library docs
2022-12-09 09:33:35 +01:00
Ryan Mulligan
ac1ae0a58e doc: auto-generate asserts and attrset library docs
If all the docs are auto-generated, it should be easier to convert
them to Commonmark.

Co-Authored-By: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2022-12-08 22:58:22 +01:00
Naïm Favier
6a117e2759 nixos/doc: render option values using lib.generators.toPretty
Render un`_type`d defaults and examples as `literalExpression`s using
`lib.generators.toPretty` so that consumers don't have to reinvent Nix
pretty-printing. `renderOptionValue` is kept internal for now intentionally.

Make `toPretty` print floats as valid Nix values (without a tilde).

Get rid of the now-obsolete `substSpecial` function.

Move towards disallowing evaluation of packages in the manual by
raising a warning on `pkgs.foo.{outPath,drvPath}`; later, this should
throw an error. Instead, module authors should use `literalExpression`
and `mkPackageOption`.
2022-12-08 17:52:52 +01:00
Naïm Favier
0b661ce32a lib/generators.toPretty: escape strings properly 2022-12-08 17:52:52 +01:00
Naïm Favier
0fa7b1b004 lib/generators.toPretty: don't evaluate derivations
With the goal of making `toPretty` suitable for rendering option
values, render derivations as `<derivation foo-1.0>` instead of
`<derivation /nix/store/…-foo-1.0.drv>`.

This is to avoid causing sudden evaluation errors for out-of-tree
projects that have options with `default = pkgs.someUnfreePackage;` and
no `defaultText`.
2022-12-08 17:52:52 +01:00
Naïm Favier
22af649d14
Merge pull request #204087 from ncfavier/splitString-simplify 2022-12-08 13:30:50 +01:00
AndersonTorres
85b6175ccb lib/default.nix: include mesonOption-related functions
To bring them to the scope when calling `lib`.
2022-12-06 23:09:36 -03:00
AndersonTorres
762f0a599e lib/strings.nix: add mesonOption utility function
And some friends, to help write Meson commandline invocations.
2022-12-06 23:09:36 -03:00
Valentin Gagarin
260de5901e
Merge pull request #204103 from ncfavier/doc-mkOrder
nixos/doc: document `mkOrder` and friends
2022-12-02 17:19:40 +01:00
Naïm Favier
e8927c46b8
nixos/doc: document mkOrder and friends
Add a section on ordering option definitions.

Also mention `mkDefault` in the section on `mkOverride`.

Clarify the code a bit by renaming `defaultPriority` to
`defaultOverridePriority` and introducing `defaultOrderPriority`.
2022-12-02 14:15:24 +01:00
Robert Hensing
6110a6009f lib/modules: Add context to the "option does not exist" error
Add trace items that provide context for a failed definition that
can not be caught within the Nix language.

This also adds a test for the `tryEval` behavior of `showDefs`.
2022-12-02 11:06:53 +00:00
Naïm Favier
3c2124c471
lib/strings: simplify splitString
There's no need to use `unsafeDiscardStringContext` since
ee7fe64c0a
(Nix 1.8).

Also the separator can't have a context since `builtins.split` would fail, so
we can assume it doesn't.
2022-12-02 12:04:36 +01:00
Sandro Jäckel
c5923af986 lib/systems/architectures: expand inferiors 2022-11-29 01:45:05 +01:00
John Ericson
2cb8f1a0ac
Merge pull request #180964 from amjoseph-nixpkgs/pr/mkSkeletonFromList/simplify
lib/systems/parse.nix: mkSkeletonFromList: improve readability
2022-11-22 15:02:22 -05:00
Artturi
761a5ba7d8
Merge pull request #202370 from Artturin/revertpartof1
Revert "lib/trivial: fix 'error: cannot decode virtual path '/nix/sto…
2022-11-22 19:49:35 +02:00
Artturin
f0e298c002 Revert "lib/trivial: fix 'error: cannot decode virtual path '/nix/store/virtual0000000000000000000000005-source''"
This reverts commit b67ee6e861.

https://github.com/NixOS/nixpkgs/issues/202244

error: a string that refers to a store path cannot be appended to a path, at /etc/nixos/nix/nixos-unstable/lib/sources.nix:193:30

appears to happen when there's a nixpkgs git submodule

> So one of the things that is different for a git submodule is that the .git folder isn't a folder, it's a textfile that contains (in my case) this:

> $ cat nix/nixos-unstable/.git
> gitdir: ../../.git/modules/nixpkgs
2022-11-22 18:33:09 +02:00
Martin Weinelt
b68bd2ee52 23.05 is Stoat 2022-11-21 21:22:27 +01:00
Artturi
20fc948445
Merge pull request #170737 from amjoseph-nixpkgs/fix-mips32-detection
lib/systems/platforms.nix: fix broken mips32 detection
2022-11-21 19:40:18 +02:00
figsoda
91969d8d37
Merge pull request #201527 from figsoda/lib
lib/attrsets: add concatMapAttrs
2022-11-21 11:01:43 -05:00
Artturi
8181233059
Merge pull request #201946 from Artturin/splicingstuff2
lib.overrideDerivation: override attrs in __spliced && splice.nix: start deprecating nativeDrv and crossDrv
2022-11-20 15:07:28 +02:00
Artturin
341e6fd558 splice.nix: start deprecating nativeDrv and crossDrv 2022-11-19 00:04:54 +02:00
Artturin
7022556622 lib.overrideDerivation: override attrs in __spliced 2022-11-18 18:44:12 +02:00
Artturin
962929884a lib/sources: make commitIdFromGitRepoOrError internal and use # for comments
so that it doesn't make the manual build fail

> Apparently this is related to the combination of this new function not getting exported from the file, while still getting documented.
2022-11-18 17:17:51 +02:00
figsoda
f993f8a186 lib/attrsets: add concatMapAttrs 2022-11-17 10:41:53 -05:00
figsoda
4536ebad69 lib/attrsets: simplify chooseDevOutputs 2022-11-17 09:41:47 -05:00
Artturi
e3bd5d17b2
Merge pull request #199812 from Artturin/removeusagesoftostringonpath1
lib/sources: remove 2 usages of toString on a path which will be read using fileContents
2022-11-17 15:18:52 +02:00
Gabriel Arazas
62b78d1ead licenses: add bsd2WithViews 2022-11-16 12:01:53 +08:00
Adam Joseph
36a566b78f lib/systems/parse.nix: mkSkeletonFromList: improve readability
The main purpose of this PR is to make the basis for
`mkSkeletonFromList`'s decision between `cpu-kernel-libcabi` vs
`cpu-vendor-os` clear, without changing its behavior.  The existing
code obscures this decision behind a sequence of prioritized matches
(i.e. `if-then`) which jump around between different coordinates.

Two side benefits of this PR:

1. It makes the root cause of #165836 obvious: we are missing a case
   for `cpu-vendor-libcabi`.  This is why nixpkgs stumbles over
   `*-none-*`.

2. It illuminates some very weird corner cases in the existing
   logic, like `*-${vendor}-ghcjs` overriding the `vendor` field,
   and `mingw32` being transformed into `windows` in some cases.

Co-authored-by: John Ericson <git@JohnEricson.me>
2022-11-13 23:08:57 -08:00