maintainers/scripts/update-dotnet-lockfiles.nix: use update.nix
This commit is contained in:
parent
e3736259f7
commit
9fb173da94
@ -8,69 +8,12 @@
|
|||||||
to 'fetch-deps', 'nuget-to-nix', or other changes to the dotnet build
|
to 'fetch-deps', 'nuget-to-nix', or other changes to the dotnet build
|
||||||
infrastructure. Regular updates should be done through the individual packages
|
infrastructure. Regular updates should be done through the individual packages
|
||||||
update scripts.
|
update scripts.
|
||||||
*/
|
*/
|
||||||
{ startWith ? null }:
|
{ ... }@args:
|
||||||
let
|
import ./update.nix (
|
||||||
pkgs = import ../.. { config.allowAliases = false; };
|
{
|
||||||
|
predicate = _: _: true;
|
||||||
inherit (pkgs) lib;
|
get-script = pkg: pkg.fetch-deps or null;
|
||||||
|
}
|
||||||
packagesWith = cond: pkgs:
|
// args
|
||||||
let
|
)
|
||||||
packagesWithInner = attrs:
|
|
||||||
lib.concatLists (
|
|
||||||
lib.mapAttrsToList (name: elem:
|
|
||||||
let
|
|
||||||
result = builtins.tryEval elem;
|
|
||||||
in
|
|
||||||
if result.success then
|
|
||||||
let
|
|
||||||
value = result.value;
|
|
||||||
in
|
|
||||||
if lib.isDerivation value then
|
|
||||||
lib.optional (cond value) value
|
|
||||||
else
|
|
||||||
if lib.isAttrs value && (value.recurseForDerivations or false || value.recurseForRelease or false) then
|
|
||||||
packagesWithInner value
|
|
||||||
else []
|
|
||||||
else []) attrs);
|
|
||||||
in
|
|
||||||
packagesWithInner pkgs;
|
|
||||||
|
|
||||||
packages = lib.unique
|
|
||||||
(lib.filter (p:
|
|
||||||
(builtins.tryEval p.outPath).success ||
|
|
||||||
builtins.trace "warning: skipping ${p.name} because it failed to evaluate" false)
|
|
||||||
((pkgs: (lib.drop (lib.lists.findFirstIndex (p: p.name == startWith) 0 pkgs) pkgs))
|
|
||||||
(packagesWith (p: p ? fetch-deps) pkgs)));
|
|
||||||
|
|
||||||
helpText = ''
|
|
||||||
Please run:
|
|
||||||
|
|
||||||
% nix-shell maintainers/scripts/update-dotnet-lockfiles.nix
|
|
||||||
'';
|
|
||||||
|
|
||||||
fetchScripts = map (p: p.fetch-deps) packages;
|
|
||||||
|
|
||||||
in pkgs.stdenv.mkDerivation {
|
|
||||||
name = "nixpkgs-update-dotnet-lockfiles";
|
|
||||||
buildCommand = ''
|
|
||||||
echo ""
|
|
||||||
echo "----------------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
echo "Not possible to update packages using \`nix-build\`"
|
|
||||||
echo ""
|
|
||||||
echo "${helpText}"
|
|
||||||
echo "----------------------------------------------------------------"
|
|
||||||
exit 1
|
|
||||||
'';
|
|
||||||
shellHook = ''
|
|
||||||
unset shellHook # do not contaminate nested shells
|
|
||||||
set -e
|
|
||||||
for x in $fetchScripts; do
|
|
||||||
$x
|
|
||||||
done
|
|
||||||
exit
|
|
||||||
'';
|
|
||||||
inherit fetchScripts;
|
|
||||||
}
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
{ package ? null
|
{ package ? null
|
||||||
, maintainer ? null
|
, maintainer ? null
|
||||||
, predicate ? null
|
, predicate ? null
|
||||||
|
, get-script ? pkg: pkg.updateScript or null
|
||||||
, path ? null
|
, path ? null
|
||||||
, max-workers ? null
|
, max-workers ? null
|
||||||
, include-overlays ? false
|
, include-overlays ? false
|
||||||
@ -56,7 +57,7 @@ let
|
|||||||
|
|
||||||
somewhatUniqueRepresentant =
|
somewhatUniqueRepresentant =
|
||||||
{ package, attrPath }: {
|
{ package, attrPath }: {
|
||||||
inherit (package) updateScript;
|
updateScript = (get-script package);
|
||||||
# Some updaters use the same `updateScript` value for all packages.
|
# Some updaters use the same `updateScript` value for all packages.
|
||||||
# Also compare `meta.description`.
|
# Also compare `meta.description`.
|
||||||
position = package.meta.position or null;
|
position = package.meta.position or null;
|
||||||
@ -89,7 +90,7 @@ let
|
|||||||
/* Recursively find all packages in `pkgs` with updateScript matching given predicate.
|
/* Recursively find all packages in `pkgs` with updateScript matching given predicate.
|
||||||
*/
|
*/
|
||||||
packagesWithUpdateScriptMatchingPredicate = cond:
|
packagesWithUpdateScriptMatchingPredicate = cond:
|
||||||
packagesWith (path: pkg: builtins.hasAttr "updateScript" pkg && cond path pkg);
|
packagesWith (path: pkg: (get-script pkg != null) && 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.
|
||||||
*/
|
*/
|
||||||
@ -121,7 +122,7 @@ let
|
|||||||
if pathContent == null then
|
if pathContent == null then
|
||||||
builtins.throw "Attribute path `${path}` does not exist."
|
builtins.throw "Attribute path `${path}` does not exist."
|
||||||
else
|
else
|
||||||
packagesWithPath prefix (path: pkg: builtins.hasAttr "updateScript" pkg)
|
packagesWithPath prefix (path: pkg: (get-script pkg != null))
|
||||||
pathContent;
|
pathContent;
|
||||||
|
|
||||||
/* Find a package under `path` in `pkgs` and require that it has an updateScript.
|
/* Find a package under `path` in `pkgs` and require that it has an updateScript.
|
||||||
@ -132,7 +133,7 @@ let
|
|||||||
in
|
in
|
||||||
if package == null then
|
if package == null then
|
||||||
builtins.throw "Package with an attribute name `${path}` does not exist."
|
builtins.throw "Package with an attribute name `${path}` does not exist."
|
||||||
else if ! builtins.hasAttr "updateScript" package then
|
else if get-script package == null then
|
||||||
builtins.throw "Package with an attribute name `${path}` does not have a `passthru.updateScript` attribute defined."
|
builtins.throw "Package with an attribute name `${path}` does not have a `passthru.updateScript` attribute defined."
|
||||||
else
|
else
|
||||||
{ attrPath = path; inherit package; };
|
{ attrPath = path; inherit package; };
|
||||||
@ -193,13 +194,13 @@ let
|
|||||||
|
|
||||||
/* Transform a matched package into an object for update.py.
|
/* Transform a matched package into an object for update.py.
|
||||||
*/
|
*/
|
||||||
packageData = { package, attrPath }: {
|
packageData = { package, attrPath }: let updateScript = get-script package; in {
|
||||||
name = package.name;
|
name = package.name;
|
||||||
pname = lib.getName package;
|
pname = lib.getName package;
|
||||||
oldVersion = lib.getVersion package;
|
oldVersion = lib.getVersion package;
|
||||||
updateScript = map builtins.toString (lib.toList (package.updateScript.command or package.updateScript));
|
updateScript = map builtins.toString (lib.toList (updateScript.command or updateScript));
|
||||||
supportedFeatures = package.updateScript.supportedFeatures or [];
|
supportedFeatures = updateScript.supportedFeatures or [];
|
||||||
attrPath = package.updateScript.attrPath or attrPath;
|
attrPath = updateScript.attrPath or attrPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* JSON file with data for update.py.
|
/* JSON file with data for update.py.
|
||||||
|
Loading…
Reference in New Issue
Block a user