diff --git a/pkgs/development/python-modules/dnf4/default.nix b/pkgs/development/python-modules/dnf4/default.nix new file mode 100644 index 000000000000..a40e22a4317f --- /dev/null +++ b/pkgs/development/python-modules/dnf4/default.nix @@ -0,0 +1,83 @@ +{ lib +, buildPythonPackage +, cmake +, fetchFromGitHub +, gettext +, libcomps +, libdnf +, python +, rpm +, sphinx +}: + +buildPythonPackage rec { + pname = "dnf4"; + version = "4.18.1"; + format = "other"; + + outputs = [ "out" "man" ]; + + src = fetchFromGitHub { + owner = "rpm-software-management"; + repo = "dnf"; + rev = version; + hash = "sha256-pgS4y87HbFiaS+fftdhKHOZAl2hYTUds3XVXUuQN6tU="; + }; + + patches = [ + ./fix-python-install-dir.patch + ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}" \ + --replace "SYSCONFDIR /etc" "SYSCONFDIR $out/etc" \ + --replace "SYSTEMD_DIR /usr/lib/systemd/system" "SYSTEMD_DIR $out/lib/systemd/system" + substituteInPlace etc/tmpfiles.d/CMakeLists.txt \ + --replace "DESTINATION /usr/lib/tmpfiles.d" "DESTINATION $out/usr/lib/tmpfiles.d" + substituteInPlace dnf/const.py.in \ + --replace "/etc" "$out/etc" + substituteInPlace doc/CMakeLists.txt \ + --replace 'SPHINX_BUILD_NAME "sphinx-build-3"' 'SPHINX_BUILD_NAME "${sphinx}/bin/sphinx-build"' + ''; + + nativeBuildInputs = [ + cmake + gettext + sphinx + ]; + + propagatedBuildInputs = [ + libcomps + libdnf + rpm + ]; + + cmakeFlags = [ + "-DPYTHON_DESIRED=${lib.head (lib.splitString ["."] python.version)}" + ]; + + postBuild = '' + make doc-man + ''; + + postInstall = '' + # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L218-L220 + ln -s dnf-3 $out/bin/dnf + ln -s dnf-3 $out/bin/dnf4 + mv $out/bin/dnf-automatic-3 $out/bin/dnf-automatic + # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L231-L232 + ln -s $out/etc/dnf/dnf.conf $out/etc/yum.conf + ln -s dnf-3 $out/bin/yum + ''; + + meta = with lib; { + description = "Package manager based on libdnf and libsolv. Replaces YUM"; + homepage = "https://github.com/rpm-software-management/dnf"; + changelog = "https://github.com/rpm-software-management/dnf/releases/tag/${version}"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ katexochen ]; + mainProgram = "dnf"; + platforms = platforms.unix; + }; +} diff --git a/pkgs/development/python-modules/dnf4/fix-python-install-dir.patch b/pkgs/development/python-modules/dnf4/fix-python-install-dir.patch new file mode 100644 index 000000000000..07b68242d8fc --- /dev/null +++ b/pkgs/development/python-modules/dnf4/fix-python-install-dir.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4aee99fb..0bb28897 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,7 +19,7 @@ ELSE () + MESSAGE (FATAL_ERROR "Invalid PYTHON_DESIRED value: " ${PYTHON_DESIRED}) + ENDIF() + +-EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from sysconfig import get_path; stdout.write(get_path('purelib'))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR) ++SET(PYTHON_INSTALL_DIR "@PYTHON_INSTALL_DIR@") + MESSAGE(STATUS "Python install dir is ${PYTHON_INSTALL_DIR}") + + ADD_SUBDIRECTORY (dnf) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b78335bf26f4..65ab4c74cd0f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -605,6 +605,8 @@ with pkgs; dec-decode = callPackage ../development/tools/dec-decode { }; + dnf4 = with python3Packages; toPythonApplication dnf4; + dnf5 = callPackage ../tools/package-management/dnf5 { }; documenso = callPackage ../applications/office/documenso { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index ab3462a2a171..a950a0ca5e52 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3204,6 +3204,8 @@ self: super: with self; { dnachisel = callPackage ../development/python-modules/dnachisel { }; + dnf4 = callPackage ../development/python-modules/dnf4 { }; + dnfile = callPackage ../development/python-modules/dnfile { }; dnslib = callPackage ../development/python-modules/dnslib { };