1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # dependencies
7 cmake,
8 python-dateutil,
9 dbus-python,
10 dnf4,
11 gettext,
12 libcomps,
13 libdnf,
14 python,
15 rpm,
16 sphinx,
17 systemd,
18}:
19
20let
21 pyMajor = lib.versions.major python.version;
22in
23
24buildPythonPackage rec {
25 pname = "dnf-plugins-core";
26 version = "4.10.1";
27 format = "other";
28
29 outputs = [
30 "out"
31 "man"
32 ];
33
34 src = fetchFromGitHub {
35 owner = "rpm-software-management";
36 repo = "dnf-plugins-core";
37 tag = version;
38 hash = "sha256-nZyM61bQ9L4t3/fa9cP+xo9ke00e6w2Obt80OpqOG8A=";
39 };
40
41 postPatch = ''
42 substituteInPlace CMakeLists.txt \
43 --replace-fail "SYSCONFDIR /etc" "SYSCONFDIR $out/etc" \
44 --replace-fail "SYSTEMD_DIR /usr/lib/systemd/system" "SYSTEMD_DIR $out/lib/systemd/system"
45 substituteInPlace doc/CMakeLists.txt \
46 --replace-fail 'SPHINX_BUILD_NAME "sphinx-build-3"' 'SPHINX_BUILD_NAME "${sphinx}/bin/sphinx-build"'
47 '';
48
49 nativeBuildInputs = [
50 cmake
51 gettext
52 sphinx
53 ];
54
55 propagatedBuildInputs = [
56 python-dateutil
57 dbus-python
58 dnf4.py
59 libcomps
60 libdnf
61 rpm
62 systemd
63 ];
64
65 cmakeFlags = [
66 "-DPYTHON_DESIRED=${pyMajor}"
67 "-DWITHOUT_LOCAL=0"
68 "-DPYTHON_INSTALL_DIR=${placeholder "out"}/${python.sitePackages}"
69 ];
70
71 postBuild = ''
72 make doc-man
73 '';
74
75 pythonImportsCheck = [
76 # This is the python module imported by dnf4 when plugins are loaded.
77 "dnfpluginscore"
78 ];
79
80 # Don't use symbolic links so argv[0] is set to the correct value.
81 postInstall = ''
82 # See https://github.com/rpm-software-management/dnf-plugins-core/blob/aee9cacdeb50768c1e869122cd432924ec533213/dnf-plugins-core.spec#L478
83 mv $out/libexec/dnf-utils-${pyMajor} $out/libexec/dnf-utils
84
85 # See https://github.com/rpm-software-management/dnf-plugins-core/blob/aee9cacdeb50768c1e869122cd432924ec533213/dnf-plugins-core.spec#L487-L503
86 bins=(
87 "debuginfo-install"
88 "needs-restarting"
89 "find-repos-of-install"
90 "repo-graph"
91 "package-cleanup"
92 "repoclosure"
93 "repodiff"
94 "repomanage"
95 "repoquery"
96 "reposync"
97 "repotrack"
98 "yum-builddep"
99 "yum-config-manager"
100 "yum-debug-dump"
101 "yum-debug-restore"
102 "yum-groups-manager"
103 "yumdownloader"
104 )
105 mkdir -p $out/bin
106 for bin in "''${bins[@]}"; do
107 ln $out/libexec/dnf-utils $out/bin/$bin
108 done
109 '';
110
111 makeWrapperArgs = [ ''--add-flags "--setopt=pluginpath=$out/${python.sitePackages}/dnf-plugins"'' ];
112
113 meta = with lib; {
114 description = "Core plugins to use with DNF package manager";
115 homepage = "https://github.com/rpm-software-management/dnf-plugins-core";
116 changelog = "https://github.com/rpm-software-management/dnf-plugins-core/releases/tag/${version}";
117 license = licenses.gpl2Only;
118 maintainers = with maintainers; [ katexochen ];
119 };
120}