about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosé Romildo <malaquias@gmail.com>2022-09-26 21:40:42 -0300
committerJosé Romildo <malaquias@gmail.com>2022-09-26 22:16:19 -0300
commit1f239257c536b461bbed049e6bc90ac5fa096ac8 (patch)
tree8cd0b1177ecf5d9bcb4869b0ff1795f73e352789
parentea4a87537cfdc83eebcd1804a5ec51057018784f (diff)
maintainers/scripts/update.nix: make package name, pname and old version available to the update script
-rw-r--r--doc/stdenv/stdenv.chapter.md2
-rw-r--r--maintainers/scripts/update.py12
2 files changed, 12 insertions, 2 deletions
diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md
index 93351ce1bdb3c..e87ab47270774 100644
--- a/doc/stdenv/stdenv.chapter.md
+++ b/doc/stdenv/stdenv.chapter.md
@@ -309,7 +309,7 @@ The attribute can also contain a list, a script followed by arguments to be pass
 passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
 ```
 
-The script will be run with `UPDATE_NIX_ATTR_PATH` environment variable set to the attribute path it is supposed to update.
+The script will be run with the `UPDATE_NIX_NAME`, `UPDATE_NIX_PNAME`, `UPDATE_NIX_OLD_VERSION` and `UPDATE_NIX_ATTR_PATH` environment variables set respectively to the name, pname, old version and attribute path of the package it is supposed to update.
 
 ::: {.note}
 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.
diff --git a/maintainers/scripts/update.py b/maintainers/scripts/update.py
index f1bed6527e797..7ae08958a1646 100644
--- a/maintainers/scripts/update.py
+++ b/maintainers/scripts/update.py
@@ -52,7 +52,17 @@ async def run_update_script(nixpkgs_root: str, merge_lock: asyncio.Lock, temp_di
     eprint(f" - {package['name']}: UPDATING ...")
 
     try:
-        update_process = await check_subprocess('env', f"UPDATE_NIX_ATTR_PATH={package['attrPath']}", *update_script_command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=worktree)
+        update_process = await check_subprocess(
+            'env',
+            f"UPDATE_NIX_NAME={package['name']}",
+            f"UPDATE_NIX_PNAME={package['pname']}",
+            f"UPDATE_NIX_OLD_VERSION={package['oldVersion']}",
+            f"UPDATE_NIX_ATTR_PATH={package['attrPath']}",
+            *update_script_command,
+            stdout=asyncio.subprocess.PIPE,
+            stderr=asyncio.subprocess.PIPE,
+            cwd=worktree,
+        )
         update_info = await update_process.stdout.read()
 
         await merge_changes(merge_lock, package, update_info, temp_dir)