1{ lib
2, stdenv
3, python3
4, groff
5, less
6, fetchFromGitHub
7, fetchpatch
8, installShellFiles
9, nix-update-script
10, testers
11, awscli2
12}:
13
14let
15 py = python3 // {
16 pkgs = python3.pkgs.overrideScope (final: prev: {
17 sphinx = prev.sphinx.overridePythonAttrs (prev: {
18 disabledTests = prev.disabledTests ++ [
19 "test_check_link_response_only" # fails on hydra https://hydra.nixos.org/build/242624087/nixlog/1
20 ];
21 });
22 python-dateutil = prev.python-dateutil.overridePythonAttrs (prev: {
23 version = "2.8.2";
24 pyproject = null;
25 src = prev.src.override {
26 version = "2.8.2";
27 hash = "sha256-ASPKzBYnrhnd88J6XeW9Z+5FhvvdZEDZdI+Ku0g9PoY=";
28 };
29 patches = [
30 # https://github.com/dateutil/dateutil/pull/1285
31 (fetchpatch {
32 url = "https://github.com/dateutil/dateutil/commit/f2293200747fb03d56c6c5997bfebeabe703576f.patch";
33 relative = "src";
34 hash = "sha256-BVEFGV/WGUz9H/8q+l62jnyN9VDnoSR71DdL+LIkb0o=";
35 })
36 ];
37 postPatch = null;
38 });
39 ruamel-yaml = prev.ruamel-yaml.overridePythonAttrs (prev: {
40 src = prev.src.override {
41 version = "0.17.21";
42 hash = "sha256-i3zml6LyEnUqNcGsQURx3BbEJMlXO+SSa1b/P10jt68=";
43 };
44 });
45 urllib3 = prev.urllib3.overridePythonAttrs (prev: rec {
46 pyproject = true;
47 version = "1.26.18";
48 nativeBuildInputs = with final; [
49 setuptools
50 ];
51 src = prev.src.override {
52 inherit version;
53 hash = "sha256-+OzBu6VmdBNFfFKauVW/jGe0XbeZ0VkGYmFxnjKFgKA=";
54 };
55 });
56 });
57 };
58
59in
60with py.pkgs; buildPythonApplication rec {
61 pname = "awscli2";
62 version = "2.15.43"; # N.B: if you change this, check if overrides are still up-to-date
63 pyproject = true;
64
65 src = fetchFromGitHub {
66 owner = "aws";
67 repo = "aws-cli";
68 rev = "refs/tags/${version}";
69 hash = "sha256-L+1+4QXDya8wwjexPB0fwx6/nRDPDrMYaaYeRm2SEU8=";
70 };
71
72 postPatch = ''
73 substituteInPlace pyproject.toml \
74 --replace-fail 'awscrt>=0.19.18,<=0.19.19' 'awscrt>=0.19.18' \
75 --replace-fail 'cryptography>=3.3.2,<40.0.2' 'cryptography>=3.3.2' \
76 --replace-fail 'distro>=1.5.0,<1.9.0' 'distro>=1.5.0' \
77 --replace-fail 'docutils>=0.10,<0.20' 'docutils>=0.10' \
78 --replace-fail 'prompt-toolkit>=3.0.24,<3.0.39' 'prompt-toolkit>=3.0.24'
79
80 substituteInPlace requirements-base.txt \
81 --replace-fail "wheel==0.43.0" "wheel>=0.43.0"
82
83 # Upstream needs pip to build and install dependencies and validates this
84 # with a configure script, but we don't as we provide all of the packages
85 # through PYTHONPATH
86 sed -i '/pip>=/d' requirements/bootstrap.txt
87 '';
88
89 build-system = [
90 installShellFiles
91 flit-core
92 ];
93
94 dependencies = [
95 awscrt
96 bcdoc
97 botocore
98 colorama
99 cryptography
100 distro
101 docutils
102 groff
103 jmespath
104 less
105 prompt-toolkit
106 python-dateutil
107 pyyaml
108 ruamel-yaml
109 urllib3
110 ];
111
112 nativeCheckInputs = [
113 jsonschema
114 mock
115 pytestCheckHook
116 ];
117
118 postInstall = ''
119 installShellCompletion --cmd aws \
120 --bash <(echo "complete -C $out/bin/aws_completer aws") \
121 --zsh $out/bin/aws_zsh_completer.sh
122 '' + lib.optionalString (!stdenv.hostPlatform.isWindows) ''
123 rm $out/bin/aws.cmd
124 '';
125
126 preCheck = ''
127 export PATH=$PATH:$out/bin
128 export HOME=$(mktemp -d)
129 '';
130
131 pytestFlagsArray = [
132 "-Wignore::DeprecationWarning"
133 ];
134
135 disabledTestPaths = [
136 "tests/dependencies"
137 "tests/unit/botocore"
138
139 # Integration tests require networking
140 "tests/integration"
141
142 # Disable slow tests (only run unit tests)
143 "tests/backends"
144 "tests/functional"
145 ];
146
147 pythonImportsCheck = [
148 "awscli"
149 ];
150
151 passthru = {
152 python = py; # for aws_shell
153 updateScript = nix-update-script {
154 # Excludes 1.x versions from the Github tags list
155 extraArgs = [ "--version-regex" "^(2\.(.*))" ];
156 };
157 tests.version = testers.testVersion {
158 package = awscli2;
159 command = "aws --version";
160 inherit version;
161 };
162 };
163
164 meta = with lib; {
165 description = "Unified tool to manage your AWS services";
166 homepage = "https://aws.amazon.com/cli/";
167 changelog = "https://github.com/aws/aws-cli/blob/${version}/CHANGELOG.rst";
168 license = licenses.asl20;
169 maintainers = with maintainers; [ bhipple davegallant bryanasdev000 devusb anthonyroussel ];
170 mainProgram = "aws";
171 };
172}