forked from mirrors/nixpkgs
maintainers/scripts/update.nix: Add support for filtering pkgs by predicate
Arbitrary predicate is useful for updating decentralised package sets like GNOME.
This commit is contained in:
parent
7d535edec5
commit
d51a631a46
|
@ -1,5 +1,6 @@
|
||||||
{ package ? null
|
{ package ? null
|
||||||
, maintainer ? null
|
, maintainer ? null
|
||||||
|
, predicate ? null
|
||||||
, path ? null
|
, path ? null
|
||||||
, max-workers ? null
|
, max-workers ? null
|
||||||
, include-overlays ? false
|
, include-overlays ? false
|
||||||
|
@ -69,6 +70,11 @@ let
|
||||||
*/
|
*/
|
||||||
packagesWith = packagesWithPath [];
|
packagesWith = packagesWithPath [];
|
||||||
|
|
||||||
|
/* Recursively find all packages in `pkgs` with updateScript matching given predicate.
|
||||||
|
*/
|
||||||
|
packagesWithUpdateScriptMatchingPredicate = cond:
|
||||||
|
packagesWith (path: pkg: builtins.hasAttr "updateScript" pkg && cond path pkg);
|
||||||
|
|
||||||
/* Recursively find all packages in `pkgs` with updateScript by given maintainer.
|
/* Recursively find all packages in `pkgs` with updateScript by given maintainer.
|
||||||
*/
|
*/
|
||||||
packagesWithUpdateScriptAndMaintainer = maintainer':
|
packagesWithUpdateScriptAndMaintainer = maintainer':
|
||||||
|
@ -79,7 +85,7 @@ let
|
||||||
else
|
else
|
||||||
builtins.getAttr maintainer' lib.maintainers;
|
builtins.getAttr maintainer' lib.maintainers;
|
||||||
in
|
in
|
||||||
packagesWith (path: pkg: builtins.hasAttr "updateScript" pkg &&
|
packagesWithUpdateScriptMatchingPredicate (path: pkg:
|
||||||
(if builtins.hasAttr "maintainers" pkg.meta
|
(if builtins.hasAttr "maintainers" pkg.meta
|
||||||
then (if builtins.isList pkg.meta.maintainers
|
then (if builtins.isList pkg.meta.maintainers
|
||||||
then builtins.elem maintainer pkg.meta.maintainers
|
then builtins.elem maintainer pkg.meta.maintainers
|
||||||
|
@ -120,6 +126,8 @@ let
|
||||||
packages =
|
packages =
|
||||||
if package != null then
|
if package != null then
|
||||||
[ (packageByName package pkgs) ]
|
[ (packageByName package pkgs) ]
|
||||||
|
else if predicate != null then
|
||||||
|
packagesWithUpdateScriptMatchingPredicate predicate pkgs
|
||||||
else if maintainer != null then
|
else if maintainer != null then
|
||||||
packagesWithUpdateScriptAndMaintainer maintainer pkgs
|
packagesWithUpdateScriptAndMaintainer maintainer pkgs
|
||||||
else if path != null then
|
else if path != null then
|
||||||
|
@ -139,6 +147,10 @@ let
|
||||||
|
|
||||||
to run update script for specific package, or
|
to run update script for specific package, or
|
||||||
|
|
||||||
|
% nix-shell maintainers/scripts/update.nix --arg predicate '(path: pkg: builtins.isList pkg.updateScript && builtins.length pkg.updateScript >= 1 && (let script = builtins.head pkg.updateScript; in builtins.isAttrs script && script.name == "gnome-update-script"))'
|
||||||
|
|
||||||
|
to run update script for all packages matching given predicate, or
|
||||||
|
|
||||||
% nix-shell maintainers/scripts/update.nix --argstr path gnome3
|
% nix-shell maintainers/scripts/update.nix --argstr path gnome3
|
||||||
|
|
||||||
to run update script for all package under an attribute path.
|
to run update script for all package under an attribute path.
|
||||||
|
|
Loading…
Reference in a new issue