{ unstable_pkgs, stable_pkgs, extra_lib, }: let inherit (unstable_pkgs) lib; mergePkgs = pkgs: lib.callPackageWith (extra_lib.warnMerge pkgs in_tree_pkgs "the ./pkgs/by-name set"); callPackageStable = mergePkgs stable_pkgs; callPackageUnstable = mergePkgs unstable_pkgs; in_tree_pkgs = extra_lib.mkByName { baseDirectory = ./by-name; fileRegex = "package.(stable|unstable).nix"; finalizeFunction = name: pkgPathList: let # When specifying a regex `mkByName` returns a list of candidates. # But we know, that there can only be one. pkgPath = builtins.head pkgPathList; in if (builtins.match "(stable)" (builtins.baseNameOf pkgPath)) == ["stable"] then callPackageStable pkgPath {} else callPackageUnstable pkgPath {}; }; in in_tree_pkgs