uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,152 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchurl
, substituteAll
, coreutils
, curl
, gawk
, glxinfo
, gnugrep
, gnused
, lsof
, xdg-utils
, dbus
, hwdata
, libX11
, mangohud32
, vulkan-headers
, glslang
, makeWrapper
, meson
, ninja
, pkg-config
, python3Packages
, unzip
, vulkan-loader
, libXNVCtrl
, wayland
, spdlog
, addOpenGLRunpath
}:
let
# Derived from subprojects/imgui.wrap
imgui = rec {
version = "1.81";
src = fetchFromGitHub {
owner = "ocornut";
repo = "imgui";
rev = "v${version}";
hash = "sha256-rRkayXk3xz758v6vlMSaUu5fui6NR8Md3njhDB0gJ18=";
};
patch = fetchurl {
url = "https://wrapdb.mesonbuild.com/v2/imgui_${version}-1/get_patch";
hash = "sha256-bQC0QmkLalxdj4mDEdqvvOFtNwz2T1MpTDuMXGYeQ18=";
};
};
in stdenv.mkDerivation rec {
pname = "mangohud";
version = "0.6.7-1";
src = fetchFromGitHub {
owner = "flightlessmango";
repo = "MangoHud";
rev = "v${version}";
fetchSubmodules = true;
sha256 = "sha256-60cZYo+d679KRggLBGbpLYM5Iu1XySEEGp+MxZs6wF0=";
};
outputs = [ "out" "doc" "man" ];
# Unpack subproject sources
postUnpack = ''(
cd "$sourceRoot/subprojects"
cp -R --no-preserve=mode,ownership ${imgui.src} imgui-${imgui.version}
unzip ${imgui.patch}
)'';
patches = [
# Hard code dependencies. Can't use makeWrapper since the Vulkan
# layer can be used without the mangohud executable by setting MANGOHUD=1.
(substituteAll {
src = ./hardcode-dependencies.patch;
path = lib.makeBinPath [
coreutils
curl
gawk
glxinfo
gnugrep
gnused
lsof
xdg-utils
];
libdbus = dbus.lib;
inherit hwdata libX11;
})
] ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux") [
# Support 32bit OpenGL applications by appending the mangohud32
# lib path to LD_LIBRARY_PATH.
#
# This workaround is necessary since on Nix's build of ld.so, $LIB
# always expands to lib even when running an 32bit application.
#
# See https://github.com/NixOS/nixpkgs/issues/101597.
(substituteAll {
src = ./opengl32-nix-workaround.patch;
inherit mangohud32;
})
];
mesonFlags = [
"-Duse_system_vulkan=enabled"
"-Dvulkan_datadir=${vulkan-headers}/share"
"-Dwith_wayland=enabled"
"-Duse_system_spdlog=enabled"
];
nativeBuildInputs = [
glslang
makeWrapper
meson
ninja
pkg-config
python3Packages.Mako
python3Packages.python
unzip
vulkan-loader
];
buildInputs = [
dbus
libX11
libXNVCtrl
wayland
spdlog
];
# Support 32bit Vulkan applications by linking in 32bit Vulkan layer
# This is needed for the same reason the 32bit OpenGL workaround is needed.
postInstall = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
ln -s ${mangohud32}/share/vulkan/implicit_layer.d/MangoHud.json \
"$out/share/vulkan/implicit_layer.d/MangoHud.x86.json"
'';
# Support Nvidia cards by adding OpenGL path and support overlaying
# Vulkan applications without requiring MangoHud to be installed
postFixup = ''
wrapProgram "$out/bin/mangohud" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ addOpenGLRunpath.driverLink ]} \
--prefix XDG_DATA_DIRS : "$out/share"
'';
meta = with lib; {
description = "A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more";
homepage = "https://github.com/flightlessmango/MangoHud";
platforms = platforms.linux;
license = licenses.mit;
maintainers = with maintainers; [ kira-bruneau zeratax ];
};
}

View file

@ -0,0 +1,75 @@
From 56a191f6db6d530c2bc89d9d3395b4c9768d108f Mon Sep 17 00:00:00 2001
From: Atemu <atemu.main@gmail.com>
Date: Tue, 17 May 2022 16:58:08 +0200
Subject: [PATCH 1/2] hardcode dependencies
---
src/dbus.cpp | 2 +-
src/loaders/loader_x11.cpp | 2 +-
src/logging.cpp | 7 +++++++
src/pci_ids.cpp | 6 ++----
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/dbus.cpp b/src/dbus.cpp
index 3b3cccb..1405725 100644
--- a/src/dbus.cpp
+++ b/src/dbus.cpp
@@ -152,7 +152,7 @@ bool dbus_manager::get_media_player_metadata(metadata& meta, std::string name) {
}
bool dbus_manager::init_internal() {
- if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) {
+ if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("@libdbus@/lib/libdbus-1.so.3")) {
SPDLOG_ERROR("Could not load libdbus-1.so.3");
return false;
}
diff --git a/src/loaders/loader_x11.cpp b/src/loaders/loader_x11.cpp
index 4db6f78..c60d08c 100644
--- a/src/loaders/loader_x11.cpp
+++ b/src/loaders/loader_x11.cpp
@@ -89,4 +89,4 @@ void libx11_loader::CleanUp(bool unload) {
}
-std::shared_ptr<libx11_loader> g_x11(new libx11_loader("libX11.so.6"));
+std::shared_ptr<libx11_loader> g_x11(new libx11_loader("@libX11@/lib/libX11.so.6"));
diff --git a/src/logging.cpp b/src/logging.cpp
index b27f21e..48f5e03 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -22,7 +22,14 @@ string exec(string command) {
#endif
std::array<char, 128> buffer;
std::string result;
+
+ char* originalPath = getenv("PATH");
+ setenv("PATH", "@path@", 1);
+
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
+
+ setenv("PATH", originalPath, 1);
+
if (!pipe) {
return "popen failed!";
}
diff --git a/src/pci_ids.cpp b/src/pci_ids.cpp
index feec222..6baa707 100644
--- a/src/pci_ids.cpp
+++ b/src/pci_ids.cpp
@@ -24,11 +24,9 @@ std::istream& get_uncommented_line(std::istream& is, std::string &line)
void parse_pciids()
{
std::ifstream file;
- file.open("/usr/share/hwdata/pci.ids");
+ file.open("@hwdata@/share/hwdata/pci.ids");
if (file.fail()){
- file.open("/usr/share/misc/pci.ids");
- if (file.fail())
- SPDLOG_ERROR("can't find file pci.ids");
+ SPDLOG_ERROR("can't find file pci.ids");
}
std::string line;
--
2.36.0

View file

@ -0,0 +1,24 @@
From 1ac93cbf0eed951af6967a81f731a0f418ea0b3d Mon Sep 17 00:00:00 2001
From: Atemu <atemu.main@gmail.com>
Date: Tue, 17 May 2022 16:58:45 +0200
Subject: [PATCH 2/2] opengl32 nix workaround
---
bin/mangohud.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/mangohud.in b/bin/mangohud.in
index 8ec21de..f65304a 100755
--- a/bin/mangohud.in
+++ b/bin/mangohud.in
@@ -23,6 +23,6 @@ fi
# figure out whether the 32 or 64 bit version should be used, and will search
# for it in the correct directory
LD_PRELOAD="${LD_PRELOAD}:${MANGOHUD_LIB_NAME}"
-LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@"
+LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@:@mangohud32@/lib/mangohud"
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"
--
2.36.0