2023-10-09 19:29:22 +00:00
|
|
|
{ lib
|
2023-11-16 04:20:00 +00:00
|
|
|
, callPackage
|
2024-04-21 15:54:59 +00:00
|
|
|
, callPackages
|
|
|
|
, stdenvNoCC
|
|
|
|
, fetchurl
|
2023-10-09 19:29:22 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
2024-04-21 15:54:59 +00:00
|
|
|
, python3
|
|
|
|
|
|
|
|
# Whether to include patches that enable placing certain behavior-defining
|
|
|
|
# configuration files in the Nix store.
|
|
|
|
, withImmutableConfig ? true
|
|
|
|
|
|
|
|
# List of extensions/plugins to include.
|
|
|
|
, withExtensions ? [ ]
|
|
|
|
|
|
|
|
, azure-cli
|
2023-10-09 19:29:22 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "2.61.0";
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-08-22 20:05:09 +00:00
|
|
|
name = "azure-cli-${version}-src";
|
2020-04-24 23:36:52 +00:00
|
|
|
owner = "Azure";
|
|
|
|
repo = "azure-cli";
|
|
|
|
rev = "azure-cli-${version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
hash = "sha256-RmCZigDenbX8OoIZeY087ga2AP8yRckyG0qZnN9gg44=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
# put packages that needs to be overridden in the py package scope
|
2023-11-16 04:20:00 +00:00
|
|
|
py = callPackage ./python-packages.nix { inherit src version; };
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# Builder for Azure CLI extensions. Extensions are Python wheels that
|
|
|
|
# outside of nix would be fetched by the CLI itself from various sources.
|
|
|
|
mkAzExtension =
|
|
|
|
{ pname
|
|
|
|
, version
|
|
|
|
, url
|
|
|
|
, sha256
|
|
|
|
, description
|
2024-05-15 15:35:15 +00:00
|
|
|
, ...
|
|
|
|
}@args: python3.pkgs.buildPythonPackage ({
|
2024-04-21 15:54:59 +00:00
|
|
|
format = "wheel";
|
|
|
|
src = fetchurl { inherit url sha256; };
|
2024-06-20 14:57:18 +00:00
|
|
|
meta = {
|
2024-04-21 15:54:59 +00:00
|
|
|
inherit description;
|
|
|
|
inherit (azure-cli.meta) platforms maintainers;
|
|
|
|
homepage = "https://github.com/Azure/azure-cli-extensions";
|
|
|
|
changelog = "https://github.com/Azure/azure-cli-extensions/blob/main/src/${pname}/HISTORY.rst";
|
|
|
|
license = lib.licenses.mit;
|
2024-06-20 14:57:18 +00:00
|
|
|
sourceProvenance = [ lib.sourceTypes.fromSource ];
|
|
|
|
} // args.meta or { };
|
|
|
|
} // (removeAttrs args [ "url" "sha256" "description" "meta" ]));
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
extensions =
|
|
|
|
callPackages ./extensions-generated.nix { inherit mkAzExtension; }
|
|
|
|
// callPackages ./extensions-manual.nix { inherit mkAzExtension; };
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
extensionDir = stdenvNoCC.mkDerivation {
|
|
|
|
name = "azure-cli-extensions";
|
|
|
|
dontUnpack = true;
|
|
|
|
installPhase =
|
|
|
|
let
|
|
|
|
namePaths = map (p: "${p.pname},${p}/${python3.sitePackages}") withExtensions;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
for line in ${lib.concatStringsSep " " namePaths}; do
|
|
|
|
name=$(echo $line | cut -d',' -f1)
|
|
|
|
path=$(echo $line | cut -d',' -f2)
|
|
|
|
mkdir -p $out/$name
|
|
|
|
for f in $(ls $path); do
|
|
|
|
ln -s $path/$f $out/$name/$f
|
|
|
|
done
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
2023-08-22 20:05:09 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
py.pkgs.toPythonApplication (py.pkgs.buildAzureCliPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "azure-cli";
|
|
|
|
inherit version src;
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
sourceRoot = "${src.name}/src/azure-cli";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = with py.pkgs; [
|
2023-11-16 04:20:00 +00:00
|
|
|
antlr4-python3-runtime
|
|
|
|
applicationinsights
|
|
|
|
argcomplete
|
|
|
|
asn1crypto
|
2020-10-07 09:15:18 +00:00
|
|
|
azure-appconfiguration
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-batch
|
|
|
|
azure-cli-core
|
|
|
|
azure-cli-telemetry
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-common
|
|
|
|
azure-core
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-cosmos
|
2022-06-26 10:26:21 +00:00
|
|
|
azure-data-tables
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-datalake-store
|
|
|
|
azure-graphrbac
|
2020-10-07 09:15:18 +00:00
|
|
|
azure-keyvault-administration
|
2023-07-15 17:15:38 +00:00
|
|
|
azure-keyvault-certificates
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-keyvault-keys
|
2023-07-15 17:15:38 +00:00
|
|
|
azure-keyvault-secrets
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-loganalytics
|
|
|
|
azure-mgmt-advisor
|
|
|
|
azure-mgmt-apimanagement
|
|
|
|
azure-mgmt-appconfiguration
|
2023-07-15 17:15:38 +00:00
|
|
|
azure-mgmt-appcontainers
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-mgmt-applicationinsights
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-authorization
|
|
|
|
azure-mgmt-batch
|
|
|
|
azure-mgmt-batchai
|
|
|
|
azure-mgmt-billing
|
|
|
|
azure-mgmt-botservice
|
|
|
|
azure-mgmt-cdn
|
|
|
|
azure-mgmt-cognitiveservices
|
|
|
|
azure-mgmt-compute
|
|
|
|
azure-mgmt-consumption
|
|
|
|
azure-mgmt-containerinstance
|
|
|
|
azure-mgmt-containerregistry
|
|
|
|
azure-mgmt-containerservice
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-mgmt-core
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-cosmosdb
|
2021-01-05 17:05:55 +00:00
|
|
|
azure-mgmt-databoxedge
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-mgmt-datalake-nspkg
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-datalake-store
|
|
|
|
azure-mgmt-datamigration
|
|
|
|
azure-mgmt-devtestlabs
|
|
|
|
azure-mgmt-dns
|
|
|
|
azure-mgmt-eventgrid
|
|
|
|
azure-mgmt-eventhub
|
2021-07-14 22:03:04 +00:00
|
|
|
azure-mgmt-extendedlocation
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-hdinsight
|
|
|
|
azure-mgmt-imagebuilder
|
|
|
|
azure-mgmt-iotcentral
|
|
|
|
azure-mgmt-iothub
|
|
|
|
azure-mgmt-iothubprovisioningservices
|
|
|
|
azure-mgmt-keyvault
|
|
|
|
azure-mgmt-kusto
|
|
|
|
azure-mgmt-loganalytics
|
|
|
|
azure-mgmt-managementgroups
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-mgmt-managedservices
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-maps
|
|
|
|
azure-mgmt-marketplaceordering
|
|
|
|
azure-mgmt-media
|
|
|
|
azure-mgmt-monitor
|
|
|
|
azure-mgmt-msi
|
|
|
|
azure-mgmt-netapp
|
|
|
|
azure-mgmt-policyinsights
|
|
|
|
azure-mgmt-privatedns
|
|
|
|
azure-mgmt-rdbms
|
|
|
|
azure-mgmt-recoveryservices
|
|
|
|
azure-mgmt-recoveryservicesbackup
|
2020-05-03 17:38:23 +00:00
|
|
|
azure-mgmt-redhatopenshift
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-redis
|
|
|
|
azure-mgmt-relay
|
|
|
|
azure-mgmt-resource
|
|
|
|
azure-mgmt-search
|
|
|
|
azure-mgmt-security
|
|
|
|
azure-mgmt-servicebus
|
|
|
|
azure-mgmt-servicefabric
|
2021-05-20 23:08:51 +00:00
|
|
|
azure-mgmt-servicefabricmanagedclusters
|
2021-12-06 16:07:01 +00:00
|
|
|
azure-mgmt-servicelinker
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-sql
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-mgmt-signalr
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-sqlvirtualmachine
|
|
|
|
azure-mgmt-storage
|
2020-09-25 04:45:31 +00:00
|
|
|
azure-mgmt-synapse
|
2020-04-24 23:36:52 +00:00
|
|
|
azure-mgmt-trafficmanager
|
|
|
|
azure-mgmt-web
|
|
|
|
azure-multiapi-storage
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-nspkg
|
2023-10-09 19:29:22 +00:00
|
|
|
azure-storage-common
|
2023-11-16 04:20:00 +00:00
|
|
|
azure-storage-blob
|
2020-09-25 04:45:31 +00:00
|
|
|
azure-synapse-accesscontrol
|
2020-11-06 00:33:48 +00:00
|
|
|
azure-synapse-artifacts
|
2021-09-18 10:52:07 +00:00
|
|
|
azure-synapse-managedprivateendpoints
|
2020-09-25 04:45:31 +00:00
|
|
|
azure-synapse-spark
|
2023-11-16 04:20:00 +00:00
|
|
|
bcrypt
|
|
|
|
certifi
|
|
|
|
cffi
|
2022-06-26 10:26:21 +00:00
|
|
|
chardet
|
2020-04-24 23:36:52 +00:00
|
|
|
colorama
|
|
|
|
cryptography
|
2021-09-18 10:52:07 +00:00
|
|
|
distro
|
2023-03-15 16:39:30 +00:00
|
|
|
fabric
|
2023-11-16 04:20:00 +00:00
|
|
|
humanfriendly
|
|
|
|
idna
|
|
|
|
invoke
|
|
|
|
isodate
|
|
|
|
javaproperties
|
|
|
|
jinja2
|
|
|
|
jmespath
|
|
|
|
jsondiff
|
2020-04-24 23:36:52 +00:00
|
|
|
knack
|
2023-11-16 04:20:00 +00:00
|
|
|
markupsafe
|
|
|
|
msal-extensions
|
|
|
|
msal
|
|
|
|
msrest
|
|
|
|
msrestazure
|
|
|
|
oauthlib
|
|
|
|
packaging
|
2020-04-24 23:36:52 +00:00
|
|
|
paramiko
|
2023-11-16 04:20:00 +00:00
|
|
|
pbr
|
|
|
|
pkginfo
|
|
|
|
portalocker
|
|
|
|
psutil
|
|
|
|
pycomposefile
|
|
|
|
pycparser
|
2023-03-15 16:39:30 +00:00
|
|
|
pygithub
|
2023-11-16 04:20:00 +00:00
|
|
|
pyjwt
|
2022-02-10 20:34:41 +00:00
|
|
|
pynacl
|
2020-04-24 23:36:52 +00:00
|
|
|
pyopenssl
|
2023-11-16 04:20:00 +00:00
|
|
|
python-dateutil
|
|
|
|
requests-oauthlib
|
2020-04-24 23:36:52 +00:00
|
|
|
requests
|
|
|
|
scp
|
2021-03-15 08:37:03 +00:00
|
|
|
semver
|
2024-04-21 15:54:59 +00:00
|
|
|
setuptools
|
2020-04-24 23:36:52 +00:00
|
|
|
six
|
|
|
|
sshtunnel
|
2023-11-16 04:20:00 +00:00
|
|
|
tabulate
|
2020-04-24 23:36:52 +00:00
|
|
|
urllib3
|
2023-11-16 04:20:00 +00:00
|
|
|
wcwidth
|
2021-06-28 23:13:55 +00:00
|
|
|
websocket-client
|
2020-04-24 23:36:52 +00:00
|
|
|
xmltodict
|
2024-05-15 15:35:15 +00:00
|
|
|
] ++ lib.optionals (!withImmutableConfig) [
|
|
|
|
# pip is required to install extensions locally, but it's not needed if
|
|
|
|
# we're using the default immutable configuration.
|
|
|
|
pip
|
2024-06-20 14:57:18 +00:00
|
|
|
] ++ lib.concatMap (extension: extension.propagatedBuildInputs) withExtensions;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
2021-05-03 20:48:10 +00:00
|
|
|
substituteInPlace az.completion.sh \
|
|
|
|
--replace register-python-argcomplete ${py.pkgs.argcomplete}/bin/register-python-argcomplete
|
2020-04-24 23:36:52 +00:00
|
|
|
installShellCompletion --bash --name az.bash az.completion.sh
|
|
|
|
installShellCompletion --zsh --name _az az.completion.sh
|
2024-04-21 15:54:59 +00:00
|
|
|
'' + lib.optionalString withImmutableConfig ''
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
$out/bin/az --version
|
|
|
|
mkdir -p $out/etc/azure
|
|
|
|
mv $TMPDIR/.azure/commandIndex.json $out/etc/azure/commandIndex.json
|
|
|
|
mv $TMPDIR/.azure/versionCheck.json $out/etc/azure/versionCheck.json
|
|
|
|
'' + ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# remove garbage
|
|
|
|
rm $out/bin/az.bat
|
|
|
|
rm $out/bin/az.completion.sh
|
|
|
|
'';
|
|
|
|
|
|
|
|
# wrap the executable so that the python packages are available
|
|
|
|
# it's just a shebang script which calls `python -m azure.cli "$@"`
|
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/bin/az \
|
2024-04-21 15:54:59 +00:00
|
|
|
'' + lib.optionalString withImmutableConfig ''
|
|
|
|
--set AZURE_IMMUTABLE_DIR $out/etc/azure \
|
|
|
|
'' + lib.optionalString (withExtensions != [ ]) ''
|
|
|
|
--set AZURE_EXTENSION_DIR ${extensionDir} \
|
|
|
|
'' + ''
|
|
|
|
--set PYTHONPATH "${python3.pkgs.makePythonPath propagatedBuildInputs}:$out/${python3.sitePackages}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
|
|
|
|
$out/bin/az --version
|
|
|
|
$out/bin/az self-test
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# ensure these namespaces are able to be accessed
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"azure.batch"
|
|
|
|
"azure.cli.core"
|
|
|
|
"azure.cli.telemetry"
|
|
|
|
"azure.cosmos"
|
|
|
|
"azure.datalake.store"
|
|
|
|
"azure.graphrbac"
|
|
|
|
"azure.keyvault"
|
|
|
|
"azure.loganalytics"
|
|
|
|
"azure.mgmt.advisor"
|
|
|
|
"azure.mgmt.apimanagement"
|
|
|
|
"azure.mgmt.applicationinsights"
|
|
|
|
"azure.mgmt.appconfiguration"
|
2023-07-15 17:15:38 +00:00
|
|
|
"azure.mgmt.appcontainers"
|
2020-04-24 23:36:52 +00:00
|
|
|
"azure.mgmt.authorization"
|
|
|
|
"azure.mgmt.batch"
|
|
|
|
"azure.mgmt.batchai"
|
|
|
|
"azure.mgmt.billing"
|
|
|
|
"azure.mgmt.botservice"
|
|
|
|
"azure.mgmt.cdn"
|
|
|
|
"azure.mgmt.cognitiveservices"
|
|
|
|
"azure.mgmt.compute"
|
|
|
|
"azure.mgmt.consumption"
|
|
|
|
"azure.mgmt.containerinstance"
|
|
|
|
"azure.mgmt.containerregistry"
|
|
|
|
"azure.mgmt.containerservice"
|
|
|
|
"azure.mgmt.cosmosdb"
|
|
|
|
"azure.mgmt.datalake.store"
|
|
|
|
"azure.mgmt.datamigration"
|
|
|
|
"azure.mgmt.devtestlabs"
|
|
|
|
"azure.mgmt.dns"
|
|
|
|
"azure.mgmt.eventgrid"
|
|
|
|
"azure.mgmt.eventhub"
|
|
|
|
"azure.mgmt.hdinsight"
|
|
|
|
"azure.mgmt.imagebuilder"
|
|
|
|
"azure.mgmt.iotcentral"
|
|
|
|
"azure.mgmt.iothub"
|
|
|
|
"azure.mgmt.iothubprovisioningservices"
|
|
|
|
"azure.mgmt.keyvault"
|
|
|
|
"azure.mgmt.kusto"
|
|
|
|
"azure.mgmt.loganalytics"
|
|
|
|
"azure.mgmt.managedservices"
|
|
|
|
"azure.mgmt.managementgroups"
|
|
|
|
"azure.mgmt.maps"
|
|
|
|
"azure.mgmt.marketplaceordering"
|
|
|
|
"azure.mgmt.media"
|
|
|
|
"azure.mgmt.monitor"
|
|
|
|
"azure.mgmt.msi"
|
|
|
|
"azure.mgmt.netapp"
|
|
|
|
"azure.mgmt.policyinsights"
|
|
|
|
"azure.mgmt.privatedns"
|
|
|
|
"azure.mgmt.rdbms"
|
|
|
|
"azure.mgmt.recoveryservices"
|
|
|
|
"azure.mgmt.recoveryservicesbackup"
|
|
|
|
"azure.mgmt.redis"
|
|
|
|
"azure.mgmt.relay"
|
|
|
|
"azure.mgmt.resource"
|
|
|
|
"azure.mgmt.search"
|
|
|
|
"azure.mgmt.security"
|
|
|
|
"azure.mgmt.servicebus"
|
|
|
|
"azure.mgmt.servicefabric"
|
|
|
|
"azure.mgmt.signalr"
|
|
|
|
"azure.mgmt.sql"
|
|
|
|
"azure.mgmt.sqlvirtualmachine"
|
|
|
|
"azure.mgmt.storage"
|
|
|
|
"azure.mgmt.trafficmanager"
|
|
|
|
"azure.mgmt.web"
|
|
|
|
"azure.storage.blob"
|
|
|
|
"azure.storage.common"
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
passthru = {
|
|
|
|
inherit extensions;
|
|
|
|
withExtensions = extensions: azure-cli.override { withExtensions = extensions; };
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/Azure/azure-cli";
|
|
|
|
description = "Next generation multi-platform command line experience for Azure";
|
2023-08-22 20:05:09 +00:00
|
|
|
downloadPage = "https://github.com/Azure/azure-cli/releases/tag/azure-cli-${version}";
|
|
|
|
longDescription = ''
|
|
|
|
The Azure Command-Line Interface (CLI) is a cross-platform
|
|
|
|
command-line tool to connect to Azure and execute administrative
|
|
|
|
commands on Azure resources. It allows the execution of commands
|
|
|
|
through a terminal using interactive command-line prompts or a script.
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
`azure-cli` has extension support. For example, to install the `aks-preview` extension, use
|
|
|
|
|
|
|
|
```nix
|
|
|
|
environment.systemPackages = [
|
|
|
|
(azure-cli.withExtensions [ azure-cli.extensions.aks-preview ])
|
|
|
|
];
|
|
|
|
```
|
|
|
|
|
|
|
|
To make the `azure-cli` immutable and prevent clashes in case `azure-cli` is also installed via other package managers,
|
|
|
|
some configuration files were moved into the derivation. This can be disabled by overriding `withImmutableConfig = false`
|
|
|
|
when building `azure-cli`.
|
2023-08-22 20:05:09 +00:00
|
|
|
'';
|
|
|
|
changelog = "https://github.com/MicrosoftDocs/azure-docs-cli/blob/main/docs-ref-conceptual/release-notes-azure-cli.md";
|
|
|
|
sourceProvenance = [ sourceTypes.fromSource ];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2023-08-22 20:05:09 +00:00
|
|
|
mainProgram = "az";
|
2024-02-29 20:09:43 +00:00
|
|
|
maintainers = with maintainers; [ jonringer ];
|
2023-08-22 20:05:09 +00:00
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
})
|