1{ lib
2, python3
3, fetchPypi
4, groff
5, less
6, nix-update-script
7, testers
8, awscli
9}:
10
11let
12 botocoreVersion = python3.pkgs.botocore.version;
13 # awscli.version should be pinned to 2 minor versions less than the botocoreVersion
14 versionMinor = toString (lib.toInt (lib.versions.minor botocoreVersion) - 2);
15 versionPatch = lib.versions.patch botocoreVersion;
16 self = python3.pkgs.buildPythonApplication rec {
17 pname = "awscli";
18 version = "1.${versionMinor}.${versionPatch}"; # N.B: if you change this, change botocore and boto3 to a matching version too
19 pyproject = true;
20
21 src = fetchPypi {
22 inherit pname version;
23 hash = "sha256-GPcXkl2H0XNaeqt2/qD5+KvW23dRB0X+zLWo9hLigQM=";
24 };
25
26 nativeBuildInputs = [
27 python3.pkgs.pythonRelaxDepsHook
28 ];
29
30 pythonRelaxDeps = [
31 # botocore must not be relaxed
32 "colorama"
33 "docutils"
34 "rsa"
35 ];
36
37 build-system = [
38 python3.pkgs.setuptools
39 ];
40
41 propagatedBuildInputs = with python3.pkgs; [
42 botocore
43 s3transfer
44 colorama
45 docutils
46 rsa
47 pyyaml
48 groff
49 less
50 ];
51
52 postInstall = ''
53 mkdir -p $out/share/bash-completion/completions
54 echo "complete -C $out/bin/aws_completer aws" > $out/share/bash-completion/completions/awscli
55
56 mkdir -p $out/share/zsh/site-functions
57 mv $out/bin/aws_zsh_completer.sh $out/share/zsh/site-functions
58
59 rm $out/bin/aws.cmd
60 '';
61
62 doInstallCheck = true;
63
64 installCheckPhase = ''
65 runHook preInstallCheck
66
67 $out/bin/aws --version | grep "${botocoreVersion}"
68 $out/bin/aws --version | grep "${version}"
69
70 runHook postInstallCheck
71 '';
72
73 passthru = {
74 python = python3; # for aws_shell
75 updateScript = nix-update-script {
76 extraArgs = [ "--version=skip" ];
77 };
78 tests.version = testers.testVersion {
79 package = awscli;
80 command = "aws --version";
81 inherit version;
82 };
83 };
84
85 meta = with lib; {
86 homepage = "https://aws.amazon.com/cli/";
87 changelog = "https://github.com/aws/aws-cli/blob/${version}/CHANGELOG.rst";
88 description = "Unified tool to manage your AWS services";
89 license = licenses.asl20;
90 mainProgram = "aws";
91 maintainers = with maintainers; [ anthonyroussel ];
92 };
93 };
94in
95assert self ? pythonRelaxDeps -> !(lib.elem "botocore" self.pythonRelaxDeps);
96self