23 lines
553 B
Nix
23 lines
553 B
Nix
{ ... }:
|
|
let
|
|
inherit (builtins) stringLength substring;
|
|
# aka startsWith but hopefully clear from the name what order the arguments go
|
|
isPrefixOf =
|
|
prefix: s:
|
|
let
|
|
prefixl = stringLength prefix;
|
|
sl = stringLength s;
|
|
in
|
|
(sl >= prefixl) && (substring 0 prefixl s) == prefix;
|
|
isSuffixOf =
|
|
suffix: s:
|
|
let
|
|
suffixl = stringLength suffix;
|
|
sl = stringLength s;
|
|
in
|
|
(sl >= suffixl) && (substring (sl - suffixl - 1) - 1 s) == suffix;
|
|
in
|
|
{
|
|
config.vacu.vaculib = { inherit isPrefixOf isSuffixOf; };
|
|
}
|