1{ lib
2, python3
3, groff
4, less
5, fetchFromGitHub
6, nix-update-script
7, testers
8, awscli2
9}:
10
11let
12 py = python3 // {
13 pkgs = python3.pkgs.overrideScope (final: prev: {
14 ruamel-yaml = prev.ruamel-yaml.overridePythonAttrs (prev: {
15 src = prev.src.override {
16 version = "0.17.21";
17 hash = "sha256-i3zml6LyEnUqNcGsQURx3BbEJMlXO+SSa1b/P10jt68=";
18 };
19 });
20 });
21 };
22
23in
24with py.pkgs; buildPythonApplication rec {
25 pname = "awscli2";
26 version = "2.13.18"; # N.B: if you change this, check if overrides are still up-to-date
27 format = "pyproject";
28
29 src = fetchFromGitHub {
30 owner = "aws";
31 repo = "aws-cli";
32 rev = "refs/tags/${version}";
33 hash = "sha256-0YCJZgu8GZgHBzlfGmOo+qF/ux99N1SQ0HDpN14z+CA=";
34 };
35
36 postPatch = ''
37 substituteInPlace pyproject.toml \
38 --replace 'cryptography>=3.3.2,<40.0.2' 'cryptography>=3.3.2' \
39 --replace 'flit_core>=3.7.1,<3.8.1' 'flit_core>=3.7.1' \
40 --replace 'awscrt>=0.16.4,<=0.16.16' 'awscrt>=0.16.4'
41
42 substituteInPlace requirements-base.txt \
43 --replace "wheel==0.38.4" "wheel>=0.38.4" \
44 --replace "flit_core==3.8.0" "flit_core>=3.8.0"
45
46 # Upstream needs pip to build and install dependencies and validates this
47 # with a configure script, but we don't as we provide all of the packages
48 # through PYTHONPATH
49 sed -i '/pip>=/d' requirements/bootstrap.txt
50 '';
51
52 nativeBuildInputs = [
53 flit-core
54 ];
55
56 propagatedBuildInputs = [
57 awscrt
58 bcdoc
59 botocore
60 colorama
61 cryptography
62 distro
63 docutils
64 groff
65 jmespath
66 less
67 prompt-toolkit
68 python-dateutil
69 pyyaml
70 ruamel-yaml
71 urllib3
72 ];
73
74 nativeCheckInputs = [
75 jsonschema
76 mock
77 pytestCheckHook
78 ];
79
80 postInstall = ''
81 mkdir -p $out/${python3.sitePackages}/awscli/data
82 ${python3.interpreter} scripts/gen-ac-index --index-location $out/${python3.sitePackages}/awscli/data/ac.index
83
84 mkdir -p $out/share/bash-completion/completions
85 echo "complete -C $out/bin/aws_completer aws" > $out/share/bash-completion/completions/aws
86
87 mkdir -p $out/share/zsh/site-functions
88 mv $out/bin/aws_zsh_completer.sh $out/share/zsh/site-functions
89
90 rm $out/bin/aws.cmd
91 '';
92
93 preCheck = ''
94 export PATH=$PATH:$out/bin
95 export HOME=$(mktemp -d)
96 '';
97
98 pytestFlagsArray = [
99 "-Wignore::DeprecationWarning"
100 ];
101
102 disabledTestPaths = [
103 # Integration tests require networking
104 "tests/integration"
105
106 # Disable slow tests (only run unit tests)
107 "tests/backends"
108 "tests/functional"
109 ];
110
111 pythonImportsCheck = [
112 "awscli"
113 ];
114
115 passthru = {
116 python = py; # for aws_shell
117 updateScript = nix-update-script {
118 # Excludes 1.x versions from the Github tags list
119 extraArgs = [ "--version-regex" "^(2\.(.*))" ];
120 };
121 tests.version = testers.testVersion {
122 package = awscli2;
123 command = "aws --version";
124 inherit version;
125 };
126 };
127
128 meta = with lib; {
129 description = "Unified tool to manage your AWS services";
130 homepage = "https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html";
131 changelog = "https://github.com/aws/aws-cli/blob/${version}/CHANGELOG.rst";
132 license = licenses.asl20;
133 maintainers = with maintainers; [ bhipple davegallant bryanasdev000 devusb anthonyroussel ];
134 mainProgram = "aws";
135 };
136}