summaryrefslogtreecommitdiffstats
path: root/lib/tests/misc.nix
AgeCommit message (Collapse)Author
2020-09-17lib/generators.toPretty: Implement multiline printingSilvan Mosberger
2020-09-17lib/generators.toPretty: Only quote attribute names if necessarySilvan Mosberger
2020-07-20lib: toHex -> toHexString & toBase -> toBaseDigitsBas van Dijk
This makes the type of these functions more apparent from the name.
2020-07-20lib: add the toHex and toBase utility functionsBas van Dijk
`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-04-02Merge pull request #83241 from Infinisil/valid-drv-nameSilvan Mosberger
lib/strings: Add `sanitizeDerivationName` function
2020-03-30lib/strings: Add sanitizeDerivationName functionSilvan Mosberger
2020-03-10lib/generators: Add toINI option for duplicate keysSilvan Mosberger
2020-02-10lib/tests/misc.nix: Fix dependency on currentSystemEelco Dolstra
This doesn't work in pure mode.
2020-01-23lib/cli,lib/tests/misc: somewhat more standard formattingProfpatsch
2020-01-23lib/cli: encodeGNUCommandLine -> toGNUCommandLineShellProfpatsch
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-05Factor out a `toGNUCommandLine` utilityGabriel Gonzalez
... as suggested by @roberth
2019-12-15Use a more realistic example that exercises all encodingsGabriel Gonzalez
... as suggested by @roberth This also caught a bug in rendering lists, which this change also fixes
2019-12-13Make behavior of `encodeGNUCommandLine` customizableGabriel Gonzalez
... based on feedback from @edolstra
2019-12-13Rename `renderOptions` to `encodeGNUCommandLine`Gabriel Gonzalez
... as suggested by @edolstra
2019-12-11Add `pkgs.lib.renderOptions`Gabriel Gonzalez
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-10-21lib/trivial: add `pipe` functionProfpatsch
`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-09-26lib: basic tests for lib.versionsJoachim Fasting
2018-12-30Remove composableDerivation, closes #18763Frederik Rietdijk
2018-10-20lib.isStorePath: fix `false` result when passed a path objectTim Cuthbertson
Since `isStorePath` relies on comparing against builtins.storeDir (a string), we need to convert the input into a string as well.
2018-10-15generators: make toPretty handle floats correctlyLéo Gaspard
2018-09-17lib/tests: Add overrideExisting testsSilvan Mosberger
2018-09-06Merge branch 'no-toPath'Shea Levy
2018-08-15lib/recursiveUpdateUntil: add a test & release note for fixProfpatsch
2018-07-20[bot]: remove unreferenced codevolth
2018-06-10lib: bitAnd, bitOr, bitXor (bitsize-agnostic fallback function) (#41491)volth
* lib: bitAnd, bitOr, bitXor * lib: test for bitAnd, bitOr, bitXor * lib: bitsize-agnostic zipIntBits * lib: bitNot * lib: bitNot
2018-06-05Revert "lib: bitAnd, bitOr, bitXor"Profpatsch
2018-06-02lib: test for bitAnd, bitOr, bitXorvolth
2018-05-22treewide: Remove uses of builtins.toPath.Shea Levy
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-04-25lib/generators: print paths without quotes & move function downProfpatsch
2018-03-29lib/generators: introduce a sane default for `mkValueString`Profpatsch
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-09lib.isStorePath: Fix derivation detectionShea Levy
2017-11-22lib/generators: add mkValueString to mkKeyValueDefault generatorProfpatsch
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-06-22lib/generators: put more information in toPretty lambdasProfpatsch
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-22lib/generators: toPrettyProfpatsch
`toPretty` implements a pretty printer for nix values.
2017-06-09lib-tests: fix test for isStorePathDaiderd Jordan
2017-05-30Add `isStorePath` tests (#26223)Profpatsch
2017-05-17lib: Consolidate tests into one meta jobJohn Ericson