From 28b4ffa230761a1ee2d566ac376b77f5f35efad5 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 17 Dec 2024 01:31:58 +0100 Subject: [PATCH] golden-cheetah-bin: 3.6 -> 3.7DEV2410, add darwin (#363290) * golden-cheetah-bin: format Signed-off-by: Florian Brandes * golden-cheetah-bin: 3.6 -> 3.7DEV2410 fixes CVE-2023-4863[1][2] [1]: https://github.com/GoldenCheetah/GoldenCheetah/issues/4396 [2]: https://github.com/GoldenCheetah/GoldenCheetah/commit/e8132b1a55e8e84fc5e34a4c91e3a7b2bf62cc2f * golden-cheetah-bin: fix qt startup Due to a version missmatch between the packaged Qt package from upstream and NixOS Qt version GoldenCheetah will not be able to start with the following error message on KDE: ``` qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb. ``` This is analog to other errors and is caused by a leaked QT_PLUGIN_PATH variable from the host to the AppImage[1]. Since this only causes issues on KDE it is sufficient to empty the variable from the desktop Menu item. This does not fix startup from the command line and is rather a workaround than a true bugfix and the underlying issue (leaking variables to appimageTools.wrapType2 applications) should be fixed. This does not affect other desktop environments [1]: https://discourse.nixos.org/t/cannot-run-ida-free-with-steam-run-could-not-load-the-qt-platform-plugin-xcb-in/29783 Signed-off-by: Florian Brandes * golden-cheetah-bin: add darwin version Signed-off-by: Florian Brandes --------- Signed-off-by: Florian Brandes --- pkgs/by-name/go/golden-cheetah-bin/darwin.nix | 44 +++++++++++++ pkgs/by-name/go/golden-cheetah-bin/linux.nix | 45 ++++++++++++++ .../by-name/go/golden-cheetah-bin/package.nix | 61 +++++++++---------- 3 files changed, 119 insertions(+), 31 deletions(-) create mode 100644 pkgs/by-name/go/golden-cheetah-bin/darwin.nix create mode 100644 pkgs/by-name/go/golden-cheetah-bin/linux.nix diff --git a/pkgs/by-name/go/golden-cheetah-bin/darwin.nix b/pkgs/by-name/go/golden-cheetah-bin/darwin.nix new file mode 100644 index 000000000000..da1c3976fafd --- /dev/null +++ b/pkgs/by-name/go/golden-cheetah-bin/darwin.nix @@ -0,0 +1,44 @@ +{ + fetchurl, + stdenv, + makeWrapper, + undmg, + pname, + commonMeta, + version, +}: + +stdenv.mkDerivation { + inherit + pname + version + ; + + src = fetchurl { + url = "https://github.com/GoldenCheetah/GoldenCheetah/releases/download/v${version}/GoldenCheetah_v${builtins.substring 0 7 version}_x64.dmg"; + hash = "sha256-GGe8pGf16FWqN9uaStnGOtOeKDB44VBD7QwHkaZb7wY="; + }; + + nativeBuildInputs = [ + makeWrapper + undmg + ]; + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p "$out/Applications/GoldenCheetah.app" + cp -r * "$out/Applications/GoldenCheetah.app/" + makeWrapper "$out/Applications/GoldenCheetah.app/Contents/MacOS/GoldenCheetah" "$out/bin/GoldenCheetah" + runHook postInstall + ''; + meta = { + inherit (commonMeta) + description + platforms + maintainers + license + sourceProvenance + ; + }; +} diff --git a/pkgs/by-name/go/golden-cheetah-bin/linux.nix b/pkgs/by-name/go/golden-cheetah-bin/linux.nix new file mode 100644 index 000000000000..01c5a7e71af3 --- /dev/null +++ b/pkgs/by-name/go/golden-cheetah-bin/linux.nix @@ -0,0 +1,45 @@ +{ + appimageTools, + fetchurl, + pname, + commonMeta, + version, +}: + +appimageTools.wrapType2 rec { + inherit + pname + version + ; + src = fetchurl { + url = "https://github.com/GoldenCheetah/GoldenCheetah/releases/download/v${version}/GoldenCheetah_v${builtins.substring 0 7 version}_x64.AppImage"; + hash = "sha256-S1YDg7opoYflL/3h+lP1SNwXpJHaN3+iE3waSjWtN6o="; + }; + + extraPkgs = pkgs: [ + pkgs.R + pkgs.zlib + pkgs.libusb-compat-0_1 + ]; + + appimageContents = appimageTools.extract { inherit pname src version; }; + + extraInstallCommands = '' + mv $out/bin/${pname} $out/bin/GoldenCheetah + mkdir -p $out/share/applications + mkdir -p $out/share/pixmaps + cp ${appimageContents}/GoldenCheetah.desktop $out/share/applications/ + substituteInPlace $out/share/applications/GoldenCheetah.desktop --replace-fail \ + "Exec=GoldenCheetah" "Exec=QT_PLUGIN_PATH= GoldenCheetah" + cp ${appimageContents}/gc.png $out/share/pixmaps/ + ''; + meta = { + inherit (commonMeta) + description + platforms + maintainers + license + sourceProvenance + ; + }; +} diff --git a/pkgs/by-name/go/golden-cheetah-bin/package.nix b/pkgs/by-name/go/golden-cheetah-bin/package.nix index c37e7dc72fff..a01685df7974 100644 --- a/pkgs/by-name/go/golden-cheetah-bin/package.nix +++ b/pkgs/by-name/go/golden-cheetah-bin/package.nix @@ -1,38 +1,37 @@ -{ appimageTools, lib, fetchurl, nix-update-script, stdenv }: +{ + lib, + stdenv, + callPackage, +}: + let - pname = "golden-cheetah"; - version = "3.6"; + version = "3.7-DEV2410"; - src = fetchurl { - url = "https://github.com/GoldenCheetah/GoldenCheetah/releases/download/v${version}/GoldenCheetah_v${version}_x64.AppImage"; - hash = "sha256-PMRUDQSQxbECbF9SPOo03t4Xxj1OtYJAPXEMyyy6EVY="; - }; - - appimageContents = appimageTools.extract { inherit pname src version; }; -in -appimageTools.wrapType2 { - inherit pname src version; - - extraPkgs = pkgs: [ pkgs.R pkgs.zlib pkgs.libusb-compat-0_1 ]; - - extraInstallCommands = '' - mv $out/bin/${pname} $out/bin/GoldenCheetah - mkdir -p $out/share/applications - mkdir -p $out/share/pixmaps - cp ${appimageContents}/GoldenCheetah.desktop $out/share/applications/ - cp ${appimageContents}/gc.png $out/share/pixmaps/ - ''; - - passthru.updateScript = nix-update-script { }; - - meta = { + commonMeta = { description = "Performance software for cyclists, runners and triathletes. This version includes the API Tokens for e.g. Strava"; - platforms = lib.platforms.linux; - broken = !stdenv.hostPlatform.isx86_64; - maintainers = with lib.maintainers; [ gador adamcstephens ]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + maintainers = with lib.maintainers; [ + gador + adamcstephens + ]; license = lib.licenses.gpl2Plus; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - knownVulnerabilities = [ "Vendors libwebp vulnerable to CVE-2023-4863" ]; }; -} +in + +if stdenv.hostPlatform.isDarwin then + callPackage ./darwin.nix { + inherit + stdenv + pname + commonMeta + version + ; + } +else + callPackage ./linux.nix { inherit pname commonMeta version; }