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