python3Packages.btrfsutil: build separately from btrfs-progs

btrfs-progs was installing its Python bindings as an egg, which doesn't work
with Nix. It turns out that there is no real benefit to building the Python
bindings as part of the btrfs-progs package. Instead, we can just package them
separately, and use nixpkgs' normal Python packaging support to install them as
a wheel. This fixes the bindings and reduces closure sizes.
This commit is contained in:
Ben Wolsieffer 2022-12-06 18:56:58 -05:00
parent 84c17bc98f
commit e21aa200b5
3 changed files with 33 additions and 11 deletions

View file

@ -0,0 +1,26 @@
{ lib
, buildPythonPackage
, btrfs-progs
}:
buildPythonPackage {
pname = "btrfsutil";
inherit (btrfs-progs) version src;
format = "setuptools";
buildInputs = [ btrfs-progs ];
preConfigure = ''
cd libbtrfsutil/python
'';
# No tests
doCheck = false;
pythonImportsCheck = [ "btrfsutil" ];
meta = with lib; {
description = "Library for managing Btrfs filesystems";
homepage = "https://btrfs.wiki.kernel.org/";
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ raskin lopsided98 ];
};
}

View file

@ -1,11 +1,10 @@
{ lib, stdenv, fetchurl
, pkg-config, python3, sphinx
, pkg-config, sphinx
, zstd
, acl, attr, e2fsprogs, libuuid, lzo, udev, zlib
, runCommand, btrfs-progs
, gitUpdater
, udevSupport ? true
, enablePython ? true
}:
stdenv.mkDerivation rec {
@ -19,13 +18,11 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
pkg-config
] ++ lib.optionals enablePython [
python3 python3.pkgs.setuptools
] ++ [
sphinx
];
buildInputs = [ acl attr e2fsprogs libuuid lzo python3 udev zlib zstd ];
buildInputs = [ acl attr e2fsprogs libuuid lzo udev zlib zstd ];
# gcc bug with -O1 on ARM with gcc 4.8
# This should be fine on all platforms so apply universally
@ -35,18 +32,17 @@ stdenv.mkDerivation rec {
install -v -m 444 -D btrfs-completion $out/share/bash-completion/completions/btrfs
'';
configureFlags = lib.optionals stdenv.hostPlatform.isMusl [
"--disable-backtrace"
] ++ lib.optionals (!enablePython) [
configureFlags = [
# Built separately, see python3Packages.btrfsutil
"--disable-python"
] ++ lib.optionals stdenv.hostPlatform.isMusl [
"--disable-backtrace"
] ++ lib.optionals (!udevSupport) [
"--disable-libudev"
];
makeFlags = [ "udevruledir=$(out)/lib/udev/rules.d" ];
installFlags = lib.optionals enablePython [ "install_python" ];
enableParallelBuilding = true;
passthru.tests = {

View file

@ -1430,7 +1430,7 @@ self: super: with self; {
btrfs = callPackage ../development/python-modules/btrfs { };
btrfsutil = toPythonModule (pkgs.btrfs-progs.override { python3 = self.python; });
btrfsutil = callPackage ../development/python-modules/btrfsutil { };
btsocket = callPackage ../development/python-modules/btsocket { };