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
|
||||
infrastructure. Regular updates should be done through the individual packages
|
||||
update scripts.
|
||||
*/
|
||||
{ startWith ? null }:
|
||||
let
|
||||
pkgs = import ../.. { config.allowAliases = false; };
|
||||
|
||||
inherit (pkgs) lib;
|
||||
|
||||
packagesWith = cond: pkgs:
|
||||
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;
|
||||
}
|
||||
*/
|
||||
{ ... }@args:
|
||||
import ./update.nix (
|
||||
{
|
||||
predicate = _: _: true;
|
||||
get-script = pkg: pkg.fetch-deps or null;
|
||||
}
|
||||
// args
|
||||
)
|
||||
|
@ -8,6 +8,7 @@
|
||||
{ package ? null
|
||||
, maintainer ? null
|
||||
, predicate ? null
|
||||
, get-script ? pkg: pkg.updateScript or null
|
||||
, path ? null
|
||||
, max-workers ? null
|
||||
, include-overlays ? false
|
||||
@ -56,7 +57,7 @@ let
|
||||
|
||||
somewhatUniqueRepresentant =
|
||||
{ package, attrPath }: {
|
||||
inherit (package) updateScript;
|
||||
updateScript = (get-script package);
|
||||
# Some updaters use the same `updateScript` value for all packages.
|
||||
# Also compare `meta.description`.
|
||||
position = package.meta.position or null;
|
||||
@ -89,7 +90,7 @@ let
|
||||
/* Recursively find all packages in `pkgs` with updateScript matching given predicate.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -121,7 +122,7 @@ let
|
||||
if pathContent == null then
|
||||
builtins.throw "Attribute path `${path}` does not exist."
|
||||
else
|
||||
packagesWithPath prefix (path: pkg: builtins.hasAttr "updateScript" pkg)
|
||||
packagesWithPath prefix (path: pkg: (get-script pkg != null))
|
||||
pathContent;
|
||||
|
||||
/* Find a package under `path` in `pkgs` and require that it has an updateScript.
|
||||
@ -132,7 +133,7 @@ let
|
||||
in
|
||||
if package == null then
|
||||
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."
|
||||
else
|
||||
{ attrPath = path; inherit package; };
|
||||
@ -193,13 +194,13 @@ let
|
||||
|
||||
/* 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;
|
||||
pname = lib.getName package;
|
||||
oldVersion = lib.getVersion package;
|
||||
updateScript = map builtins.toString (lib.toList (package.updateScript.command or package.updateScript));
|
||||
supportedFeatures = package.updateScript.supportedFeatures or [];
|
||||
attrPath = package.updateScript.attrPath or attrPath;
|
||||
updateScript = map builtins.toString (lib.toList (updateScript.command or updateScript));
|
||||
supportedFeatures = updateScript.supportedFeatures or [];
|
||||
attrPath = updateScript.attrPath or attrPath;
|
||||
};
|
||||
|
||||
/* JSON file with data for update.py.
|
||||
|
Loading…
Reference in New Issue
Block a user