nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, buildPythonPackage
3, fetchPypi
4, setuptools-scm
5, ansible-compat
6, ansible-core
7, enrich
8, flaky
9, pyyaml
10, rich
11, ruamel-yaml
12, wcmatch
13, yamllint
14, pythonOlder
15, pytest-xdist
16, pytestCheckHook
17}:
18
19buildPythonPackage rec {
20 pname = "ansible-lint";
21 version = "6.0.2";
22 format = "pyproject";
23 disabled = pythonOlder "3.6";
24
25 src = fetchPypi {
26 inherit pname version;
27 sha256 = "sha256-tTm8ItE+beDMLiV1jh0osrwBVhpBSuN87aNwi1oqee0=";
28 };
29
30 postPatch = ''
31 # it is fine if lint tools are missing
32 substituteInPlace conftest.py \
33 --replace "sys.exit(1)" ""
34 '';
35
36 nativeBuildInputs = [
37 setuptools-scm
38 ];
39
40 propagatedBuildInputs = [
41 ansible-compat
42 ansible-core
43 enrich
44 pyyaml
45 rich
46 ruamel-yaml
47 wcmatch
48 yamllint
49 ];
50
51 # tests can't be easily run without installing things from ansible-galaxy
52 doCheck = false;
53
54 checkInputs = [
55 flaky
56 pytest-xdist
57 pytestCheckHook
58 ];
59
60 preCheck = ''
61 # ansible wants to write to $HOME and crashes if it can't
62 export HOME=$(mktemp -d)
63 export PATH=$PATH:${lib.makeBinPath [ ansible-core ]}
64
65 # create a working ansible-lint executable
66 export PATH=$PATH:$PWD/src/ansiblelint
67 ln -rs src/ansiblelint/__main__.py src/ansiblelint/ansible-lint
68 patchShebangs src/ansiblelint/__main__.py
69
70 # create symlink like in the git repo so test_included_tasks does not fail
71 ln -s ../roles examples/playbooks/roles
72 '';
73
74 disabledTests = [
75 # requires network
76 "test_cli_auto_detect"
77 "test_install_collection"
78 "test_prerun_reqs_v1"
79 "test_prerun_reqs_v2"
80 "test_require_collection_wrong_version"
81 # re-execs ansible-lint which does not works correct
82 "test_custom_kinds"
83 "test_run_inside_role_dir"
84 "test_run_multiple_role_path_no_trailing_slash"
85 "test_runner_exclude_globs"
86
87 "test_discover_lintables_umlaut"
88 ];
89
90 makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible-core ]}" ];
91
92 meta = with lib; {
93 homepage = "https://github.com/ansible-community/ansible-lint";
94 description = "Best practices checker for Ansible";
95 license = licenses.mit;
96 maintainers = with maintainers; [ sengaya SuperSandro2000 ];
97 };
98}