2021-01-15 22:18:51 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-03-15 08:37:03 +00:00
|
|
|
# The unwrapped gnuradio derivation
|
2020-12-07 07:45:13 +00:00
|
|
|
, unwrapped
|
2021-03-15 08:37:03 +00:00
|
|
|
# If it's a minimal build, we don't want to wrap it with lndir and
|
|
|
|
# wrapProgram..
|
2021-05-20 23:08:51 +00:00
|
|
|
, doWrap ? true
|
2021-03-15 08:37:03 +00:00
|
|
|
# For the wrapper
|
2020-12-07 07:45:13 +00:00
|
|
|
, makeWrapper
|
|
|
|
# For lndir
|
|
|
|
, xorg
|
2021-03-15 08:37:03 +00:00
|
|
|
# To define a the gnuradio.pkgs scope
|
|
|
|
, newScope
|
2024-05-15 15:35:15 +00:00
|
|
|
# For Emulating wrapGAppsHook3
|
2020-12-07 07:45:13 +00:00
|
|
|
, gsettings-desktop-schemas
|
|
|
|
, glib
|
|
|
|
, hicolor-icon-theme
|
|
|
|
, pango
|
|
|
|
, json-glib
|
|
|
|
, dconf
|
|
|
|
, gobject-introspection
|
|
|
|
, librsvg
|
|
|
|
, gdk-pixbuf
|
|
|
|
, harfbuzz
|
|
|
|
, at-spi2-core
|
|
|
|
, atk
|
|
|
|
# For Adding additional GRC blocks
|
|
|
|
, extraPackages ? []
|
|
|
|
# For Adding additional python packaages
|
|
|
|
, extraPythonPackages ? []
|
2023-10-09 19:29:22 +00:00
|
|
|
, soapysdr # For it's passthru.searchPath
|
|
|
|
# soapysdr plugins we add by default. Ideally, we should have a
|
|
|
|
# soapysdrPackages = soapysdr.pkgs attribute set, but until now this wasn't
|
|
|
|
# crucial.
|
|
|
|
, soapyairspy
|
|
|
|
, soapyaudio
|
|
|
|
, soapybladerf
|
|
|
|
, soapyhackrf
|
|
|
|
, soapyremote
|
|
|
|
, soapyrtlsdr
|
|
|
|
, soapyuhd
|
|
|
|
# For adding / changing soapysdr packages, like soapsdr-with-plugins does
|
|
|
|
, extraSoapySdrPackages ? [
|
|
|
|
soapyairspy
|
|
|
|
soapyaudio
|
|
|
|
soapybladerf
|
|
|
|
soapyhackrf
|
|
|
|
soapyremote
|
|
|
|
soapyrtlsdr
|
|
|
|
soapyuhd
|
|
|
|
]
|
2020-12-07 07:45:13 +00:00
|
|
|
# Allow to add whatever you want to the wrapper
|
|
|
|
, extraMakeWrapperArgs ? []
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
let
|
2021-10-28 06:52:43 +00:00
|
|
|
# We don't check if `python-support` feature is on, as it's unlikely someone
|
|
|
|
# may wish to wrap GR without python support.
|
2020-12-07 07:45:13 +00:00
|
|
|
pythonPkgs = extraPythonPackages
|
2021-10-28 06:52:43 +00:00
|
|
|
++ [ (unwrapped.python.pkgs.toPythonModule unwrapped) ]
|
2024-05-15 15:35:15 +00:00
|
|
|
++ unwrapped.passthru.uhd.pythonPath
|
|
|
|
++ lib.optionals (unwrapped.passthru.uhd.pythonPath != []) [
|
|
|
|
(unwrapped.python.pkgs.toPythonModule unwrapped.passthru.uhd)
|
|
|
|
]
|
2020-12-07 07:45:13 +00:00
|
|
|
# Add the extraPackages as python modules as well
|
|
|
|
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.flatten (lib.mapAttrsToList (
|
2020-12-07 07:45:13 +00:00
|
|
|
feat: info: (
|
2023-02-16 17:41:37 +00:00
|
|
|
lib.optionals ((unwrapped.hasFeature feat) && (builtins.hasAttr "pythonRuntime" info)) info.pythonRuntime
|
2020-12-07 07:45:13 +00:00
|
|
|
)
|
2023-02-16 17:41:37 +00:00
|
|
|
) unwrapped.featuresInfo)
|
2020-12-07 07:45:13 +00:00
|
|
|
;
|
2021-03-15 08:37:03 +00:00
|
|
|
pythonEnv = unwrapped.python.withPackages(ps: pythonPkgs);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
pname = unwrapped.pname + "-wrapped";
|
|
|
|
inherit (unwrapped) version;
|
2020-12-07 07:45:13 +00:00
|
|
|
makeWrapperArgs = builtins.concatStringsSep " " ([
|
|
|
|
]
|
2024-05-15 15:35:15 +00:00
|
|
|
# Emulating wrapGAppsHook3 & wrapQtAppsHook working together
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals (
|
2021-10-28 06:52:43 +00:00
|
|
|
(unwrapped.hasFeature "gnuradio-companion")
|
|
|
|
|| (unwrapped.hasFeature "gr-qtgui")
|
2020-12-07 07:45:13 +00:00
|
|
|
) [
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "$out/share"
|
2022-03-30 09:31:56 +00:00
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "$out/share/gsettings-schemas/${pname}"
|
2020-12-07 07:45:13 +00:00
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${hicolor-icon-theme}/share"
|
|
|
|
# Needs to run `gsettings` on startup, see:
|
|
|
|
# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1764890.html
|
2021-01-15 22:18:51 +00:00
|
|
|
"--prefix" "PATH" ":" "${lib.getBin glib}/bin"
|
2020-12-07 07:45:13 +00:00
|
|
|
]
|
2021-10-28 06:52:43 +00:00
|
|
|
++ lib.optionals (unwrapped.hasFeature "gnuradio-companion") [
|
2020-12-07 07:45:13 +00:00
|
|
|
"--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"
|
2021-01-15 22:18:51 +00:00
|
|
|
"--prefix" "GIO_EXTRA_MODULES" ":" "${lib.getLib dconf}/lib/gio/modules"
|
2020-12-07 07:45:13 +00:00
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk}/share"
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk}/share/gsettings-schemas/${unwrapped.gtk.name}"
|
2021-01-15 22:18:51 +00:00
|
|
|
"--prefix" "GI_TYPELIB_PATH" ":" "${lib.makeSearchPath "lib/girepository-1.0" [
|
2024-06-05 15:53:02 +00:00
|
|
|
(lib.getLib glib)
|
2020-12-07 07:45:13 +00:00
|
|
|
unwrapped.gtk
|
|
|
|
gsettings-desktop-schemas
|
|
|
|
atk
|
|
|
|
# From some reason, if .out is not used, .bin is used, and we want
|
|
|
|
# what's in `.out`.
|
|
|
|
pango.out
|
|
|
|
gdk-pixbuf
|
|
|
|
json-glib
|
|
|
|
harfbuzz
|
|
|
|
librsvg
|
|
|
|
gobject-introspection
|
|
|
|
at-spi2-core
|
|
|
|
]}"
|
|
|
|
]
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals (extraPackages != []) [
|
|
|
|
"--prefix" "GRC_BLOCKS_PATH" ":" "${lib.makeSearchPath "share/gnuradio/grc/blocks" extraPackages}"
|
2020-12-07 07:45:13 +00:00
|
|
|
]
|
2023-10-09 19:29:22 +00:00
|
|
|
++ lib.optionals (extraSoapySdrPackages != []) [
|
|
|
|
"--prefix" "SOAPY_SDR_PLUGIN_PATH" ":" "${lib.makeSearchPath
|
|
|
|
soapysdr.passthru.searchPath extraSoapySdrPackages}"
|
|
|
|
]
|
2021-10-28 06:52:43 +00:00
|
|
|
++ lib.optionals (unwrapped.hasFeature "gr-qtgui")
|
2020-12-07 07:45:13 +00:00
|
|
|
# 3.7 builds with qt4
|
2021-05-20 23:08:51 +00:00
|
|
|
(if lib.versionAtLeast unwrapped.versionAttr.major "3.8" then
|
2020-12-07 07:45:13 +00:00
|
|
|
[
|
|
|
|
"--prefix" "QT_PLUGIN_PATH" ":"
|
2021-03-15 08:37:03 +00:00
|
|
|
"${
|
|
|
|
lib.makeSearchPath
|
|
|
|
unwrapped.qt.qtbase.qtPluginPrefix
|
2022-10-30 15:09:59 +00:00
|
|
|
(builtins.map lib.getBin ([
|
2021-03-15 08:37:03 +00:00
|
|
|
unwrapped.qt.qtbase
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2021-03-15 08:37:03 +00:00
|
|
|
unwrapped.qt.qtwayland
|
2022-10-30 15:09:59 +00:00
|
|
|
]))
|
2021-03-15 08:37:03 +00:00
|
|
|
}"
|
2020-12-07 07:45:13 +00:00
|
|
|
"--prefix" "QML2_IMPORT_PATH" ":"
|
2021-03-15 08:37:03 +00:00
|
|
|
"${
|
|
|
|
lib.makeSearchPath
|
|
|
|
unwrapped.qt.qtbase.qtQmlPrefix
|
2022-10-30 15:09:59 +00:00
|
|
|
(builtins.map lib.getBin ([
|
2021-03-15 08:37:03 +00:00
|
|
|
unwrapped.qt.qtbase
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2021-03-15 08:37:03 +00:00
|
|
|
unwrapped.qt.qtwayland
|
2022-10-30 15:09:59 +00:00
|
|
|
]))
|
2021-03-15 08:37:03 +00:00
|
|
|
}"
|
2020-12-07 07:45:13 +00:00
|
|
|
]
|
|
|
|
else
|
2021-03-15 08:37:03 +00:00
|
|
|
# Add here qt4 related environment for 3.7?
|
2020-12-07 07:45:13 +00:00
|
|
|
[
|
|
|
|
|
|
|
|
]
|
|
|
|
)
|
|
|
|
++ extraMakeWrapperArgs
|
|
|
|
);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-15 08:37:03 +00:00
|
|
|
packages = import ../../../top-level/gnuradio-packages.nix {
|
|
|
|
inherit lib stdenv newScope;
|
|
|
|
gnuradio = unwrapped;
|
2020-12-07 07:45:13 +00:00
|
|
|
};
|
2021-03-15 08:37:03 +00:00
|
|
|
passthru = unwrapped.passthru // {
|
|
|
|
inherit
|
|
|
|
pythonEnv
|
|
|
|
pythonPkgs
|
|
|
|
unwrapped
|
|
|
|
;
|
|
|
|
pkgs = packages;
|
|
|
|
};
|
2021-05-20 23:08:51 +00:00
|
|
|
self = if doWrap then
|
2021-03-15 08:37:03 +00:00
|
|
|
stdenv.mkDerivation {
|
2022-03-30 09:31:56 +00:00
|
|
|
inherit pname version passthru;
|
2022-04-27 09:35:20 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2021-03-15 08:37:03 +00:00
|
|
|
buildInputs = [
|
|
|
|
xorg.lndir
|
|
|
|
];
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir $out
|
|
|
|
cd $out
|
|
|
|
lndir -silent ${unwrapped}
|
|
|
|
${lib.optionalString
|
|
|
|
(extraPackages != [])
|
|
|
|
(builtins.concatStringsSep "\n"
|
|
|
|
(builtins.map (pkg: ''
|
|
|
|
if [[ -d ${lib.getBin pkg}/bin/ ]]; then
|
|
|
|
lndir -silent ${pkg}/bin ./bin
|
|
|
|
fi
|
|
|
|
'') extraPackages)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
for i in $out/bin/*; do
|
|
|
|
if [[ ! -x "$i" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
cp -L "$i" "$i".tmp
|
|
|
|
mv -f "$i".tmp "$i"
|
|
|
|
if head -1 "$i" | grep -q ${unwrapped.python}; then
|
|
|
|
substituteInPlace "$i" \
|
|
|
|
--replace ${unwrapped.python} ${pythonEnv}
|
|
|
|
fi
|
|
|
|
wrapProgram "$i" ${makeWrapperArgs}
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
inherit (unwrapped) meta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
unwrapped.overrideAttrs(_: {
|
|
|
|
inherit passthru;
|
|
|
|
})
|
|
|
|
;
|
|
|
|
in self
|