mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 23:36:17 +01:00
4239bf17ec
When the updates are not frozen, there is no need to try to extract versions from attributes.
26 lines
1.3 KiB
Nix
26 lines
1.3 KiB
Nix
{ stdenv, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
||
{ packageName, attrPath ? packageName, versionPolicy ? "odd-unstable", freeze ? false }:
|
||
|
||
let
|
||
python = python3.withPackages (p: [ p.requests ]);
|
||
upperBoundFlag =
|
||
let
|
||
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
||
packageVersion = lib.getVersion package;
|
||
versionComponents = lib.versions.splitVersion packageVersion;
|
||
minorVersion = lib.versions.minor packageVersion;
|
||
minorAvailable = builtins.length versionComponents > 1 && builtins.match "[0-9]+" minorVersion != null;
|
||
nextMinor = builtins.fromJSON minorVersion + 1;
|
||
upperBound = "${lib.versions.major packageVersion}.${builtins.toString nextMinor}";
|
||
in lib.optionalString (freeze && minorAvailable) ''--upper-bound="${upperBound}"'';
|
||
updateScript = writeScript "gnome-update-script" ''
|
||
#!${stdenv.shell}
|
||
set -o errexit
|
||
package_name="$1"
|
||
attr_path="$2"
|
||
version_policy="$3"
|
||
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
||
latest_tag=$(python "${./find-latest-version.py}" "$package_name" "$version_policy" "stable" ${upperBoundFlag})
|
||
update-source-version "$attr_path" "$latest_tag"
|
||
'';
|
||
in [ updateScript packageName attrPath versionPolicy ]
|