Age | Commit message (Collapse) | Author | Files | Lines |
|
lib.strings: Prevent paths as inputs in some functions
|
|
See also parent commits
|
|
There's no need to call this function on path data types, and it's
confusing with the new lib.path library functions
|
|
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
|
|
Since it's an attribute set, the lib function location generating code
tries to generate locations for each of the characters...
|
|
|
|
lib/strings: add `concatLines`
|
|
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.
|
|
|
|
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.
|
|
|
|
No change in behavior.
|
|
|
|
Expecting no change in behavior.
|
|
Expecting no change in behavior.
|
|
|
|
|
|
|
|
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
|
|
h7x4/lib-strings-toInt-broken-for-negative-numbers
lib.strings: fix negative number handling for `toInt` and `toIntBase10`
|
|
Like `unlines` from Haskell.
The aim is to replace the `concatStringsSep "\n"` pattern for generated
files, which doesn't add a final newline.
|
|
The previous version would be unstable due to an input validation regex
not expecting a '-' in front of the number.
|
|
|
|
And some friends, to help write Meson commandline invocations.
|
|
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.
|
|
lib: add strings.toIntBase10 to parse zero-padded strings
|
|
presumably due to using libc++'s regex lib instead of libstdc++ on linux
Fixes https://github.com/NixOS/nixpkgs/pull/177273#issuecomment-1287562800
|
|
toInt and toIntBase10.
|
|
|
|
|
|
|
|
|
|
dedupes extranous /'s in filepaths
Co-authored-by: Daniel Olsen <daniel.olsen99@gmail.com>
|
|
|
|
|
|
|
|
This should fix the issue mentioned here:
https://github.com/NixOS/nixpkgs/pull/168175#issuecomment-1107830574
|
|
Co-authored-by: Silvan Mosberger <github@infinisil.com>
|
|
A straightforward piece of plumbing to safely inject Nix variables into
shell scripts:
''
${lib.toShellVars { inherit foo bar; }}
cmd "$foo" --bar "$bar"
''
|
|
* lib/strings: optimise hasInfix function
* lib/strings: optimise hasInfix further using regex
* rstudio: call hasInfix with a string
* lib/strings: remove let from hasInfix
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
|
|
Always sanitize derivation name
|
|
`^` and `$` are implicit in `match`.
|
|
Adds some functions related to string similarity:
- lib.strings.commonPrefixLength
- lib.strings.commonSuffixLength
- lib.strings.levenshtein
- lib.strings.levenshteinAtMost
|
|
|
|
The previous example output was forgotten copy-paste from some other
function.
|
|
Given a string, this function returns a string that can be inserted
verbatim in an XML document.
|
|
The current implementation of the concatStringsSep fallback references
concatStrings whcih is just a partial application of concatStringsSep,
forming a circular dependency. Although this will almost never be
encountered as (assuming the user does not explicitly trigger it):
1. the or operator will short circuit both in lazy and strict
evaluation
2. this can only occur in Nix versions prior to 1.10
which is not compatible with various nix operations as of 2.3.15
However it is still important if scopedImport is used or the builtins
have been overwritten. lib.foldl' is used instead of builtins.foldl'
as the foldl' primops was introduced in the same release as concatStringsSep.
|
|
These functions work on lists of anything, not just lists of strings.
|
|
When a list is passed to isStorePath this is most likely a mistake and
it is therefore better to just return false. There is one case where
this theoretically makes sense (if a list contains a single element for
which isStorePath elem), but since that case is also probably seldomly
intentional, it may save someone from debbuging unclear evaluation
errors.
|
|
Since it checks if dirOf x is the nix store dir, a trailing slash will
break this check and make it return false.
|