diff --git a/doc/stdenv.xml b/doc/stdenv.xml index 00d1ec87098..a14d78afe71 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -709,19 +709,16 @@ passthru.updateScript = writeScript "update-zoom-us" '' passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]; - Note that the update scripts will be run in parallel by default; you - should avoid running git commit or any other commands - that cannot handle that. + + + The script will be usually run from the root of the Nixpkgs repository + but you should not rely on that. Also note that the update scripts will + be run in parallel by default; you should avoid running git + commit or any other commands that cannot handle that. For information about how to run the updates, execute - - nix-shell - - maintainers/scripts/update.nix - - - . + nix-shell maintainers/scripts/update.nix. diff --git a/maintainers/scripts/update.nix b/maintainers/scripts/update.nix index 120cd5552f4..04723cb8a36 100755 --- a/maintainers/scripts/update.nix +++ b/maintainers/scripts/update.nix @@ -20,7 +20,9 @@ let in [x] ++ nubOn f xs; - pkgs = import ./../../default.nix { }; + pkgs = import ./../../default.nix { + overlays = []; + }; packagesWith = cond: return: set: nubOn (pkg: pkg.updateScript) @@ -67,9 +69,12 @@ let let attrSet = pkgs.lib.attrByPath (pkgs.lib.splitString "." path) null pkgs; in - packagesWith (name: pkg: builtins.hasAttr "updateScript" pkg) - (name: pkg: pkg) - attrSet; + if attrSet == null then + builtins.throw "Attribute path `${path}` does not exists." + else + packagesWith (name: pkg: builtins.hasAttr "updateScript" pkg) + (name: pkg: pkg) + attrSet; packageByName = name: let @@ -122,9 +127,17 @@ let packageData = package: { name = package.name; pname = (builtins.parseDrvName package.name).name; - updateScript = pkgs.lib.toList package.updateScript; + updateScript = map builtins.toString (pkgs.lib.toList package.updateScript); }; + packagesJson = pkgs.writeText "packages.json" (builtins.toJSON (map packageData packages)); + + optionalArgs = + pkgs.lib.optional (max-workers != null) "--max-workers=${max-workers}" + ++ pkgs.lib.optional (keep-going == "true") "--keep-going"; + + args = [ packagesJson ] ++ optionalArgs; + in pkgs.stdenv.mkDerivation { name = "nixpkgs-update-script"; buildCommand = '' @@ -139,6 +152,6 @@ in pkgs.stdenv.mkDerivation { ''; shellHook = '' unset shellHook # do not contaminate nested shells - exec ${pkgs.python3.interpreter} ${./update.py} ${pkgs.writeText "packages.json" (builtins.toJSON (map packageData packages))}${pkgs.lib.optionalString (max-workers != null) " --max-workers=${max-workers}"}${pkgs.lib.optionalString (keep-going == "true") " --keep-going"} + exec ${pkgs.python3.interpreter} ${./update.py} ${builtins.concatStringsSep " " args} ''; } diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index bc2c68feaea..591ffa6ca5b 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -86,14 +86,10 @@ if [ $(grep -c "$oldHash" "$nixFile") != 1 ]; then die "Couldn't locate old source hash '$oldHash' (or it appeared more than once) in '$nixFile'!" fi -oldUrl=$(nix-instantiate $systemArg --eval -E "with import ./. {}; builtins.elemAt $attr.src.drvAttrs.urls 0" | tr -d '"') +oldUrl=$(nix-instantiate $systemArg --eval -E "with import ./. {}; builtins.elemAt ($attr.src.drvAttrs.urls or [ $attr.src.url ]) 0" | tr -d '"') if [ -z "$oldUrl" ]; then - oldUrl=$(nix-instantiate $systemArg --eval -E "with import ./. {}; $attr.src.url" | tr -d '"') - - if [ -z "$oldUrl" ]; then - die "Couldn't evaluate source url from '$attr.src'!" - fi + die "Couldn't evaluate source url from '$attr.src'!" fi drvName=$(nix-instantiate $systemArg --eval -E "with import ./. {}; (builtins.parseDrvName $attr.name).name" | tr -d '"') @@ -109,13 +105,13 @@ if [ "$oldVersion" = "$newVersion" ]; then fi # Escape regex metacharacter that are allowed in store path names -oldVersion=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g') -oldUrl=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g') +oldVersionEscaped=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g') +oldUrlEscaped=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g') -if [ $(grep -c -E "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then - pattern="/\b$versionKey\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|" -elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersion\"" "$nixFile") = 1 ]; then - pattern="/\bname\b\s*=/ s|-$oldVersion\"|-$newVersion\"|" +if [ $(grep -c -E "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersionEscaped\"" "$nixFile") = 1 ]; then + pattern="/\b$versionKey\b\s*=/ s|\"$oldVersionEscaped\"|\"$newVersion\"|" +elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersionEscaped\"" "$nixFile") = 1 ]; then + pattern="/\bname\b\s*=/ s|-$oldVersionEscaped\"|-$newVersion\"|" else die "Couldn't figure out where out where to patch in new version in '$attr'!" fi @@ -128,7 +124,7 @@ fi # Replace new URL if [ -n "$newUrl" ]; then - sed -i "$nixFile" -re "s|\"$oldUrl\"|\"$newUrl\"|" + sed -i "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|" if cmp -s "$nixFile" "$nixFile.bak"; then die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!" diff --git a/pkgs/desktops/gnome-3/update.nix b/pkgs/desktops/gnome-3/update.nix index 2ee72d46993..f42b6723950 100644 --- a/pkgs/desktops/gnome-3/update.nix +++ b/pkgs/desktops/gnome-3/update.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, writeScript, python3, common-updater-scripts, coreutils, gnugrep, gnused }: +{ stdenv, lib, writeScript, python3, common-updater-scripts }: { packageName, attrPath ? packageName, versionPolicy ? "odd-unstable" }: let @@ -9,7 +9,7 @@ let package_name="$1" attr_path="$2" version_policy="$3" - PATH=${lib.makeBinPath [ common-updater-scripts coreutils gnugrep gnused python ]} + PATH=${lib.makeBinPath [ common-updater-scripts python ]} latest_tag=$(python "${./find-latest-version.py}" "$package_name" "$version_policy" "stable") update-source-version "$attr_path" "$latest_tag" '';