about summary refs log tree commit diff
path: root/lib/strings.nix
AgeCommit message (Collapse)AuthorFilesLines
2024-04-02lib/strings: Add makeIncludePath (#296237)Florian Richer1-0/+12
* Update strings.nix * Fix typo in docs * Update lib/strings.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Update lib/strings.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Add unit test with strings * Move test to strings * Add unit test with package structure * testMakeIncludePathWithPkgs: use real pkgs * Revert "testMakeIncludePathWithPkgs: use real pkgs" This reverts commit fb1850c069cfb324f3a43323da740a27a11793f3. * Update lib/tests/misc.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Update lib/tests/misc.nix Co-authored-by: Silvan Mosberger <github@infinisil.com> --------- Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> Co-authored-by: Silvan Mosberger <github@infinisil.com>
2024-03-03lib.toInt/toIntBase10: Make more efficient by hoisting up internal strings ↵adisbladis1-10/+17
into higher scope
2024-02-09lib.strings: Remove unneeded polyfillSilvan Mosberger1-2/+1
Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around.
2024-02-03lib: make deprecation warnings consistentAlois Wohlschlager1-2/+2
The deprecation warnings in lib were wildly inconsistent. Different formulations were used in different places for the same meaning. Some warnings used builtins.trace instead of lib.warn, which prevents silencing; one even only had a comment instead. Make everything more uniform.
2023-12-11Merge pull request #273473 from adisbladis/lib-isConvertibleToString-static-listSilvan Mosberger1-2/+4
lib.isConvertibleToString: Statically compute types list
2023-12-11lib.cmakeOptionType: Statically compute types listadisbladis1-6/+7
2023-12-11lib.isConvertibleToString: Statically compute types listadisbladis1-2/+4
2023-12-11lib.strings: Dont create scopes for getName/getVersionadisbladis1-12/+12
We can create the `parse` function in a scope one level up to avoid recomputing it every time.
2023-10-31lib.strings: add `replicate`h7x41-0/+14
`strings.replicate` returns n copies of a string, concatenated into a new string Co-authored-by: Silvan Mosberger <github@infinisil.com>
2023-10-09lib: refactorAnderson Torres1-12/+15
- rename `(enable|with)Feature(As|)` inputs to more descriptive names
2023-09-27lib: add cmakeOptionType, cmakeBool and cmakeFeatureAnderson Torres1-0/+58
2023-08-14lib.removePrefix: OptimiseSilvan Mosberger1-2/+2
2023-06-22lib: simplify stringToCharactersfigsoda1-1/+2
2023-06-15lib.path.hasPrefix: initSilvan Mosberger1-1/+2
2023-04-04Merge pull request #221204 from tweag/deprecate-paths-to-stringsSilvan Mosberger1-11/+75
lib.strings: Prevent paths as inputs in some functions
2023-03-15lib.strings.remove{Prefix,Suffix}: Deprecate for path prefix/suffix argumentsSilvan Mosberger1-5/+23
See also parent commits
2023-03-15lib.strings.normalizePath: Deprecate for path valuesSilvan Mosberger1-1/+14
There's no need to call this function on path data types, and it's confusing with the new lib.path library functions
2023-03-15lib.strings: Deprecate path prefix/suffix/infix argumentsSilvan Mosberger1-5/+38
lib.{hasPrefix,hasInfix,hasSuffix} would otherwise return an always-false result, which can be very unexpected: nix-repl> lib.strings.hasPrefix ./lib ./lib/meta.nix false
2023-03-04lib/strings: hide asciiTableNaïm Favier1-2/+2
Since it's an attribute set, the lib function location generating code tries to generate locations for each of the characters...
2023-03-03strings: add escapeQuery for url encodingPatrick Widmer1-3/+18
2023-01-31Merge pull request #205557 from ncfavier/concatLinesSilvan Mosberger1-0/+11
lib/strings: add `concatLines`
2022-12-31lib.isStringLike: Remove use of listRobert Hensing1-1/+3
In the current implementation of Nix, this list would be allocated over and over. Iirc pennae tried to optimize static list allocation, but gained no significant performance improvement.
2022-12-31lib.strings.isConvertibleWithToString: Refactor to reuse isStringLikeRobert Hensing1-4/+3
2022-12-31lib.strings: isMoreCoercibleString -> isConvertibleWithToStringRobert Hensing1-5/+6
Yes, this function name is inconveniently long, but it is important for the name to explicitly reference the function and not be mistaken for the implicit string conversions, which only happen for a smaller set of values.
2022-12-31lib.strings: isSimpleCoercibleString -> isStringLikeRobert Hensing1-7/+7
2022-12-31treewide: isCoercibleToString -> isMoreCoercibleToStringRobert Hensing1-1/+1
No change in behavior.
2022-12-31lib.strings: Rename isCoercibleToString -> isMoreCoercibleToStringRobert Hensing1-2/+11
2022-12-31lib.strings.toShellVar: Use isSimpleCoercibleStringRobert Hensing1-1/+1
Expecting no change in behavior.
2022-12-31lib.strings.isStorePath: Use isSimpleCoercibleToStringRobert Hensing1-1/+1
Expecting no change in behavior.
2022-12-31lib.strings: Add isSimpleCoercibleToStringRobert Hensing1-0/+11
2022-12-20lib/strings: replace poop emoji (#206999)Naïm Favier1-1/+1
2022-12-17lib: fix typosfigsoda1-2/+2
2022-12-15lib.replaceChars: warn about being a deprecated aliasArtturin1-17/+6
replaceStrings has been in nix since 2015(nix 1.10) so it is safe to remove the fallback https://github.com/nixos/nix/commit/d6d5885c1567454754a0d260521bafa0bd5e7fdb
2022-12-11Merge pull request #205457 from ↵Robert Hensing1-6/+7
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/+11
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-6/+7
The previous version would be unstable due to an input validation regex not expecting a '-' in front of the number.
2022-12-08Merge pull request #204087 from ncfavier/splitString-simplifyNaïm Favier1-6/+4
2022-12-06lib/strings.nix: add mesonOption utility functionAndersonTorres1-0/+55
And some friends, to help write Meson commandline invocations.
2022-12-02lib/strings: simplify `splitString`Naïm Favier1-6/+4
There's no need to use `unsafeDiscardStringContext` since https://github.com/NixOS/nix/commit/ee7fe64c0ac00f2be11604a2a6509eb86dc19f0a (Nix 1.8). Also the separator can't have a context since `builtins.split` would fail, so we can assume it doesn't.
2022-10-24Merge pull request #173949 from jacoblambda/fix-toInt-zero-paddingRobert Hensing1-6/+87
lib: add strings.toIntBase10 to parse zero-padded strings
2022-10-24lib.normalizePath: the empty string is not a valid regex on darwinGuillaume Girol1-1/+1
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes https://github.com/NixOS/nixpkgs/pull/177273#issuecomment-1287562800
2022-10-23lib/strings: Update docs and restructured code to improve readability of ↵Jacob Abel1-21/+37
toInt and toIntBase10.
2022-10-23lib/strings: Improve error message for octal ambiguity in toIntJacob Abel1-3/+2
2022-10-23lib/strings: Refactor toInt into toInt and toIntBase10Jacob Abel1-3/+51
2022-10-23lib/strings: Update toInt to handle intermixed ws and zeros. Added testsJacob Abel1-7/+13
2022-10-23lib/strings: allow toInt to parse zero-padded stringsJacob Abel1-4/+16
2022-10-20lib.strings: Add normalizePathajs1241-0/+10
dedupes extranous /'s in filepaths Co-authored-by: Daniel Olsen <daniel.olsen99@gmail.com>
2022-10-20lib.strings: Add function to do C-style escapingDaniel Olsen1-0/+13
2022-10-20lib.strings: Add function to convert character to numberDaniel Olsen1-0/+15
2022-05-07lib/strings/toShellVars: handle derivations as stringsNaïm Favier1-4/+5