From db09ceb5bbdc0f2aea9a4c758857db9be1894503 Mon Sep 17 00:00:00 2001 From: superherointj <5861043+superherointj@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:24:11 -0300 Subject: [PATCH] azure-cli: add generate-extensions routine At nixpkgs, generate-extensions routine can be executed as: nix run .#azure-cli.passthru.generate-extensions --- pkgs/by-name/az/azure-cli/README.md | 11 +++++------ pkgs/by-name/az/azure-cli/extensions-generated.nix | 7 +------ pkgs/by-name/az/azure-cli/package.nix | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/az/azure-cli/README.md b/pkgs/by-name/az/azure-cli/README.md index ec98c8cb7d24..4d899ff52af0 100644 --- a/pkgs/by-name/az/azure-cli/README.md +++ b/pkgs/by-name/az/azure-cli/README.md @@ -19,13 +19,12 @@ ## Extensions -There are two sets of extensions: the one in `extensions-generated.nix` is generated with the script -`query-extension-index.sh`. These are extensions that don't have external requirements and thus can -be easily maintained and updated. The set should only be manipulated through an update based on the -script output. +There are two sets of extensions: -The other set of extensions is in `extensions-manual.nix`. These are extensions with requirements, -which need to be packaged and maintained manually. +- `extensions-generated.nix` are extensions with no external requirements, which can be regenerated running: + > nix run .#azure-cli.passthru.generate-extensions + +- `extensions-manual.nix` are extensions with requirements, which need to be manually packaged and maintained. ### Adding an extension to `extensions-manual.nix` diff --git a/pkgs/by-name/az/azure-cli/extensions-generated.nix b/pkgs/by-name/az/azure-cli/extensions-generated.nix index eea00148bc8f..ef2523ba9ccd 100644 --- a/pkgs/by-name/az/azure-cli/extensions-generated.nix +++ b/pkgs/by-name/az/azure-cli/extensions-generated.nix @@ -1,9 +1,4 @@ -# This file packages Azure CLI extensions that don't have any requirements. -# Extensions with requirements should be placed in another file, so this one -# can be re-generated during update. -# -# Attributes were generated using the query-extension-index.sh script: -# ./query-extension-index.sh --requirements=false --download --nix --cli-version= +# This file is automatically generated. DO NOT EDIT! Read README.md { mkAzExtension }: { account = mkAzExtension rec { diff --git a/pkgs/by-name/az/azure-cli/package.nix b/pkgs/by-name/az/azure-cli/package.nix index 7f038c63c8c5..ab2d5d4d0f51 100644 --- a/pkgs/by-name/az/azure-cli/package.nix +++ b/pkgs/by-name/az/azure-cli/package.nix @@ -8,6 +8,7 @@ runCommand, installShellFiles, python311, + writeScriptBin, # Whether to include patches that enable placing certain behavior-defining # configuration files in the Nix store. @@ -375,6 +376,19 @@ py.pkgs.toPythonApplication ( touch $out ''; }; + + generate-extensions = writeScriptBin "${pname}-update-extensions" '' + export FILE=extensions-generated.nix + echo "# This file is automatically generated. DO NOT EDIT! Read README.md" > $FILE + echo "{ mkAzExtension }:" >> $FILE + echo "{" >> $FILE + ${./query-extension-index.sh} --requirements=false --download --nix --cli-version=${version} \ + | xargs -n1 -d '\n' echo " " >> $FILE + echo "" >> $FILE + echo "}" >> $FILE + echo "Extension was saved to \"extensions-generated.nix\" file." + echo "Move it to \"{nixpkgs}/pkgs/by-name/az/azure-cli/extensions-generated.nix\"." + ''; }; meta = {