Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / dnf4 / default.nix
blobc05d003be299ebd755996b1b027e58c4086f38ae
1 { lib
2 , buildPythonPackage
3 , cmake
4 , fetchFromGitHub
5 , gettext
6 , libcomps
7 , libdnf
8 , python
9 , rpm
10 , sphinx
13 let
14   pyMajor = lib.versions.major python.version;
17 buildPythonPackage rec {
18   pname = "dnf4";
19   version = "4.19.2";
20   format = "other";
22   outputs = [ "out" "man" "py" ];
24   src = fetchFromGitHub {
25     owner = "rpm-software-management";
26     repo = "dnf";
27     rev = version;
28     hash = "sha256-2voBauWXPoHWBt58vZfgpO1oWBDDZ+DvWN6jb5qOzFg=";
29   };
31   patches = [
32     ./fix-python-install-dir.patch
33   ];
35   postPatch = ''
36     substituteInPlace CMakeLists.txt \
37       --replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}" \
38       --replace "SYSCONFDIR /etc" "SYSCONFDIR $out/etc" \
39       --replace "SYSTEMD_DIR /usr/lib/systemd/system" "SYSTEMD_DIR $out/lib/systemd/system"
40     substituteInPlace etc/tmpfiles.d/CMakeLists.txt \
41       --replace "DESTINATION /usr/lib/tmpfiles.d" "DESTINATION $out/usr/lib/tmpfiles.d"
42     substituteInPlace dnf/const.py.in \
43       --replace "/etc" "$out/etc" \
44       --replace "/var/tmp" "/tmp"
45     substituteInPlace doc/CMakeLists.txt \
46       --replace 'SPHINX_BUILD_NAME "sphinx-build-3"' 'SPHINX_BUILD_NAME "${sphinx}/bin/sphinx-build"'
47   '';
49   nativeBuildInputs = [
50     cmake
51     gettext
52     sphinx
53   ];
55   propagatedBuildInputs = [
56     libcomps
57     libdnf
58     rpm
59   ];
61   cmakeFlags = [
62     "-DPYTHON_DESIRED=${pyMajor}"
63   ];
65   dontWrapPythonPrograms = true;
67   postBuild = ''
68     make doc-man
69   '';
71   postInstall = ''
72     # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L218-L220
73     ln -s dnf-${pyMajor} $out/bin/dnf
74     ln -s dnf-${pyMajor} $out/bin/dnf4
75     mv $out/bin/dnf-automatic-${pyMajor} $out/bin/dnf-automatic
77     # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L231-L232
78     ln -s $out/etc/dnf/dnf.conf $out/etc/yum.conf
79     ln -s dnf-${pyMajor} $out/bin/yum
81     mkdir -p $out/share/bash-completion/completions
82     mv $out/etc/bash_completion.d/dnf-3 $out/share/bash-completion/completions/dnf4
83     ln -s $out/share/bash-completion/completions/dnf4 $out/share/bash-completion/completions/dnf
84     rm -r $out/etc/bash_completion.d
85   '';
87   postFixup = ''
88     moveToOutput "lib/${python.libPrefix}" "$py"
89   '';
91   meta = with lib; {
92     description = "Package manager based on libdnf and libsolv. Replaces YUM";
93     homepage = "https://github.com/rpm-software-management/dnf";
94     changelog = "https://github.com/rpm-software-management/dnf/releases/tag/${version}";
95     license = licenses.gpl2Only;
96     maintainers = with maintainers; [ katexochen ];
97     mainProgram = "dnf";
98     platforms = platforms.unix;
99   };