btrfs-progs: allow to build without python bindings

Python cross-compilation is quite difficult, and doesn't work in
several situations, such as:

https://github.com/NixOS/nixpkgs/issues/186525

Let's give people the option of cross-compiling `btrfs-progs` to
hostPlatforms for which we cannot cross-compile python.  Unfortunately
btrfs-progs insists on a special configure flag `--disable-python`;
simply being unable to find python isn't enough.
This commit is contained in:
Adam Joseph 2022-08-13 15:25:11 -07:00
parent b57e4951e2
commit 28b3398d73

View file

@ -5,6 +5,7 @@
, runCommand, btrfs-progs
, gitUpdater
, udevSupport ? true
, enablePython ? true
}:
stdenv.mkDerivation rec {
@ -18,7 +19,9 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
pkg-config
] ++ lib.optionals enablePython [
python3 python3.pkgs.setuptools
] ++ [
sphinx
];
@ -32,12 +35,17 @@ stdenv.mkDerivation rec {
install -v -m 444 -D btrfs-completion $out/share/bash-completion/completions/btrfs
'';
configureFlags = lib.optional stdenv.hostPlatform.isMusl "--disable-backtrace"
++ lib.optional (!udevSupport) "--disable-libudev";
configureFlags = lib.optionals stdenv.hostPlatform.isMusl [
"--disable-backtrace"
] ++ lib.optionals (!enablePython) [
"--disable-python"
] ++ lib.optionals (!udevSupport) [
"--disable-libudev"
];
makeFlags = [ "udevruledir=$(out)/lib/udev/rules.d" ];
installFlags = [ "install_python" ];
installFlags = lib.optionals enablePython [ "install_python" ];
enableParallelBuilding = true;