Commit Graph

164 Commits

Author SHA1 Message Date
John Ericson
765d2608b6 Fix lib tests
js-ghcjs didn't fit in an existing categor.
2019-11-25 14:09:50 +00:00
Profpatsch
8252861507 lib/trivial: add pipe function
`pipe` is a useful operator for creating pipelines of functions.

It works around the usual problem of e.g. string operations becoming
deeply nested functions.

In principle, there are four different ways this function could be
written:

pipe val [ f1 .. fn ]
pipe val [ fn .. f1 ]
compose [ f1 .. fn ] val
compose [ fn .. f1 ] val

The third and fourth form mirror composition of functions, they would
be the same as e.g. `(f1 << f2 << f3 .. << fn) val`.
However, it is not clear which direction the list should have (as one
can see in the second form, which is the most absurd.

In order not to confuse users, we decide for the most “intuitive”
form, which mirrors the way unix pipes work (thus the name `pipe`).
The flow of data goes from left to right.

Co-Authored-By: Silvan Mosberger <infinisil@icloud.com>
2019-10-21 13:19:16 +02:00
Matthew Bauer
bf2e3515a8
Merge pull request #70194 from obsidiansystems/lib-more-arm
lib: Add armv7a-linux to doubles.nix
2019-10-01 13:34:27 -04:00
John Ericson
3098d65210 lib: Add armv7a-linux to doubles.nix
This is needed for android.
2019-10-01 12:51:57 -04:00
Joachim Fasting
2d4352b1ae
lib: basic tests for lib.versions 2019-09-26 17:42:48 +02:00
Silvan Mosberger
9a44f44d4c
lib/types: Add oneOf, extension of either to a list of types 2019-08-06 14:08:42 +02:00
Frederik Rietdijk
8931db9f0b make-tarball / lib-tests: reduce duplication
The misc.nix and systems.nix tests were invoked at three different
places. Let's not that.
2019-07-11 18:02:05 +02:00
Matthew Bauer
d059185bad Revert "Revert "systems/doubles.nix: add Apple doubles""
This reverts commit ce2f74df2c.

Doubles are treated as -darwin here, to provide some consistency.
There is some ambiguity between “x86_64-darwin” and “i686-darwin”
which could refer to binaries linked between iOS simulator or real
macOS binaries. useiOSPrebuilt can be used to determine which to use,
however.
2019-07-10 15:14:59 -04:00
Matthew Bauer
0fef9f89e4 systems: fix lib-tests
These were broken by the added system doubles. This just adds those to
the lib-tests.
2019-06-04 14:51:33 -04:00
Matthew Bauer
ed5c731b21 tests/systems: fix tests 2019-04-25 17:28:02 -04:00
(cdep)illabout
dcbd136319
Fix the documentation for the tests to reflect what is actually happening. 2019-02-07 10:33:48 +09:00
(cdep)illabout
81fa1e392b lib/modules: Change mkAliasOptionModule to use the priority for the alias.
This commit changes the `mkAliasOptionModule` function to make sure that
the priority for the aliased option is propagated to the non-aliased
option.

This also affects the `mkRenamedOptionModule` function in a similar
fashion.

This also removes the `mkAliasOptionModuleWithPriority` function, since
its functionality is now subsumed by `mkAliasOptionModule`.

This change was recommended by @nbp:
https://github.com/NixOS/nixpkgs/pull/53397#discussion_r245487432
2019-01-24 13:02:16 +09:00
(cdep)illabout
7314d885a1
Add test that shows that the aliases are able to override options. 2019-01-06 18:10:03 +09:00
(cdep)illabout
b81b3ad1b0
lib/modules: Add a function to create an option alias that respects the priority
This commit adds a function `mkAliasOptionModuleWithPriority`.  This
function will make an alias to an existing option and copy over the
priority.

This functionality is needed for PRs like #53041.  In that case
`nixos-generate-config` added an option to `hardware-configuration.nix`
with `mkDefault`.  That option was then changed and an alias created for
the old name.

The end user should be able to set the non-alias option in their
`configuration.nix` and have everything work correctly.  Without this
function, the priority for the option won't be copied over correctly
and the end-user will get a message saying they have the same option
set to two different values.
2019-01-04 18:35:10 +09:00
(cdep)illabout
da00ec4b45
Add a failing test for mkAliasOptionModule. 2019-01-04 18:34:09 +09:00
Frederik Rietdijk
c6e043d57c Remove composableDerivation, closes #18763 2018-12-30 12:33:45 +00:00
Tim Cuthbertson
d984c55383 lib.isStorePath: fix false result when passed a path object
Since `isStorePath` relies on comparing against builtins.storeDir
(a string), we need to convert the input into a string as well.
2018-10-20 22:33:04 +11:00
Matthew Bauer
4a12a9321c tests/systems.nix: fix tests
these weren’t being run correctly
2018-10-18 14:12:49 -05:00
Léo Gaspard
455e0ed885 generators: make toPretty handle floats correctly 2018-10-15 14:03:16 +02:00
Jörg Thalheim
83d89edc6e
Merge pull request #46336 from Infinisil/overrideExisting
lib: Improve overrideExisting implementation
2018-09-18 11:37:30 +01:00
Silvan Mosberger
afd8620621
lib/tests: Add overrideExisting tests 2018-09-17 22:40:08 +02:00
Graham Christensen
4c7f0714c9
Merge pull request #36287 from shlevy/lib-tests-default
lib/tests: Add check-eval.nix to run simple tests.
2018-09-16 18:38:47 -04:00
Shea Levy
18337f3ece
Merge branch 'no-toPath' 2018-09-06 08:09:53 -04:00
Jörg Thalheim
9efffe0135 hurd: cleanup unmaintained target
This has been not touched in 6 years. Let's remove it to cause less
problems when adding new cross-compiling infrastructure.
This also simplify gcc significantly.
2018-08-28 22:18:02 +01:00
Profpatsch
d817452e29 lib/recursiveUpdateUntil: add a test & release note for fix 2018-08-15 17:16:56 +02:00
volth
87f5930c3f [bot]: remove unreferenced code 2018-07-20 18:48:37 +00:00
volth
3c2bbe217c lib: bitAnd, bitOr, bitXor (bitsize-agnostic fallback function) (#41491)
* lib: bitAnd, bitOr, bitXor

* lib: test for bitAnd, bitOr, bitXor

* lib: bitsize-agnostic zipIntBits

* lib: bitNot

* lib: bitNot
2018-06-10 21:25:48 +02:00
Profpatsch
f98272d6e2 Revert "lib: bitAnd, bitOr, bitXor" 2018-06-05 18:45:20 +02:00
volth
078b9b4c2b
lib: test for bitAnd, bitOr, bitXor 2018-06-02 21:13:43 +00:00
Shea Levy
6da6accd30
treewide: Remove uses of builtins.toPath.
toPath has confusing semantics and is never necessary; it can always
either just be omitted or replaced by pre-concatenating `/.`. It has
been marked as "!!! obsolete?" for more than 10 years in a C++
comment, hopefully removing it will let us properly deprecate and,
eventually, remove it.
2018-05-22 16:42:02 -04:00
Robert Helgesson
08e8701673
lib.types: fix loaOf behavior for long lists
Assigning a list of 10 or more elements to an option having the type
`loaOf a` produces a configuration value that is not honoring the
order of the original list. This commit fixes this and a related issue
arising when 10 or more lists are merged into this type of option.
2018-05-07 20:23:52 +02:00
Silvan Mosberger
cd5736116c lib/types: clear up coercedTo description 2018-05-06 23:58:36 +02:00
Silvan Mosberger
b16a69289a lib/types: Add coercedTo unsound tests 2018-05-06 23:58:36 +02:00
Profpatsch
c84dad316a lib/generators: print paths without quotes & move function down 2018-04-25 15:31:17 +02:00
Profpatsch
fa71407f36 lib/generators: introduce a sane default for mkValueString
So far, `mkValueString` defaulted to `toString`,
which is a bad match for most configuration file formats,
especially because how booleans are formatted.
This also improves error messages for unsupported types.

Add a test to codify the formatting.
2018-03-29 16:53:06 +02:00
Eelco Dolstra
7db841512a
Remove obsolete /nix/var/nix/{manifests,channel-cache} 2018-03-20 18:26:13 +01:00
Shea Levy
b66d7dc0ce
lib.isStorePath: Fix derivation detection 2018-03-09 17:21:31 -05:00
Shea Levy
6fcf691545
lib-tests: Don't depend on /bin/sh
https://hydra.nixos.org/build/70748333
2018-03-08 08:36:35 -05:00
Shea Levy
f1eb2f35a6
lib/tests: Add check-eval.nix to run simple tests.
This can be used by evaluation-only tools to validate tests are still
working.
2018-03-04 06:28:49 -05:00
Daniel Barlow
9c50ae6898 lib, treewide: Add missing MIPS arches, and fix existing usage
Existing "mips64el" should be "mipsel".

This is just the barest minimum so that nixpkgs can recognize them as
systems - although required for building individual derivations onto
MIPS boards, it is not sufficient if you want to actually build nixos on
those targets
2018-02-23 20:43:42 -05:00
Profpatsch
8e00dcd242 lib/generators: add mkValueString to mkKeyValueDefault generator
This means the generation of values can now be influenced, even down from e.g.
an INI generator.
Breaks the interface of `mkKeyValueDefault` to match its interface to other
generator functions. It might me sensible to rename `mkKeyValue` and
`mkKeyValueSet` to conform to the `toX`-style of generator functions.
2017-11-22 21:53:59 +01:00
Profpatsch
462c048c77 lib/types: add ints.positive.
For values that are positive, but cannot be 0.
2017-11-05 15:56:32 +01:00
Profpatsch
c85f085062 lib/types: update docs to match the new type names 2017-11-05 15:56:32 +01:00
Profpatsch
f8e6cd3465 lib/types: add tests for ints.between and ints.unsigned
The int types are trivial invocations of `ints.between`, so they are not tested
explicitely.
2017-11-05 15:56:32 +01:00
Profpatsch
5cbc6ca9bb lib/generators: put more information in toPretty lambdas
With `builtins.functionArgs` we can get some information if the first argument
is an attrset and whether the contained fields have default values. Encode that
into the pretty-printed lambda.
2017-06-22 00:58:59 +02:00
Profpatsch
b1ffe5e4c0 lib/generators: toPretty
`toPretty` implements a pretty printer for nix values.
2017-06-22 00:58:59 +02:00
Daiderd Jordan
cfe2b12fe4
lib-tests: fix test for isStorePath 2017-06-09 23:38:08 +02:00
Profpatsch
3fa1be6f49 Add isStorePath tests (#26223) 2017-05-30 20:48:32 +01:00
John Ericson
da8b2f1412 lib tests: Simplify relative path for default argument 2017-05-21 13:38:36 -04:00
John Ericson
296753f094 lib: Consolidate tests into one meta job 2017-05-17 11:14:59 -04:00
John Ericson
d86caa3216 lib: Fix preexisting bugs in old platforms code (now bugs in tests)
Warning, this changes the compatibility claims of existing packages!
2017-04-17 17:13:01 -04:00
John Ericson
8c99aab3ea lib: Fix system parsing, and use for doubles lists
The old hard-coded lists are now used to test system parsing.

In the process, make an `assertTrue` in release lib for eval tests; also
use it in release-cross
2017-04-17 17:13:01 -04:00
Daiderd Jordan
d88721e440
modules: add support for module replacement with disabledModules
This is based on a prototype Nicolas B. Pierron worked on during a
discussion we had at FOSDEM.

A new version with a workaround for problems of the reverted original.
Discussion: https://github.com/NixOS/nixpkgs/commit/3f2566689
2017-03-03 13:45:22 +01:00
Vladimír Čunát
fcec3e1c72
Revert "modules: add support for module replacement with disabledModules"
This reverts commit 3f2566689d for now.
Evaluation of the tested job got broken, blocking nixos-unstable.
2017-03-01 21:56:01 +01:00
Daiderd Jordan
37705ac1b1 use relative path for module tests 2017-02-28 00:14:48 +01:00
Daiderd Jordan
3f2566689d modules: add support for module replacement with disabledModules
This is based on a prototype Nicolas B. Pierron worked on during a
discussion we had at FOSDEM.
2017-02-28 00:14:48 +01:00
Nikolay Amiantov
5b759293e0 modules lib: type description in type error message 2017-02-03 11:28:33 +01:00
Nikolay Amiantov
fcb20b9fee module tests: add tests for coercedTo 2017-02-02 01:53:00 +03:00
John Ericson
f073df60d6 Replace ./../* with ../* in Nix expressions (#16414) 2016-06-22 10:39:50 +02:00
zimbatm
07b1f78b94 lib: alphabetize things 2016-02-26 22:15:41 +00:00
Nicolas B. Pierron
a6b455bbae NixOS modules: Add error context on module arguments evaluation. 2015-07-14 15:07:54 +02:00
Nicolas B. Pierron
7f1a782d91 Add tests for the new module system improvements. 2015-03-16 22:38:41 +01:00
Nicolas B. Pierron
de0f122b01 Issue #6161 - Register lib tests as release blockers. 2015-02-09 00:07:44 +01:00
Nicolas B. Pierron
6d15e32536 Issue #6161 - Add tests for NixOS modules. 2015-02-09 00:07:44 +01:00