How can we use the azure-cli-extensions packages?

Hi,

I’m trying to use the azure-cli-extensions.account package (in nixpkgs-unstable), but the base azure-cli package does not seem to be aware of it.

> az # just to show we're using an azure-cli installed outside of nix
zsh: command not found: az

> nix-shell -p pkgs.azure-cli-extensions.account pkgs.azure-cli

[nix-shell:~]$ az account tenant list
The command requires the extension account. Do you want to install it now? The command will continue to run after the extension is installed. (Y/n):
Run 'az config set extension.use_dynamic_install=yes_without_prompt' to allow installing extensions without prompt.
Default enabled including preview versions for extension installation now. Disabled in May 2024. Use '--allow-preview true' to enable it specifically if needed. Use '--allow-preview false' to install stable version only.
An error occurred. Pip failed with status code 1. Use --debug for more information.

Is there anything that needs to be done to make use of the extension?

Thanks!

I received help wit this elsewhere, sharing the solution here in case anyone else encounters this. Apparently there’s a .withExtensions attribute. This code will pull in all of the azure-cli-extentions packages:

{
  lib,
  pkgs,
  ...
}: let
  inherit (lib) mkIf isDerivation;
  inherit (builtins) filter attrValues;
  azure-cli = pkgs.azure-cli.withExtensions (filter (item: isDerivation item) (attrValues pkgs.azure-cli-extensions));
in {
  home.packages = [azure-cli];
}

I also had to add the nixpkgs-unstable channel as my main nixpkgs channel for this to work.

nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs