about summary refs log tree commit diff
path: root/lib/tests/misc.nix
AgeCommit message (Collapse)AuthorFilesLines
2023-10-11lib.makeOverridable: fix functionArgs on returned functionRobert Hensing1-0/+12
2023-10-10Merge pull request #254452 from flyingcircusio/lib-attrsToListSilvan Mosberger1-0/+24
lib.attrsets.attrsToList: add function
2023-10-10lib.attrsets.attrsToList: add functionOliver Schmidt1-0/+24
For transforming back between lists and attrsets, it makes sense to have a quasi-inverse of `builtins.listToAttrs` available as a library function. Co-authored-by: Silvan Mosberger <github@infinisil.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-09-27lib.attrsets.foldlAttrs: Make stricterSilvan Mosberger1-2/+2
See the parent commit for the same change to lib.lists.foldl'
2023-09-27lib.lists.foldl': Make strict in the initial accumulatorSilvan Mosberger1-2/+2
To maintain backwards compatibility, this can't be changed in the Nix language. We can however ensure that the version Nixpkgs has the more intuitive behavior.
2023-09-26lib.lists.foldl': Add testsSilvan Mosberger1-0/+32
2023-08-21lib.generators.toGitINI: added testVwCSXg1-0/+45
Added basic generators.toGitINI test. Mostly taken from https://github.com/nix-community/home-manager/blob/958c06303f43cf0625694326b7f7e5475b1a2d5c/tests/modules/programs/git/git.nix. The ${"\t} escape is used so that the lines aren't recognized as "Wrong indent style".
2023-08-14lib.removePrefix: Add testsSilvan Mosberger1-0/+21
2023-08-14Merge pull request #243511 from tweag/lib.lists.hasPrefixSilvan Mosberger1-0/+38
`lib.lists.{hasPrefix,removePrefix}`: init
2023-07-26Merge pull request #243520 from tweag/lib.lists.commonPrefixSilvan Mosberger1-20/+63
`lib.lists.{findFirstIndex,commonPrefix}`: init
2023-07-20lib.lists.commonPrefix: initSilvan Mosberger1-0/+33
2023-07-19lib.lists.findFirstIndex: initSilvan Mosberger1-20/+30
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-07-19Merge pull request #244044 from tweag/lib-readmeRobert Hensing1-3/+15
Create a Readme in `lib`
2023-07-18lib.attrsets.mergeAttrsList: initSilvan Mosberger1-0/+25
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-07-18lib/tests: Unify documentation of individual testable filesSilvan Mosberger1-3/+15
2023-07-14lib.lists.removePrefix: initSilvan Mosberger1-0/+17
2023-07-14lib.lists.hasPrefix: initSilvan Mosberger1-0/+21
2023-06-06lib.list.findFirst: Make lazierSilvan Mosberger1-0/+5
There's no need to evaluate list elements after a matching element
2023-06-06lib/tests: Add findFirst testsSilvan Mosberger1-0/+35
2023-05-05Merge pull request #223407 from AngryAnt/toplist-pathtoonn1-0/+24
lib.toPlist: Add support for path values
2023-04-29lib.generators.toLua: asBindings optionMykola Orliuk1-0/+40
Allows to generate code block for setting of global variables
2023-04-23lib.generators.toLua: allow disabling multilineMykola Orliuk1-2/+7
2023-04-23lib/generators: add toLua/mkLuaInlineMykola Orliuk1-0/+61
Suitable to simplify Lua-based configurations like neovim-lspconfig that might need to interpolate Nix package paths.
2023-03-27lib.toPlist: keep test output in external files for their tab indentsEmil "AngryAnt" Johansen1-46/+1
2023-03-27lib.toPlist: basic test coverageEmil "AngryAnt" Johansen1-0/+69
2023-03-11init: lib.foldlAttrshsjobeki1-0/+31
- provide comprehensive example - add unit test
2023-03-03strings: add escapeQuery for url encodingPatrick Widmer1-0/+9
2023-02-07Merge pull request #206611 from h7x4/lib-lists-add-repeatSilvan Mosberger1-0/+5
lib.lists: add `replicate`
2023-02-06lib.lists: add `replicate`h7x41-0/+5
`replicate` returns n copies of an element as a list. Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2023-01-31Merge pull request #205557 from ncfavier/concatLinesSilvan Mosberger1-0/+5
lib/strings: add `concatLines`
2022-12-21lib/versions: add `pad`Naïm Favier1-0/+15
Pad a version string with zeros to match a given number of components.
2022-12-11Merge pull request #205457 from ↵Robert Hensing1-0/+4
h7x4/lib-strings-toInt-broken-for-negative-numbers lib.strings: fix negative number handling for `toInt` and `toIntBase10`
2022-12-10lib/strings: add `concatLines`Naïm Favier1-0/+5
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-10lib.strings: fix negative number handling for `toInt` and `toIntBase10`h7x41-0/+4
The previous version would be unstable due to an input validation regex not expecting a '-' in front of the number.
2022-12-08nixos/doc: render option values using `lib.generators.toPretty`Naïm Favier1-1/+1
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-08lib/generators.toPretty: escape strings properlyNaïm Favier1-8/+8
2022-12-08lib/generators.toPretty: don't evaluate derivationsNaïm Favier1-1/+1
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-11-17lib/attrsets: add concatMapAttrsfigsoda1-0/+17
2022-10-23lib/strings: Update docs and restructured code to improve readability of ↵Jacob Abel1-0/+4
toInt and toIntBase10.
2022-10-23lib/strings: Refactor toInt into toInt and toIntBase10Jacob Abel1-16/+44
2022-10-23lib/strings: Update toInt to handle intermixed ws and zeros. Added testsJacob Abel1-0/+11
2022-10-23lib/strings: allow toInt to parse zero-padded stringsJacob Abel1-0/+28
2022-10-20lib/tests/misc: Add tests for charToInt, escapeC, and normalizePathDaniel Olsen1-0/+15
2022-09-21lib: Add lazyDerivationRobert Hensing1-0/+53
2022-09-17lib.types: Add parentheses where description is ambiguousRobert Hensing1-0/+53
2022-05-23Merge pull request #168374 from Ma27/special-attrs-in-with-recursionSilvan Mosberger1-0/+15
lib/generators: withRecursion: don't break attr-sets with special attrs
2022-05-15Revert "lib: init flakes.nix"adisbladis1-10/+0
This reverts commit PR #167947. Flakes aren't standardised and the `lib` namespace shouldn't be polluted with utilities that serve only experimental uses.
2022-05-07lib/strings/toShellVars: handle derivations as stringsNaïm Favier1-0/+12
2022-05-02Merge pull request #170090 from danth/has-infix-toStringRobert Hensing1-0/+30
lib/strings: call toString within hasInfix
2022-05-02lib/tests: add tests for hasInfixDaniel Thwaites1-0/+30
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>