Commit Graph

2513 Commits

Author SHA1 Message Date
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
Geoffrey Huntley
bc62fff2cf
lib.licenses: add Prosperity-3.0.0 license (#97832) 2020-09-12 22:13:27 +02:00
zimbatm
035627dff2
lib: allow to import JSON and TOML files
The vision here is that configuration tools can generate .json or .toml
files, which can be plugged into an existing configuration.

Eg:

    { lib, ... }:
    {
      imports = [
        (lib.modules.importJSON ./hardware-configuration.json)
      ];
    }
2020-09-12 16:37:50 +02:00
zimbatm
947a7d33f9
lib: add importTOML
Complements the `lib.importJSON`. `builtins.readTOML` has been
introduced in Nix 2.1.
2020-09-12 16:37:50 +02:00
Frederik Rietdijk
37d29394ec Merge staging-next into staging 2020-09-12 10:00:45 +02:00
Matthew Bauer
86d8c55470
Merge branch 'staging' into ios-13 2020-09-10 23:24:26 -05:00
Matthew Bauer
8483d29d60
Merge pull request #97587 from arcnmx/arch-fix
Fix arch eval error
2020-09-10 14:48:25 -05:00
arcnmx
8f3efbde4e Fix arch eval error introduced in #61019
This occurs when using a `platform.gcc.arch` that isn't one of the
pre-existing hard-coded options.
2020-09-09 12:17:00 -07:00
David Anderson
3a38cef8f9 jasper: remove, abandoned upstream.
Jasper has been marked insecure for a while, and upstream has not
been responsive to CVEs for over a year.

Fixes #55388.

Signed-off-by: David Anderson <dave@natulte.net>
2020-09-09 18:29:42 +00:00
John Ericson
5fd27509cf
Merge pull request #97387 from Ericson2314/fix-android-prebuilt
cc-wrapper: Fix for prebuilt android
2020-09-08 20:24:50 -04:00
John Ericson
e2bef8fbdc lib.systems.examples: Bump android SDK to 21
074bc78cc8 evidently meant to do this, but
forgot.
2020-09-08 09:33:09 -04:00
Jonathan Ringer
1f3587cdd5 21.03 is Okapi
* Okapi is an artiodactyl mammal native to Central Africa
* https://en.wikipedia.org/wiki/Okapi
2020-09-07 14:20:35 -07:00
Silvan Mosberger
ed5a07c0ef
Merge pull request #97114 from Infinisil/type-deprecation
Better type deprecation messages
2020-09-07 19:33:19 +02:00
Silvan Mosberger
f73b762aac
Merge pull request #97042 from Infinisil/freeform-option-docs
Show sub options of freeform types
2020-09-07 19:31:01 +02:00
Silvan Mosberger
a582f6adde
lib/types: Set deprecationMessage for types.optionSet 2020-09-07 13:17:19 +02:00
Silvan Mosberger
3b7aca47e0
lib/types: Set deprecationMessage for types.loaOf 2020-09-07 13:17:19 +02:00
Silvan Mosberger
2bed3b2ad7
lib/types: Set deprecationMessage for types.string 2020-09-07 13:17:19 +02:00
Silvan Mosberger
14095f8f48
lib/types: Remove types.list, it's been deprecated long enough
Has been deprecated since fd803fce60
(2013-08-22)
2020-09-07 13:17:18 +02:00
Silvan Mosberger
1d4656225d
lib/types: Allow types to emit a deprecation warning
Previously the only way to deprecate a type was using

  theType = lib.warn "deprecated" (mkOptionType ...)

This caused the warning to be emitted when the type was evaluated, but
the error didn't include which option actually used that type.

With this commit, types can specify a deprecationMessage, which when
non-null, is printed along with the option that uses the type
2020-09-07 13:17:14 +02:00
Silvan Mosberger
f320dbae41
lib/tests: Add test for freeform option docs 2020-09-04 15:50:13 +02:00
Silvan Mosberger
ea5ba6e13d
lib/types: Show sub options of freeform types
Previously if you set the freeform type to e.g. attrsOf (submodule ..),
those submodule options wouldn't be shown in the manual.
2020-09-03 21:16:29 +02:00
V
423fc3f232 lib/strings: deprecate readPathsFromFile
> NOTE: This function is not performant and should be avoided.

It's not used at all in-tree now, so we can remove it completely after
any remaining users are given notice.
2020-09-03 19:15:10 +02:00
WORLDofPEACE
18348c7829
Merge pull request #96042 from rnhmjoj/loaOf
treewide: completely remove types.loaOf
2020-09-02 08:45:37 -04:00
John Ericson
1965a241fc
Merge pull request #61019 from volth/gcc.arch-amd
platform.gcc.arch: support for AMD CPUs
2020-09-01 22:31:16 -04:00
rnhmjoj
20d491a317
treewide: completely remove types.loaOf 2020-09-02 00:42:50 +02:00
volth
c5fe132b3c
Update architectures.nix 2020-09-01 11:28:34 +00:00
John Ericson
5a05601013
Merge pull request #96223 from KAction/static
Make pkgsStatic set "static" argument to true
2020-08-31 20:00:15 -04:00
kfollesdal
bf74036952 pythonPackages.databricks-connect: init at 7.1.0 2020-08-31 13:05:09 -07:00
kfollesdal
a9337c0873 licenses: add databricks 2020-08-31 13:05:09 -07:00
Matthew Bauer
d0e52b6b32
Merge pull request #95309 from obsidiansystems/mobile-fixes
Support Android 29 in cross-compilation
2020-08-28 14:59:37 -05:00
Dmitry Bogatov
55195119d5 Distinguish pkgsStatic from pkgsMusl via stdenv.targetPlatform
This change allows derivations to distinguish dynamic musl build and
static musl build in cases where upstream build system can't detect it
by itself.
2020-08-27 18:36:34 -04:00
Eelco Dolstra
2d50c7c08e
Don't set $NIX_DB_DIR
This variable was removed in 2016.
2020-08-24 18:50:20 +02:00
volth
60ce27db2b
Update architectures.nix 2020-08-22 23:04:08 +00:00
volth
8ad48c921e
Update architectures.nix 2020-08-22 23:01:38 +00:00
volth
55bc2b54a4
Update architectures.nix 2020-08-22 22:55:13 +00:00
Maximilian Bosch
fa30c9abed
lib/modules: improve error-message for undeclared options if prefix contains no options
An easy-to-make mistake when declaring e.g. a submodule is the accidental
confusion of `options` and `config`:

    types.submodule {
      config = {
        foo = mkOption { /* ... */ };
      };
    }

However the error-message

  The option `[definition 1-entry 1].foo' defined in `<expr.nix>' does not exist.

is fairly unhelpful because it seems as the options are declared at the
first sight. In fact, it took a colleague and me a while to track down such
a mistake a few days ago and we both agreed that this should be somehow caught
to save the time we spent debugging the module in question.

At first I decided to catch this error in the `submodules`-type directly
by checking whether `options` is undeclared, however this becomes fairly
complicated as soon as a submodule-declaration e.g. depends on existing
`config`-values which would've lead to some ugly `builtins.tryExec`-heuristic.

This patch now simply checks if the option's prefix has any options
defined if a point in evaluation is reached where it's clear that the
option in question doesn't exist. This means that this patch doesn't
change the logic of the module system, it only provides a more detailed
error in certain cases:

  The option `[definition 1-entry 1].foo' defined in `<expr.nix>' does not exist.

  However it seems as there are no options defined in [definition 1-entry 1]. Are you sure you've
  declared your options properly? This happens if you e.g. declared your options in `types.submodule'
  under `config' rather than `options'.
2020-08-18 15:25:26 +02:00
Maximilian Bosch
30842d0263
Merge pull request #95718 from Infinisil/fixup-nonexistant-option-error
lib/modules: Fix nonexistant option error
2020-08-18 11:12:39 +02:00
Matthew Bauer
074bc78cc8 android: update sdk, ndk to 29, 21 2020-08-17 23:51:53 -05:00
Silvan Mosberger
d5700d626c
lib/modules: Fix nonexistant option error
The refactoring in fd75dc8765
introduced a mistake in the error message that doesn't show the full
context anymore. E.g. with this module:

  options.foo.bar = lib.mkOption {
    type = lib.types.submodule {
      baz = 10;
    };
    default = {};
  };

You'd get the error

  The option `baz' defined in `/home/infinisil/src/nixpkgs/config.nix' does not exist.

instead of the previous

  The option `foo.bar.baz' defined in `/home/infinisil/src/nixpkgs/config.nix' does not exist.

This commit undoes this regression
2020-08-18 00:12:36 +02:00
Daniël de Kok
5454cf2053 licenses: add BlueOak-1.0.0 2020-08-17 12:29:16 -07:00
Robert Hensing
6d0a85fe52
Merge pull request #82743 from Infinisil/partially-typed-v2
Freeform modules
2020-08-15 12:13:58 +02:00
Silvan Mosberger
42cf8130d7
lib/modules: Add syntactic sugar for config._module.freeformType
This introduces `freeformType` as a top-level module attribute, allowing
definitions like

  {
    freeformType = ...;
    options = ...;
    config = ...;
  }
2020-08-14 22:49:04 +02:00
Silvan Mosberger
e0ded8f4ba
lib/modules: Fix freeform modules when there's no definitions 2020-08-10 17:27:33 +02:00
volth
cf7b63df5b gcc.arch: refactor, move tables under lib/ 2020-08-05 11:18:26 +00:00
Vladimír Čunát
01c2ba8575
Merge branch 'staging-next' into staging 2020-08-04 21:38:08 +02:00
Emery Hemingway
ccedb29f4b Define a i686-genode system double 2020-08-04 18:08:56 +02:00
Robert Scott
f26cbd0caa licenses: add bsdProtection
see https://spdx.org/licenses/BSD-Protection.html
2020-08-03 14:39:36 -07:00
Silvan Mosberger
446d80d28d
lib/tests: Add tests for freeform modules 2020-08-03 22:37:01 +02:00
Silvan Mosberger
2d45a62899
lib/types: Make submodules use the freeform type description
Submodules that have a freeform type set behave as if that was the type
of the option itself (for values that don't have an option). Since the
submodules options are shown as separate entries in the manual, it makes
sense to show the freeform type as the submodule type.
2020-08-03 22:37:01 +02:00
Silvan Mosberger
65e25deb06
lib/modules: Implement freeform modules
For programs that have a lot of (Nix-representable) configuration options,
a simple way to represent this in a NixOS module is to declare an
option of a type like `attrsOf str`, representing a key-value mapping
which then gets generated into a config file. However with such a type,
there's no way to add type checking for only some key values.

On the other end of the spectrum, one can declare a single separate
option for every key value that the program supports, ending up with a module
with potentially 100s of options. This has the benefit that every value
gets type checked, catching mistakes at evaluation time already. However
the disadvantage is that the module becomes big, becomes coupled to the
program version and takes a lot of effort to write and maintain.

Previously there was a middle ground between these two
extremes: Declare an option of a type like `attrsOf str`, but declare
additional separate options for the values you wish to have type
checked, and assign their values to the `attrsOf str` option. While this
works decently, it has the problem of duplicated options, since now both
the additional options and the `attrsOf str` option can be used to set a
key value. This leads to confusion about what should happen if both are
set, which defaults should apply, and more.

Now with this change, a middle ground becomes available that solves above
problems: The module system now supports setting a freeform type, which
gets used for all definitions that don't have an associated option. This
means that you can now declare all options you wish to have type
checked, while for the rest a freeform type like `attrsOf str` can be
used.
2020-08-03 22:37:00 +02:00
Silvan Mosberger
fd75dc8765
lib/modules: Internally collect all unmatched definitions
This fundamentally changes how the module evaluation internally
handles definitions without an associated option.

Previously the values of these definitions were discarded and only
the names were propagated. This was fine because that's all that's
needed for optionally checking whether all definitions have an
associated option with _module.check.

However with the upcoming change of supporting freeform modules,
we *do* need the values of these.

With this change, the module evaluation cleanly separates definitions
that match an option, and ones that do not.
2020-08-03 22:37:00 +02:00
Silvan Mosberger
b02a3d7b08
lib/modules: Scope module evaluation variables more tightly
This is a purely cosmetic change so it's easier to see dependencies
between variables.
2020-08-03 22:37:00 +02:00
Robert Hensing
150bf4fa3b
Merge pull request #75584 from Infinisil/settings-formats
Configuration file formats for JSON, INI, YAML and TOML
2020-08-02 16:58:49 +02:00
zowoq
c8500de47b lib/*: editorconfig fixes 2020-07-31 15:07:33 +10:00
Silvan Mosberger
9df69cba05
lib/generators: Extend mkValueStringDefault with float support 2020-07-29 18:06:34 +02:00
Silvan Mosberger
5ae3fb2c38
lib/strings: Add floatToString 2020-07-25 21:43:09 +02:00
John Ericson
5c56778efd
Merge pull request #93568 from aaronjanse/aj-redox
Add Redox OS as a target
2020-07-22 12:56:00 -04:00
Aaron Janse
60fd049b65 redox: add as target 2020-07-21 13:11:36 -07:00
Matthew Bauer
bb5d0a47b7 systems/examples.nix: update to iOS 13
new apps need iOS 13, so we should try to use that here
2020-07-21 10:34:57 -05:00
Bas van Dijk
6e7822b8f3 lib: toHex -> toHexString & toBase -> toBaseDigits
This makes the type of these functions more apparent from the name.
2020-07-20 13:14:19 +02:00
Bas van Dijk
00022fbeda lib: add the toHex and toBase utility functions
`toHex` converts the given positive integer to a string of the hexadecimal
representation of that integer. For example:

```
toHex 0 => "0"

toHex 16 => "10"

toHex 250 => "FA"
```

`toBase base i` converts the positive integer `i` to a list of it
digits in the given `base`. For example:

```
toBase 10 123 => [ 1 2 3 ]

toBase 2 6 => [ 1 1 0 ]

toBase 16 250 => [ 15 10 ]
```
2020-07-20 13:09:26 +02:00
Jan Tojnar
fb7507d068
Merge pull request #92348 from jtojnar/explicit-only-gpl
licenses: Make single-version-only GPL explicit
2020-07-18 06:48:41 +02:00
Jörg Thalheim
d7e89fa661
commitIdFromGitRepo: fix stackoverflow if many branches are used.
If many branches are created than builtins.match stack overflows because
of a bug in libstdc++: see https://github.com/NixOS/nix/issues/2147
2020-07-17 10:44:08 +01:00
Jan Tojnar
13b5ae55cd
licenses: Make single-version-only GPL explicit
I commonly see people use the former when they should use the latter.

Would be also in line with the SPDX change https://www.gnu.org/licenses/identify-licenses-clearly.html
2020-07-05 17:51:30 +02:00
Ryan Mulligan
73019d65bd
Merge pull request #92049 from r-ryantm/auto-update/libvmaf
libvmaf: 1.5.1 -> 1.5.2
2020-07-02 21:42:45 -07:00
Ryan Mulligan
46e4bc8a7d licenses: add bsd2Patent 2020-07-02 21:18:01 -07:00
Daniël de Kok
d4737c93fc licenses: add LGPL For Linguistic Resources 2020-06-27 23:03:39 -07:00
Maximilian Bosch
c0c786c3bd
Merge pull request #91454 from ConradMearns/obsidian
obsidian: init at 0.7.3
2020-06-28 01:21:21 +02:00
Markus Kowalewski
9143be487b
lib/licenses: add SPDX LLVM-exception 2020-06-27 12:51:13 +02:00
Conrad Mearns
e4172776e7 licences: add Obsidian.md EULA 2020-06-25 02:38:06 +02:00
rnhmjoj
986079275b
lib/attrsets: add getMan function 2020-06-18 10:16:57 +02:00
Silvan Mosberger
de71ca2ebc
lib/types: Fix type description of bool enum values
Previously bool values would show as <bool>
2020-10-03 15:15:04 +02:00
Pierre Allix
106be3f6fe lib/attrsets: fix typo in the comment of mapAttrsRecursiveCond 2020-06-16 13:48:57 +02:00
Markus Kowalewski
d75a478ff2
licenses: add GNU Free Documentation License v1.1 2020-06-11 18:27:34 +02:00
Frederik Rietdijk
43f71029cc Merge master into staging-next 2020-06-05 19:40:53 +02:00
Eelco Dolstra
8f9e4bef4c
Bump minver.nix to 2.2
Note: NixOS 19.03 had Nix 2.2 and 19.09 had 2.3.
2020-06-04 13:43:10 +02:00
Florian Klink
cfb4d0dfe3
Merge pull request #84032 from teto/fix_kernel_merge
Fix kernel configuration merge
2020-05-22 13:32:22 +02:00
Emily
aff9979170 lib.fake{Sri => Hash}: fix and rename
The previous hash was too short and caused evaluation-time errors like:

    invalid SRI hash 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='

Additionally, since the fact that this is broken implies that nobody
could have been using it, "SRI" is a bit of a vague and obscure term,
`fakeSriHash` would be somewhat of a mouthful, and the relevant fetcher
parameters are just called `hash`, rename it to `fakeHash`.
2020-05-11 23:11:12 +01:00
Jörg Thalheim
885f65fbff
Merge pull request #86074 from emilazy/refactor-linux-hardened-update-script 2020-05-11 10:40:42 +01:00
Emily
d6fe0a4e2d linux/hardened: move files into directory 2020-05-08 15:49:35 +01:00
Drew Mullen
448d68c511 fix example for foldl 2020-05-08 08:31:27 -04:00
Silvan Mosberger
a89b773984
lib/tests: Allow overriding pkgs independent of lib being tested 2020-04-25 23:40:20 +02:00
Pavol Rusnak
461a252bee
verifast: change license to MIT
It seems verifast was relicensed to MIT in 2016:
b3c1bce76a

As this was the only package using lib.licenses.msrla I dropped it.
2020-04-23 09:59:33 +00:00
Timo Kaufmann
166bf2314a
Merge pull request #81210 from B4dM4n/ausweisapp2
ausweisapp2: init at 1.20.0
2020-04-20 22:07:40 +00:00
Fabian Möller
592e433496
licenses: add EUPL-1.2 2020-04-18 23:30:03 +02:00
Pavol Rusnak
2c45fa52a4
lib/licenses: use https where possible 2020-04-18 23:26:44 +02:00
Pavol Rusnak
fadcfc3ea4
treewide: per RFC45, remove more unquoted URLs 2020-04-18 14:04:37 +02:00
Daiderd Jordan
964700da44
lib/options: fix showOption example 2020-04-14 20:38:31 +02:00
Daiderd Jordan
31a03daa72
Revert "lib/options: Use escapeNixIdentifier for showOption"
This is used in in the manual generation for option identifiers that can
be linked. This, unike what the example describes, doesn't preserve
quotes which is needed for these identifiers to be valid.

This reverts commit 124cccbe3b.
2020-04-14 20:34:07 +02:00
Jan Tojnar
c652b64a26
lib/options: Relax showOption quoting
124cccbe3b
broke the build of NixOS manual.

It does not make sense to be as strict as with attributes since we
are not limited by the CLI's inability to handle numbers.
Placeholders should not be quoted either as they are not part of Nix
syntax but a meta-level construct.
2020-04-14 04:49:17 +02:00
Silvan Mosberger
f579564062
lib/maintainer-list: Implement validity checks 2020-04-13 17:28:00 +02:00