lib/removePackages: Match names by regex

This commit is contained in:
Mikael 2024-08-31 19:46:19 +02:00
parent 81fab8da3b
commit fa507f5f71
Signed by: mikael
SSH key fingerprint: SHA256:21QyD2Meiot7jOUVitIR5YkGB/XuXdCvLW1hE6dsri0

View file

@ -1,8 +1,10 @@
{ nixpkgs, ... }: { nixpkgs, ... }:
let let
inherit (builtins) elem filter; inherit (builtins) match filter foldl';
inherit (nixpkgs.lib.strings) getName; inherit (nixpkgs.lib.strings) getName;
in pkgOrNameList: pkgList:
let nameList = map (pkg: getName pkg) pkgOrNameList; fold = name: acc: regex:
in filter (pkg: !elem (getName pkg) nameList) pkgList if acc == false then false
else match regex name == null;
in regexList: filter (pkg: foldl' (getName pkg |> fold) true regexList)