lib/removePackages: Match names by regex

This commit is contained in:
Mikael Voss 2024-08-31 19:46:19 +02:00
parent 81fab8da3b
commit fa507f5f71
No known key found for this signature in database

View file

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