2021-01-15 05:42:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-10-16 21:31:20 +01:00
|
|
|
# The unwrapped gnuradio derivation
|
2020-10-05 10:04:49 +01:00
|
|
|
, unwrapped
|
2020-10-16 21:31:20 +01:00
|
|
|
# If it's a minimal build, we don't want to wrap it with lndir and
|
|
|
|
# wrapProgram..
|
|
|
|
, wrap ? true
|
|
|
|
# For the wrapper
|
2020-10-05 10:04:49 +01:00
|
|
|
, makeWrapper
|
|
|
|
# For lndir
|
|
|
|
, xorg
|
2020-10-16 21:31:20 +01:00
|
|
|
# To define a the gnuradio.pkgs scope
|
|
|
|
, newScope
|
2020-10-05 10:04:49 +01:00
|
|
|
# For Emulating wrapGAppsHook
|
|
|
|
, 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 ? []
|
|
|
|
# Allow to add whatever you want to the wrapper
|
|
|
|
, extraMakeWrapperArgs ? []
|
|
|
|
}:
|
2015-07-15 11:24:03 +01:00
|
|
|
|
2020-10-05 10:04:49 +01:00
|
|
|
let
|
|
|
|
pythonPkgs = extraPythonPackages
|
2020-11-06 10:03:47 +00:00
|
|
|
# Add the extraPackages as python modules as well
|
|
|
|
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
|
2021-01-15 05:42:41 +00:00
|
|
|
++ lib.flatten (lib.mapAttrsToList (
|
2020-10-05 10:04:49 +01:00
|
|
|
feat: info: (
|
|
|
|
if unwrapped.hasFeature feat unwrapped.features then
|
|
|
|
(if builtins.hasAttr "pythonRuntime" info then info.pythonRuntime else [])
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
) unwrapped.featuresInfo)
|
2020-10-16 21:31:20 +01:00
|
|
|
++ lib.optionals
|
|
|
|
(unwrapped.hasFeature "python-support" unwrapped.features)
|
|
|
|
(
|
|
|
|
# Add unwrapped itself as a python module
|
|
|
|
[ (unwrapped.python.pkgs.toPythonModule unwrapped) ]
|
|
|
|
# Add all extraPackages as python modules
|
|
|
|
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
|
|
|
|
)
|
2020-10-05 10:04:49 +01:00
|
|
|
;
|
2020-10-16 21:31:20 +01:00
|
|
|
pythonEnv = unwrapped.python.withPackages(ps: pythonPkgs);
|
2015-07-15 11:24:03 +01:00
|
|
|
|
2021-01-15 05:42:41 +00:00
|
|
|
name = (lib.appendToName "wrapped" unwrapped).name;
|
2020-10-05 10:04:49 +01:00
|
|
|
makeWrapperArgs = builtins.concatStringsSep " " ([
|
|
|
|
]
|
|
|
|
# Emulating wrapGAppsHook & wrapQtAppsHook working together
|
2021-01-15 05:42:41 +00:00
|
|
|
++ lib.optionals (
|
2020-10-05 10:04:49 +01:00
|
|
|
(unwrapped.hasFeature "gnuradio-companion" unwrapped.features)
|
|
|
|
|| (unwrapped.hasFeature "gr-qtgui" unwrapped.features)
|
|
|
|
) [
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "$out/share"
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "$out/share/gsettings-schemas/${name}"
|
|
|
|
"--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 05:42:41 +00:00
|
|
|
"--prefix" "PATH" ":" "${lib.getBin glib}/bin"
|
2020-10-05 10:04:49 +01:00
|
|
|
]
|
2021-01-15 05:42:41 +00:00
|
|
|
++ lib.optionals (unwrapped.hasFeature "gnuradio-companion" unwrapped.features) [
|
2020-10-05 10:04:49 +01:00
|
|
|
"--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"
|
2021-01-15 05:42:41 +00:00
|
|
|
"--prefix" "GIO_EXTRA_MODULES" ":" "${lib.getLib dconf}/lib/gio/modules"
|
2020-10-05 10:04:49 +01:00
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk}/share"
|
|
|
|
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk}/share/gsettings-schemas/${unwrapped.gtk.name}"
|
2021-01-15 05:42:41 +00:00
|
|
|
"--prefix" "GI_TYPELIB_PATH" ":" "${lib.makeSearchPath "lib/girepository-1.0" [
|
2020-10-05 10:04:49 +01: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 05:42:41 +00:00
|
|
|
++ lib.optionals (extraPackages != []) [
|
|
|
|
"--prefix" "GRC_BLOCKS_PATH" ":" "${lib.makeSearchPath "share/gnuradio/grc/blocks" extraPackages}"
|
2020-10-05 10:04:49 +01:00
|
|
|
]
|
2021-01-15 05:42:41 +00:00
|
|
|
++ lib.optionals (unwrapped.hasFeature "gr-qtgui" unwrapped.features)
|
2020-10-05 10:04:49 +01:00
|
|
|
# 3.7 builds with qt4
|
|
|
|
(if unwrapped.versionAttr.major == "3.8" then
|
|
|
|
[
|
|
|
|
"--prefix" "QT_PLUGIN_PATH" ":"
|
2020-10-16 21:31:20 +01:00
|
|
|
"${
|
|
|
|
lib.makeSearchPath
|
|
|
|
unwrapped.qt.qtbase.qtPluginPrefix
|
|
|
|
(builtins.map lib.getBin [
|
|
|
|
unwrapped.qt.qtbase
|
|
|
|
unwrapped.qt.qtwayland
|
|
|
|
])
|
|
|
|
}"
|
2020-10-05 10:04:49 +01:00
|
|
|
"--prefix" "QML2_IMPORT_PATH" ":"
|
2020-10-16 21:31:20 +01:00
|
|
|
"${
|
|
|
|
lib.makeSearchPath
|
|
|
|
unwrapped.qt.qtbase.qtQmlPrefix
|
|
|
|
(builtins.map lib.getBin [
|
|
|
|
unwrapped.qt.qtbase
|
|
|
|
unwrapped.qt.qtwayland
|
|
|
|
])
|
|
|
|
}"
|
2020-10-05 10:04:49 +01:00
|
|
|
]
|
|
|
|
else
|
2020-10-16 21:31:20 +01:00
|
|
|
# Add here qt4 related environment for 3.7?
|
2020-10-05 10:04:49 +01:00
|
|
|
[
|
|
|
|
|
|
|
|
]
|
|
|
|
)
|
|
|
|
++ extraMakeWrapperArgs
|
|
|
|
);
|
2015-07-15 11:24:03 +01:00
|
|
|
|
2020-10-16 21:31:20 +01:00
|
|
|
packages = import ../../../top-level/gnuradio-packages.nix {
|
|
|
|
inherit lib stdenv newScope;
|
|
|
|
gnuradio = unwrapped;
|
2020-10-05 10:04:49 +01:00
|
|
|
};
|
2020-10-16 21:31:20 +01:00
|
|
|
passthru = unwrapped.passthru // {
|
|
|
|
inherit
|
|
|
|
pythonEnv
|
|
|
|
pythonPkgs
|
|
|
|
unwrapped
|
|
|
|
;
|
|
|
|
pkgs = packages;
|
|
|
|
};
|
|
|
|
self = if wrap then
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit name passthru;
|
|
|
|
buildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
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
|