Commit db09ceb5 authored by superherointj's avatar superherointj
Browse files

azure-cli: add generate-extensions routine

At nixpkgs, generate-extensions routine can be executed as:

  nix run .#azure-cli.passthru.generate-extensions
parent 440922e9
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -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`

+1 −6
Original line number Diff line number Diff line
# 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=<version>
# This file is automatically generated. DO NOT EDIT! Read README.md
{ mkAzExtension }:
{
  account = mkAzExtension rec {
+14 −0
Original line number Diff line number Diff line
@@ -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 = {