5 - Update `version` and `src.hash` in package.nix
6 - Check out the changes made to the azure-cli [setup.py](https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/setup.py) since the last release
7 - Try build the CLI, will likely fail with `ModuleNotFoundError`, for example
9 ModuleNotFoundError: No module named 'azure.mgmt.storage.v2023_05_01'
11 Sometimes it will also fail with other import errors.
12 - Check the referenced module (`azure-mgmt-storage`) in the setup.py
13 - Find the actual version required, for example
15 'azure-mgmt-storage==21.2.0',
17 - Update version and hash of this dependency in python-packages.nix
18 - Repeat until it builds
22 There are two sets of extensions:
24 - `extensions-generated.nix` are extensions with no external requirements, which can be regenerated running:
25 > nix run .#azure-cli.passthru.generate-extensions
27 - `extensions-manual.nix` are extensions with requirements, which need to be manually packaged and maintained.
29 ### Adding an extension to `extensions-manual.nix`
31 To manually add a missing extension, first query its metadata from the extension index.
32 Use the following command, use the current version of azure-cli in nixpkgs as `cli-version`
33 and the name of the extension you want to package as `extension`:
36 ./query-extension-index.sh --cli-version=2.61.0 --extension=azure-devops --download
39 The output should look something like this:
43 "pname": "azure-devops",
44 "description": "Tools for managing Azure DevOps.",
46 "url": "https://github.com/Azure/azure-devops-cli-extension/releases/download/20240514.1/azure_devops-1.0.1-py2.py3-none-any.whl",
47 "sha256": "f300d0288f017148514ebe6f5912aef10c7a6f29bdc0c916b922edf1d75bc7db",
56 Based on this, you can add an attribute to `extensions-manual.nix`:
59 azure-devops = mkAzExtension rec {
60 pname = "azure-devops";
62 url = "https://github.com/Azure/azure-devops-cli-extension/releases/download/20240206.1/azure_devops-${version}-py2.py3-none-any.whl";
63 sha256 = "658a2854d8c80f874f9382d421fa45abf6a38d00334737dda006f8dec64cf70a";
64 description = "Tools for managing Azure DevOps";
65 propagatedBuildInputs = with python3Packages; [
68 meta.maintainers = with lib.maintainers; [ katexochen ];
72 * The attribute name should be the same as `pname`.
73 * Replace the version in `url` with `${version}`.
74 * The json output `requires` must be transformed into `propagetedBuildInputs`.
75 * If `license` is `"MIT"`, it can be left out in the nix expression, as the builder defaults to that license.
76 * Add yourself as maintainer in `meta.maintainers`.
78 ### Testing extensions
80 You can build azure-cli with an extension on the command line by running the following command at the root of this repository:
83 nix build --impure --expr 'with (import ./. {}); azure-cli.withExtensions [ azure-cli.extensions.azure-devops ]'
86 Check if the desired functionality was added.
88 You can check if the extensions was recognized by running:
91 ./result/bin/az extension list
94 The output should show the extension like this:
99 "experimental": false,
100 "extensionType": "whl",
101 "name": "azure-devops",
102 "path": "/nix/store/azbgnpg5nh5rb8wfvp0r9bmcx83mqrj5-azure-cli-extensions/azure-devops",
109 ### Removing an extension
111 If extensions are removed upstream, an alias is added to the end of `extensions-manual.nix`
112 (see `# Removed extensions`). This alias should throw an error and be of similar structure as
116 blockchain = throw "The 'blockchain' extension for azure-cli was deprecated upstream"; # Added 2024-04-26