Commit graph

110 commits

Author SHA1 Message Date
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
Silvan Mosberger 446d80d28d
lib/tests: Add tests for freeform modules 2020-08-03 22:37:01 +02:00
zowoq c8500de47b lib/*: editorconfig fixes 2020-07-31 15:07:33 +10: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
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
Silvan Mosberger a89b773984
lib/tests: Allow overriding pkgs independent of lib being tested 2020-04-25 23:40:20 +02:00
Silvan Mosberger f579564062
lib/maintainer-list: Implement validity checks 2020-04-13 17:28:00 +02:00
Silvan Mosberger a90d8de242
lib/tests/release.nix: Avoid importing nixpkgs into the store
Improves build time by about a factor of two on my system
2020-04-13 17:27:05 +02:00
Silvan Mosberger 0bc7f3440a
lib/tests/modules.sh: Don't depend on $PWD 2020-04-13 17:27:04 +02:00
Silvan Mosberger f75c11cfdf
Merge pull request #83241 from Infinisil/valid-drv-name
lib/strings: Add `sanitizeDerivationName` function
2020-04-02 05:58:13 +02:00
Silvan Mosberger 4b206ac83b
lib/strings: Add sanitizeDerivationName function 2020-03-30 01:15:30 +02:00
Emery Hemingway 9f91fa02a6 lib/systems: Add Genode platform definitions
Add platform definitions for 64-bit ARM and x86. This is sufficient for
for building Genode where a toolchain is provided as an overlay.

Toolchain: git+https://git.sr.ht/~ehmry/genodepkgs?rev=14fc773ac9ecd2cbb30cb4612b284eee83d83546
2020-03-24 20:41:21 +05:30
John Ericson 19a0b38cbe
Merge pull request #82882 from obsidiansystems/armv6-embedded
Misc fixes for armv6 bare metal cross
2020-03-19 10:38:22 -04:00
Silvan Mosberger 742e3fc002
lib/tests: Check for nested option-dependent definitions 2020-03-19 03:50:47 +01:00
Silvan Mosberger 9eecf2d057
Revert "lib/modules: Throw better error when definitions assign to an option set"
This reverts commit 15c873b486.

This was causing infinite recursion when depending on nested options
2020-03-19 03:50:15 +01:00
John Ericson 7c0d3f6f70 lib: Fix systems test for new armv6l-none 2020-03-18 17:43:11 -04:00
Robert Hensing 5f357b20b3
Merge pull request #82751 from Infinisil/minor-module-improvements
Minor module improvements
2020-03-18 10:06:06 +01:00
Silvan Mosberger e931de58a2
lib/modules: Fix type checks not being done before merging
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2020-03-18 04:38:53 +01:00
Silvan Mosberger 15c873b486
lib/modules: Throw better error when definitions assign to an option set 2020-03-18 04:38:50 +01:00
Robert Hensing 31206e44e1 lib/modules: Test the ability for config to depend on options for compatibility 2020-03-17 20:21:10 +01:00
Silvan Mosberger 575354babf
lib/generators: Add toINI option for duplicate keys 2020-03-10 16:01:04 +01:00
Eelco Dolstra 5c389f84d4 lib/tests/misc.nix: Don't make a copy on Nixpkgs 2020-02-10 16:21:04 +01:00
Eelco Dolstra a274da605d lib/tests/misc.nix: Fix dependency on currentSystem
This doesn't work in pure mode.
2020-02-10 16:20:41 +01:00
Profpatsch b2654c226a lib/cli,lib/tests/misc: somewhat more standard formatting 2020-01-23 14:47:38 +01:00
Profpatsch 582354d3b6 lib/cli: encodeGNUCommandLine -> toGNUCommandLineShell
The semantic difference between `encode` and `to` is not apparent.
Users are likely to confuse both functions (which leads to unexpected
error messages about the wrong types). Like in `generators.nix`, all
functions should be prefixed by `to`.

Furthermore, converting to a string depends on the target context. In
this case, it’s a POSIX shell, so we should name it that (compare
`escapeShellArg` in `strings.nix`).

We can later add versions that escape for embedding in e.g. python
scripts or similar.
2020-01-23 14:47:38 +01:00
Robert Hensing 8da81465c1
Merge pull request #75539 from Gabriel439/gabriel/renderOptions
Add `pkgs.lib.encodeGNUCommandLine`
2020-01-14 12:04:05 +01:00
Robert Hensing 9884cb3ed0
Merge pull request #76861 from Infinisil/paths-as-submodules
lib/types: Allow paths as submodule values
2020-01-12 14:19:04 +01:00
Silvan Mosberger ab10e87414
lib/tests: Add tests for attrsOf and lazyAttrsOf 2020-01-10 16:20:31 +01:00
Silvan Mosberger 092107cdc1
lib/tests: Fix module tests
Fix the broken test in https://github.com/NixOS/nixpkgs/pull/77416

Apparently hydra uses `nix-build lib/tests/release.nix` to run all
tests, where IFD isn't allowed. Fortunately we can get around this with
builtins.toFile, which doesn't require IFD, but still can test the
properties we want.
2020-01-10 16:02:36 +01:00
Silvan Mosberger 2955e6bd26
lib/tests: Add test case for imports from derivations 2020-01-10 04:13:28 +01:00
Silvan Mosberger e9c16ec186
Merge pull request #76857 from Infinisil/recursive-disableModules
Apply `disabledModules` recursively
2020-01-09 18:20:12 +01:00
Silvan Mosberger b89b23b6b2
lib/tests: Add tests for recursive disabledModules 2020-01-09 17:26:08 +01:00
Silvan Mosberger 6525da6321
lib/types: Allow paths as submodule values 2020-01-08 23:54:45 +01:00
rnhmjoj cde46494c6 lib/tests: remove strictly loaOf tests and rebase on attrsOf 2020-01-06 10:39:19 -05:00
Gabriel Gonzalez 6d584c2614 Factor out a toGNUCommandLine utility
... as suggested by @roberth
2020-01-05 13:03:00 -08:00
Silvan Mosberger be3f887ac4
lib/tests: Temporarily disable submodule path test
Until https://github.com/NixOS/nixpkgs/pull/76861 or so is merged
2020-01-03 06:02:55 +01:00
Silvan Mosberger cdf79db19d
Module system improvements for NixOS as a submodule (#75031)
Module system improvements for NixOS as a submodule
2020-01-02 20:38:45 +01:00
Silvan Mosberger cc81320a46
lib/tests: Add submoduleWith tests 2020-01-02 09:59:35 +01:00
Gabriel Gonzalez 5edd4dd44c Use a more realistic example that exercises all encodings
... as suggested by @roberth

This also caught a bug in rendering lists, which this change also fixes
2019-12-15 08:21:41 -08:00
Gabriel Gonzalez 693096d283 Make behavior of encodeGNUCommandLine customizable
... based on feedback from @edolstra
2019-12-13 18:25:52 -08:00
Gabriel Gonzalez 8c6a05c8c9 Rename renderOptions to encodeGNUCommandLine
... as suggested by @edolstra
2019-12-13 18:19:24 -08:00
Gabriel Gonzalez 183a99734f Add pkgs.lib.renderOptions
This adds a new utility to intelligently convert Nix records to
command line options to reduce boilerplate for simple use cases and to
also reduce the likelihood of malformed command lines
2019-12-11 16:30:05 -08:00
John Ericson 80524db331 Merge branch 'ghcjs-cross-without-cc-19.09' into ghcjs-cross-without-cc 2019-11-25 14:11:18 +00:00
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