newsflash: fix cross compilation
This commit is contained in:
@@ -863,6 +863,96 @@ in with final; {
|
|||||||
# );
|
# );
|
||||||
# 2023/07/31: upstreaming is blocked on vpnc cross compilation
|
# 2023/07/31: upstreaming is blocked on vpnc cross compilation
|
||||||
# networkmanager-vpnc = mvToNativeInputs [ glib ] prev.networkmanager-vpnc;
|
# networkmanager-vpnc = mvToNativeInputs [ glib ] prev.networkmanager-vpnc;
|
||||||
|
|
||||||
|
newsflash = prev.newsflash.overrideAttrs (upstream: {
|
||||||
|
nativeBuildInputs = (lib.filter (p: !lib.elem (p.pname or p.name) [ "gdk-pixbuf" "blueprint-compiler" ]) upstream.nativeBuildInputs) ++ [
|
||||||
|
buildPackages.git
|
||||||
|
(buildPackages.writeShellScriptBin "blueprint-compiler" ''
|
||||||
|
export GI_TYPELIB_PATH=${typelibPath [
|
||||||
|
buildPackages.clapper
|
||||||
|
buildPackages.glib
|
||||||
|
buildPackages.gtk4
|
||||||
|
buildPackages.gst_all_1.gstreamer
|
||||||
|
# some of these below are probably *not* needed
|
||||||
|
buildPackages.gst_all_1.gst-plugins-base
|
||||||
|
buildPackages.gst_all_1.gst-plugins-good
|
||||||
|
buildPackages.gst_all_1.gst-plugins-bad
|
||||||
|
buildPackages.gdk-pixbuf
|
||||||
|
buildPackages.graphene
|
||||||
|
buildPackages.harfbuzz
|
||||||
|
buildPackages.libadwaita
|
||||||
|
buildPackages.pango
|
||||||
|
]}
|
||||||
|
exec ${lib.getExe buildPackages.blueprint-compiler} "$@"
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
# strictDeps = false;
|
||||||
|
|
||||||
|
postPatch = (upstream.postPatch or "") + ''
|
||||||
|
substituteInPlace src/meson.build --replace-fail \
|
||||||
|
"'src' / rust_target" \
|
||||||
|
"'src' / '${rust.toRustTarget stdenv.hostPlatform}' / rust_target"
|
||||||
|
|
||||||
|
rm build.rs
|
||||||
|
|
||||||
|
export OUT_DIR=$(pwd)
|
||||||
|
|
||||||
|
# from build.rs:
|
||||||
|
glib-compile-resources --sourcedir=data/resources --target=icons.gresource data/resources/icons.gresource.xml
|
||||||
|
glib-compile-resources --sourcedir=data/resources --target=styles.gresource data/resources/styles.gresource.xml
|
||||||
|
substitute data/io.gitlab.news_flash.NewsFlash.appdata.xml.in.in \
|
||||||
|
data/resources/io.gitlab.news_flash.NewsFlash.appdata.xml \
|
||||||
|
--replace-fail '@appid@' 'io.gitlab.news_flash.NewsFlash'
|
||||||
|
glib-compile-resources --sourcedir=data/resources --target=appdata.gresource data/resources/appdata.gresource.xml
|
||||||
|
'';
|
||||||
|
|
||||||
|
# nixpkgs sets CARGO_BUILD_TARGET to the build platform target, so correct that.
|
||||||
|
# fixes openssl not being able to find its library
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
${rust.envVars.setEnv} "CARGO_BUILD_TARGET=${rust.toRustTarget stdenv.hostPlatform}" ninja -j$NIX_BUILD_CORES
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
env = let
|
||||||
|
inherit buildPackages stdenv rust;
|
||||||
|
ccForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
||||||
|
cxxForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++";
|
||||||
|
ccForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||||
|
cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
|
||||||
|
rustBuildPlatform = rust.toRustTarget stdenv.buildPlatform;
|
||||||
|
rustTargetPlatform = rust.toRustTarget stdenv.hostPlatform;
|
||||||
|
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||||
|
in (upstream.env or {}) // {
|
||||||
|
# taken from <pkgs/build-support/rust/hooks/default.nix>
|
||||||
|
# fixes "cargo:warning=aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option ‘-m64’"
|
||||||
|
# XXX: these aren't necessarily valid environment variables: the referenced nix file is more clever to get them to work.
|
||||||
|
"CC_${rustBuildPlatform}" = "${ccForBuild}";
|
||||||
|
"CXX_${rustBuildPlatform}" = "${cxxForBuild}";
|
||||||
|
"CC_${rustTargetPlatform}" = "${ccForHost}";
|
||||||
|
"CXX_${rustTargetPlatform}" = "${cxxForHost}";
|
||||||
|
# fails to fix "Failed to find OpenSSL development headers."
|
||||||
|
# OPENSSL_NO_VENDOR = 1;
|
||||||
|
# OPENSSL_LIB_DIR = "${lib.getLib openssl}/lib";
|
||||||
|
# OPENSSL_DIR = "${lib.getDev openssl}";
|
||||||
|
};
|
||||||
|
|
||||||
|
# mesonFlags = let
|
||||||
|
# crossFile = writeText "cross-file.conf" ''
|
||||||
|
# [binaries]
|
||||||
|
# rust = [ 'rustc', '--target', '${rust.toRustTargetSpec stdenv.hostPlatform}' ]
|
||||||
|
# '';
|
||||||
|
# in
|
||||||
|
# (upstream.mesonFlags or []) ++ [
|
||||||
|
# "-Dprofile=development"
|
||||||
|
# ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
|
# "--cross-file=${crossFile}"
|
||||||
|
# ];
|
||||||
|
});
|
||||||
|
|
||||||
# fixes "properties/gresource.xml: Permission denied"
|
# fixes "properties/gresource.xml: Permission denied"
|
||||||
# - by providing glib-compile-resources
|
# - by providing glib-compile-resources
|
||||||
# 2024/05/31: upstreaming is blocked on qtsvg, qtimageformats, qtx11extras
|
# 2024/05/31: upstreaming is blocked on qtsvg, qtimageformats, qtx11extras
|
||||||
|
Reference in New Issue
Block a user