diff --git a/pkgs/development/python-modules/babeltrace/default.nix b/pkgs/development/python-modules/babeltrace/default.nix new file mode 100644 index 0000000000000..6b4e56262c9a2 --- /dev/null +++ b/pkgs/development/python-modules/babeltrace/default.nix @@ -0,0 +1,18 @@ +{ toPythonModule +, python +, babeltrace +, swig2 +}: + +toPythonModule (babeltrace.overrideAttrs ({ nativeBuildInputs ? [ ], configureFlags ? [ ], ... }: { + nativeBuildInputs = nativeBuildInputs ++ [ swig2 ]; + + configureFlags = configureFlags ++ [ "--enable-python-bindings" ]; + + # Nix treats nativeBuildInputs specially for cross-compilation, but in this + # case, cross-compilation is accounted for explicitly. Using the variables + # ensures that the platform setup isn't messed with further. It also allows + # regular Python to be added in the future if it is ever needed. + PYTHON = "${python.pythonOnBuildForHost}/bin/python"; + PYTHON_CONFIG = "${python.pythonOnBuildForHost}/bin/python-config"; +})) diff --git a/pkgs/development/python-modules/babeltrace2/default.nix b/pkgs/development/python-modules/babeltrace2/default.nix new file mode 100644 index 0000000000000..5ef4cf65c1a00 --- /dev/null +++ b/pkgs/development/python-modules/babeltrace2/default.nix @@ -0,0 +1,21 @@ +{ toPythonModule +, python +, babeltrace2 +, swig +}: + +toPythonModule (babeltrace2.overrideAttrs ({ nativeBuildInputs ? [ ], configureFlags ? [ ], ... }: { + nativeBuildInputs = nativeBuildInputs ++ [ swig ]; + + configureFlags = configureFlags ++ [ + "--enable-python-bindings" + "--enable-python-plugins" + ]; + + # Nix treats nativeBuildInputs specially for cross-compilation, but in this + # case, cross-compilation is accounted for explicitly. Using the variables + # ensures that the platform setup isn't messed with further. It also allows + # regular Python to be added in the future if it is ever needed. + PYTHON = "${python.pythonOnBuildForHost}/bin/python"; + PYTHON_CONFIG = "${python.pythonOnBuildForHost}/bin/python-config"; +})) diff --git a/pkgs/development/tools/misc/babeltrace/common.nix b/pkgs/development/tools/misc/babeltrace/common.nix new file mode 100644 index 0000000000000..48faf89b28f2d --- /dev/null +++ b/pkgs/development/tools/misc/babeltrace/common.nix @@ -0,0 +1,43 @@ +{ lib +, stdenv +, fetchzip +, autoreconfHook +, pkg-config +, glib +, elfutils + +, version +, hash +}: + +args: stdenv.mkDerivation (finalAttrs: args // { + inherit version; + + src = fetchzip { + url = "https://www.efficios.com/files/babeltrace/${finalAttrs.pname}-${finalAttrs.version}.tar.bz2"; + inherit hash; + }; + + # In 1.x, the pre-generated ./configure script uses an old autoconf version + # which breaks cross-compilation (replaces references to malloc with + # rpl_malloc). + # In 2.x, there is no pre-generated ./configure script. + # Re-generate with nixpkgs's autoconf. This requires glib to be present in + # nativeBuildInputs for its m4 macros to be present. + nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ autoreconfHook pkg-config glib ]; + + buildInputs = args.buildInputs or [ ] ++ [ glib elfutils ]; + + # --enable-debug-info (default) requires the configure script to run host + # executables to determine the elfutils library version, which cannot be done + # while cross compiling. + configureFlags = args.configureFlags or [ ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-debug-info"; + + meta = with lib; { + description = "Command-line tool and library to read and convert LTTng tracefiles"; + homepage = "https://www.efficios.com/babeltrace"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = [ maintainers.bjornfor ]; + }; +}) diff --git a/pkgs/development/tools/misc/babeltrace/default.nix b/pkgs/development/tools/misc/babeltrace/default.nix index 014d926eea3d7..0919d1705abe2 100644 --- a/pkgs/development/tools/misc/babeltrace/default.nix +++ b/pkgs/development/tools/misc/babeltrace/default.nix @@ -1,32 +1,6 @@ -{ lib, stdenv, fetchurl, autoreconfHook, pkg-config, glib, libuuid, popt, elfutils }: - -stdenv.mkDerivation rec { - pname = "babeltrace"; - version = "1.5.8"; - - src = fetchurl { - url = "https://www.efficios.com/files/babeltrace/${pname}-${version}.tar.bz2"; - sha256 = "1hkg3phnamxfrhwzmiiirbhdgckzfkqwhajl0lmr1wfps7j47wcz"; - }; - - # The pre-generated ./configure script uses an old autoconf version which - # breaks cross-compilation (replaces references to malloc with rpl_malloc). - # Re-generate with nixpkgs's autoconf. This requires glib to be present in - # nativeBuildInputs for its m4 macros to be present. - nativeBuildInputs = [ autoreconfHook glib pkg-config ]; - buildInputs = [ glib libuuid popt elfutils ]; - - # --enable-debug-info (default) requires the configure script to run host - # executables to determine the elfutils library version, which cannot be done - # while cross compiling. - configureFlags = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-debug-info"; - - meta = with lib; { - description = "Command-line tool and library to read and convert LTTng tracefiles"; - homepage = "https://www.efficios.com/babeltrace"; - license = licenses.mit; - platforms = platforms.linux; - maintainers = [ maintainers.bjornfor ]; - }; +{ callPackage }: +{ + v1 = callPackage ./v1.nix { }; + v2 = callPackage ./v2.nix { }; } diff --git a/pkgs/development/tools/misc/babeltrace/v1.nix b/pkgs/development/tools/misc/babeltrace/v1.nix new file mode 100644 index 0000000000000..7781ea056272b --- /dev/null +++ b/pkgs/development/tools/misc/babeltrace/v1.nix @@ -0,0 +1,15 @@ +{ callPackage +, libuuid +, popt +}: + +callPackage ./common.nix +{ + version = "1.5.11"; + hash = "sha256-kreCyByYgWhEhRXulVithOweVhadat3ZmsbbbcUYKN8="; +} +{ + pname = "babeltrace"; + + buildInputs = [ libuuid popt ]; +} diff --git a/pkgs/development/tools/misc/babeltrace/v2.nix b/pkgs/development/tools/misc/babeltrace/v2.nix new file mode 100644 index 0000000000000..a804ec0ae9a88 --- /dev/null +++ b/pkgs/development/tools/misc/babeltrace/v2.nix @@ -0,0 +1,15 @@ +{ callPackage +}: + +callPackage ./common.nix +{ + version = "2.0.5"; + hash = "sha256-8jY+zOI1Xqht9ybVDPelJgKrGTheIuzGaiaGV3dGJ+4="; +} +{ + pname = "babeltrace2"; + + preBuild = '' + makeFlagsArray+=(CFLAGS="-Wno-error=stringop-truncation -Wno-error=null-dereference") + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c9eec87f62cbd..859076fbb6190 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18447,7 +18447,11 @@ with pkgs; b4 = callPackage ../development/tools/b4 { }; - babeltrace = callPackage ../development/tools/misc/babeltrace { }; + babeltracePackages = callPackage ../development/tools/misc/babeltrace { }; + + babeltrace = babeltracePackages.v1; + + babeltrace2 = babeltracePackages.v2; bam = callPackage ../development/tools/build-managers/bam { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c3253da82ad78..97115108d9986 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1284,6 +1284,10 @@ self: super: with self; { babelgladeextractor = callPackage ../development/python-modules/babelgladeextractor { }; + babeltrace = callPackage ../development/python-modules/babeltrace { inherit (pkgs) babeltrace; }; + + babeltrace2 = callPackage ../development/python-modules/babeltrace2 { inherit (pkgs) babeltrace2; }; + bambi = callPackage ../development/python-modules/bambi { }; pad4pi = callPackage ../development/python-modules/pad4pi { };