2024-08-24 13:10:45 +02:00
|
|
|
{ nixpkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2024-08-24 13:16:55 +02:00
|
|
|
inherit (builtins) filter isList isString stringLength;
|
|
|
|
inherit (nixpkgs.lib.lists) subtractLists;
|
2024-08-24 13:10:45 +02:00
|
|
|
inherit (nixpkgs.lib.strings) addContextFrom;
|
|
|
|
|
|
|
|
split = strOrList:
|
|
|
|
if isList strOrList then strOrList
|
|
|
|
else builtins.split "[[:space:]]+" strOrList
|
|
|
|
|> filter (flag: isString flag && stringLength flag > 0)
|
|
|
|
|> map (flag: addContextFrom strOrList flag);
|
|
|
|
|
|
|
|
remerge = strOrList: list:
|
|
|
|
if isList strOrList then list
|
|
|
|
else toString list;
|
|
|
|
in {
|
|
|
|
remove = rem: strOrList: split strOrList
|
2024-08-24 13:16:55 +02:00
|
|
|
|> subtractLists rem
|
2024-08-24 13:10:45 +02:00
|
|
|
|> remerge strOrList;
|
|
|
|
|
|
|
|
subst = sub: strOrList: split strOrList
|
|
|
|
|> map (flag: sub.${flag} or flag)
|
|
|
|
|> remerge strOrList;
|
|
|
|
}
|