From 387bdb9c5e5b712fa37525039e752fcdbf0d705b Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 24 Dec 2023 13:33:39 +0000 Subject: [PATCH 1/4] libbytesize: fix Python bindings --- pkgs/by-name/li/libbytesize/package.nix | 12 ++++++++++-- pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/li/libbytesize/package.nix b/pkgs/by-name/li/libbytesize/package.nix index bd395682cc145..5928f4c9a7edc 100644 --- a/pkgs/by-name/li/libbytesize/package.nix +++ b/pkgs/by-name/li/libbytesize/package.nix @@ -11,7 +11,7 @@ mpfr, pcre2, pkg-config, - python3, + python3Packages, stdenv, }: @@ -41,7 +41,8 @@ stdenv.mkDerivation (finalAttrs: { gtk-doc libxslt pkg-config - python3 + python3Packages.python + python3Packages.pythonImportsCheckHook ]; buildInputs = [ @@ -52,6 +53,13 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; + postInstall = '' + substituteInPlace $out/${python3Packages.python.sitePackages}/bytesize/bytesize.py \ + --replace-fail 'CDLL("libbytesize.so.1")' "CDLL('$out/lib/libbytesize.so.1')" + ''; + + pythonImportsCheck = [ "bytesize" ]; + meta = { homepage = "https://github.com/storaged-project/libbytesize"; description = "Tiny library providing a C 'class' for working with arbitrary big sizes in bytes"; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index bb45317ec90de..dadaea76efecd 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1923,6 +1923,8 @@ self: super: with self; { bytecode = callPackage ../development/python-modules/bytecode { }; + bytesize = toPythonModule (pkgs.libbytesize.override { python3Packages = self; }); + bytewax = callPackage ../development/python-modules/bytewax { }; bz2file = callPackage ../development/python-modules/bz2file { }; From e09aa2ed43d789b3eabe0e51f045965b262136e7 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 25 Dec 2023 14:10:12 +0000 Subject: [PATCH 2/4] libblockdev: split out Python bindings Allow overriding Python without requiring that the entire dependency graph (e.g. udisks) to be built against that Python. --- pkgs/development/libraries/libblockdev/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libblockdev/default.nix b/pkgs/development/libraries/libblockdev/default.nix index 7679aefe5b95a..6e0f9858f730e 100644 --- a/pkgs/development/libraries/libblockdev/default.nix +++ b/pkgs/development/libraries/libblockdev/default.nix @@ -40,12 +40,18 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-WCMedMkaMMhZbB3iJu3c+CTT3AvOjzOSYP45J+NQEDQ="; }; - outputs = [ "out" "dev" "devdoc" ]; + outputs = [ "out" "dev" "devdoc" "python" ]; postPatch = '' patchShebangs scripts + substituteInPlace src/python/gi/overrides/Makefile.am \ + --replace-fail ''\'''${exec_prefix}' '@PYTHON_EXEC_PREFIX@' ''; + configureFlags = [ + "--with-python_prefix=${placeholder "python"}" + ]; + nativeBuildInputs = [ autoconf-archive autoreconfHook From 1813aaf111ab4db2b59b7b7fddf7bc5a2eb1e645 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 24 Dec 2023 15:01:41 +0000 Subject: [PATCH 3/4] blivet: init at 3.10.1 --- .../python-modules/blivet/default.nix | 109 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 111 insertions(+) create mode 100644 pkgs/development/python-modules/blivet/default.nix diff --git a/pkgs/development/python-modules/blivet/default.nix b/pkgs/development/python-modules/blivet/default.nix new file mode 100644 index 0000000000000..e3ca43c8cd225 --- /dev/null +++ b/pkgs/development/python-modules/blivet/default.nix @@ -0,0 +1,109 @@ +{ + lib, + pkgs, + python, + buildPythonPackage, + fetchFromGitHub, + pygobject3, + libblockdev, + bytesize, + pyudev, + dbus-python, + util-linux, + kmod, + libndctl, + nvme-cli, + dosfstools, + e2fsprogs, + hfsprogs, + xfsprogs, + f2fs-tools, + ntfs3g, + btrfs-progs, + reiserfsprogs, + mdadm, + lvm2, + gfs2-utils, + cryptsetup, + multipath-tools, + dracut, + stratisd, +}: + +let + libblockdevPython = (libblockdev.override { python3 = python; }).python; +in +buildPythonPackage rec { + pname = "blivet"; + version = "3.10.1"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "storaged-project"; + repo = "blivet"; + rev = "blivet-${version}"; + hash = "sha256-Ooc63mf03ZO7zxm8s/Tm8jSQg5LWyKnHAqbyvn1UHB8="; + }; + + postPatch = '' + find blivet -name '*.py' | while IFS= read -r i ; do + substituteInPlace "$i" \ + --replace \ + 'gi.require_version("BlockDev",' \ + 'import gi.repository + gi.require_version("GIRepository", "2.0") + from gi.repository import GIRepository + GIRepository.Repository.prepend_search_path("${libblockdev}/lib/girepository-1.0") + gi.require_version("BlockDev",' + done + ''; + + propagatedBuildInputs = [ + pygobject3 + libblockdevPython + bytesize + pyudev + dbus-python + util-linux + kmod + libndctl + nvme-cli + pkgs.systemd + dosfstools + e2fsprogs + hfsprogs + xfsprogs + f2fs-tools + ntfs3g + btrfs-progs + reiserfsprogs + mdadm + lvm2 + gfs2-utils + cryptsetup + multipath-tools + dracut + stratisd + ]; + + pythonImportsCheck = [ "blivet" ]; + + # Even unit tests require a system D-Bus. + # TODO: Write a NixOS VM test? + doCheck = false; + + # Fails with: TypeError: don't know how to make test from: + # + dontUseSetuptoolsCheck = true; + + meta = { + description = "Python module for system storage configuration"; + homepage = "https://github.com/storaged-project/blivet"; + license = [ + lib.licenses.gpl2Plus + lib.licenses.lgpl2Plus + ]; + maintainers = with lib.maintainers; [ cybershadow ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index dadaea76efecd..84ce5b5e84a8e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1686,6 +1686,8 @@ self: super: with self; { blis = callPackage ../development/python-modules/blis { }; + blivet = callPackage ../development/python-modules/blivet { }; + blobfile = callPackage ../development/python-modules/blobfile { }; blockchain = callPackage ../development/python-modules/blockchain { }; From 052b26573d4584cab10a1731d564ebc33674f889 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 24 Dec 2023 17:07:20 +0000 Subject: [PATCH 4/4] blivet-gui: init at 2.5.0 --- pkgs/by-name/bl/blivet-gui/package.nix | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 pkgs/by-name/bl/blivet-gui/package.nix diff --git a/pkgs/by-name/bl/blivet-gui/package.nix b/pkgs/by-name/bl/blivet-gui/package.nix new file mode 100644 index 0000000000000..efe4fe2de7856 --- /dev/null +++ b/pkgs/by-name/bl/blivet-gui/package.nix @@ -0,0 +1,73 @@ +# Notes for using this package outside of NixOS: +# 1. --pure cannot be used (as pkexec will be used from the path, +# and we can't use nixpkgs polkit due to lack of setuid bit) +# 2. You must prefix the blivet-gui command with "SHELL=/bin/bash" +# (otherwise your system polkit will reject the SHEL Lfrom nixpkgs). + +{ + lib, + python3, + fetchFromGitHub, + gtk3, + util-linux, + gobject-introspection, + adwaita-icon-theme, + hicolor-icon-theme, + wrapGAppsHook3, + pkexecPath ? "pkexec", + testers, + blivet-gui, +}: + +python3.pkgs.buildPythonApplication rec { + pname = "blivet-gui"; + version = "2.5.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "storaged-project"; + repo = "blivet-gui"; + rev = version; + hash = "sha256-fKd2Vj8clZ6Q7bZipfN5umyMW2rBXMUnpAuDE70p67U="; + }; + + postPatch = '' + substituteInPlace blivetgui/gui_utils.py --replace-fail /usr/share $out/share + substituteInPlace blivet-gui --replace-fail "pkexec blivet-gui-daemon" "pkexec $out/bin/blivet-gui-daemon" + substituteInPlace blivet-gui --replace-fail "pkexec" "${pkexecPath}" + ''; + + nativeBuildInputs = [ + util-linux + gobject-introspection + wrapGAppsHook3 + ]; + + buildInputs = [ gtk3 ]; + + dependencies = [ + python3.pkgs.blivet + python3.pkgs.pyparted + python3.pkgs.pid + ]; + + dontWrapGApps = true; + + preFixup = '' + makeWrapperArgs+=( + ''${gappsWrapperArgs[@]} + --prefix XDG_DATA_DIRS : ${adwaita-icon-theme}/share + ) + ''; + + passthru.tests.version = testers.testVersion { package = blivet-gui; }; + + meta = { + description = "GUI tool for storage configuration using blivet library"; + homepage = "https://fedoraproject.org/wiki/Blivet"; + license = lib.licenses.gpl2Plus; + mainProgram = "blivet-gui"; + maintainers = with lib.maintainers; [ cybershadow ]; + platforms = lib.platforms.linux; + }; +}