maintainers/scripts/update.nix: Import lib into scope
This will make it easier to change it if we want to decouple from pkgs.
This commit is contained in:
parent
683c68232e
commit
8f50956ee0
|
@ -9,6 +9,10 @@
|
||||||
# TODO: add assert statements
|
# TODO: add assert statements
|
||||||
|
|
||||||
let
|
let
|
||||||
|
pkgs = import ./../../default.nix (if include-overlays then { } else { overlays = []; });
|
||||||
|
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
/* Remove duplicate elements from the list based on some extracted value. O(n^2) complexity.
|
/* Remove duplicate elements from the list based on some extracted value. O(n^2) complexity.
|
||||||
*/
|
*/
|
||||||
nubOn = f: list:
|
nubOn = f: list:
|
||||||
|
@ -16,21 +20,19 @@ let
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
x = pkgs.lib.head list;
|
x = lib.head list;
|
||||||
xs = pkgs.lib.filter (p: f x != f p) (pkgs.lib.drop 1 list);
|
xs = lib.filter (p: f x != f p) (lib.drop 1 list);
|
||||||
in
|
in
|
||||||
[x] ++ nubOn f xs;
|
[x] ++ nubOn f xs;
|
||||||
|
|
||||||
pkgs = import ./../../default.nix (if include-overlays then { } else { overlays = []; });
|
|
||||||
|
|
||||||
packagesWith = cond: return: set:
|
packagesWith = cond: return: set:
|
||||||
nubOn (pkg: pkg.updateScript)
|
nubOn (pkg: pkg.updateScript)
|
||||||
(pkgs.lib.flatten
|
(lib.flatten
|
||||||
(pkgs.lib.mapAttrsToList
|
(lib.mapAttrsToList
|
||||||
(name: pkg:
|
(name: pkg:
|
||||||
let
|
let
|
||||||
result = builtins.tryEval (
|
result = builtins.tryEval (
|
||||||
if pkgs.lib.isDerivation pkg && cond name pkg
|
if lib.isDerivation pkg && cond name pkg
|
||||||
then [(return name pkg)]
|
then [(return name pkg)]
|
||||||
else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
|
else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
|
||||||
then packagesWith cond return pkg
|
then packagesWith cond return pkg
|
||||||
|
@ -47,10 +49,10 @@ let
|
||||||
packagesWithUpdateScriptAndMaintainer = maintainer':
|
packagesWithUpdateScriptAndMaintainer = maintainer':
|
||||||
let
|
let
|
||||||
maintainer =
|
maintainer =
|
||||||
if ! builtins.hasAttr maintainer' pkgs.lib.maintainers then
|
if ! builtins.hasAttr maintainer' lib.maintainers then
|
||||||
builtins.throw "Maintainer with name `${maintainer'} does not exist in `maintainers/maintainer-list.nix`."
|
builtins.throw "Maintainer with name `${maintainer'} does not exist in `maintainers/maintainer-list.nix`."
|
||||||
else
|
else
|
||||||
builtins.getAttr maintainer' pkgs.lib.maintainers;
|
builtins.getAttr maintainer' lib.maintainers;
|
||||||
in
|
in
|
||||||
packagesWith (name: pkg: builtins.hasAttr "updateScript" pkg &&
|
packagesWith (name: pkg: builtins.hasAttr "updateScript" pkg &&
|
||||||
(if builtins.hasAttr "maintainers" pkg.meta
|
(if builtins.hasAttr "maintainers" pkg.meta
|
||||||
|
@ -66,7 +68,7 @@ let
|
||||||
|
|
||||||
packagesWithUpdateScript = path:
|
packagesWithUpdateScript = path:
|
||||||
let
|
let
|
||||||
attrSet = pkgs.lib.attrByPath (pkgs.lib.splitString "." path) null pkgs;
|
attrSet = lib.attrByPath (lib.splitString "." path) null pkgs;
|
||||||
in
|
in
|
||||||
if attrSet == null then
|
if attrSet == null then
|
||||||
builtins.throw "Attribute path `${path}` does not exists."
|
builtins.throw "Attribute path `${path}` does not exists."
|
||||||
|
@ -77,7 +79,7 @@ let
|
||||||
|
|
||||||
packageByName = name:
|
packageByName = name:
|
||||||
let
|
let
|
||||||
package = pkgs.lib.attrByPath (pkgs.lib.splitString "." name) null pkgs;
|
package = lib.attrByPath (lib.splitString "." name) null pkgs;
|
||||||
in
|
in
|
||||||
if package == null then
|
if package == null then
|
||||||
builtins.throw "Package with an attribute name `${name}` does not exists."
|
builtins.throw "Package with an attribute name `${name}` does not exists."
|
||||||
|
@ -125,15 +127,15 @@ let
|
||||||
|
|
||||||
packageData = package: {
|
packageData = package: {
|
||||||
name = package.name;
|
name = package.name;
|
||||||
pname = pkgs.lib.getName package;
|
pname = lib.getName package;
|
||||||
updateScript = map builtins.toString (pkgs.lib.toList package.updateScript);
|
updateScript = map builtins.toString (lib.toList package.updateScript);
|
||||||
};
|
};
|
||||||
|
|
||||||
packagesJson = pkgs.writeText "packages.json" (builtins.toJSON (map packageData packages));
|
packagesJson = pkgs.writeText "packages.json" (builtins.toJSON (map packageData packages));
|
||||||
|
|
||||||
optionalArgs =
|
optionalArgs =
|
||||||
pkgs.lib.optional (max-workers != null) "--max-workers=${max-workers}"
|
lib.optional (max-workers != null) "--max-workers=${max-workers}"
|
||||||
++ pkgs.lib.optional (keep-going == "true") "--keep-going";
|
++ lib.optional (keep-going == "true") "--keep-going";
|
||||||
|
|
||||||
args = [ packagesJson ] ++ optionalArgs;
|
args = [ packagesJson ] ++ optionalArgs;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue