From 809f525f6d99f72c7a5324d616b80d700f02589c Mon Sep 17 00:00:00 2001 From: ccicnce113424 Date: Wed, 25 Mar 2026 03:06:09 +0800 Subject: [PATCH] eglexternalplatform: add update script and setup hook, add maintainer --- .../eg/eglexternalplatform/package.nix | 22 ++++++++-- .../eg/eglexternalplatform/setup-hook.sh | 43 +++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/eg/eglexternalplatform/setup-hook.sh diff --git a/pkgs/by-name/eg/eglexternalplatform/package.nix b/pkgs/by-name/eg/eglexternalplatform/package.nix index 3208fbcd02eb..c8ac9db06298 100644 --- a/pkgs/by-name/eg/eglexternalplatform/package.nix +++ b/pkgs/by-name/eg/eglexternalplatform/package.nix @@ -4,6 +4,9 @@ fetchFromGitHub, meson, ninja, + buildPackages, + replaceVars, + nix-update-script, }: stdenv.mkDerivation (finalAttrs: { @@ -11,9 +14,9 @@ stdenv.mkDerivation (finalAttrs: { version = "1.2.1"; src = fetchFromGitHub { - owner = "Nvidia"; + owner = "NVIDIA"; repo = "eglexternalplatform"; - rev = finalAttrs.version; + tag = finalAttrs.version; hash = "sha256-tDKh1oSnOSG/XztHHYCwg1tDB7M6olOtJ8te+uan9ko="; }; @@ -22,11 +25,24 @@ stdenv.mkDerivation (finalAttrs: { ninja ]; + setupHook = replaceVars ./setup-hook.sh { + jq = lib.getExe buildPackages.jq; + sponge = lib.getExe' buildPackages.moreutils "sponge"; + }; + + strictDeps = true; + __structuredAttrs = true; + + passthru.updateScript = nix-update-script { extraArgs = [ "--use-github-releases" ]; }; + meta = { description = "EGL External Platform interface"; homepage = "https://github.com/NVIDIA/eglexternalplatform"; license = lib.licenses.mit; platforms = lib.platforms.linux ++ lib.platforms.freebsd; - maintainers = with lib.maintainers; [ hedning ]; + maintainers = with lib.maintainers; [ + hedning + ccicnce113424 + ]; }; }) diff --git a/pkgs/by-name/eg/eglexternalplatform/setup-hook.sh b/pkgs/by-name/eg/eglexternalplatform/setup-hook.sh new file mode 100644 index 000000000000..2beca684e793 --- /dev/null +++ b/pkgs/by-name/eg/eglexternalplatform/setup-hook.sh @@ -0,0 +1,43 @@ +# shellcheck shell=bash + +absolutizeIcdLibraryPath() { + local jsonFile="$1" + local libPath="$2" + + if [[ -z "$jsonFile" || -z "$libPath" ]]; then + nixErrorLog "absolutizeIcdLibraryPath: expected " + return 1 + fi + + if [[ ! -f "$jsonFile" ]]; then + nixErrorLog "absolutizeIcdLibraryPath: JSON file not found: $jsonFile" + return 1 + fi + + @jq@ --arg lib "$libPath" \ + '.ICD.library_path |= $lib + .' \ + "$jsonFile" | @sponge@ "$jsonFile" +} + +fixupEglExternalPlatformIcdJsonHook() { + case "${absolutizeEglExternalPlatformIcdJson-}" in + 1|true|yes) ;; + *) return 0 ;; + esac + + local jsonDir="$prefix/share/egl/egl_external_platform.d" + + if [[ ! -d "$jsonDir" ]]; then + return 0 + fi + + local f + for f in "$jsonDir"/*.json; do + if [[ ! -e "$f" ]]; then + continue + fi + absolutizeIcdLibraryPath "$f" "$prefix/lib/" + done +} + +fixupOutputHooks+=(fixupEglExternalPlatformIcdJsonHook)