From 0467f6d76f4229ce8bba099b3755087c5f6a1c83 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Sat, 25 Feb 2023 14:00:05 +0900 Subject: [PATCH] anki-bin: set correct name and version for derivation anki-bin is built with buildFHSUserEnv on Linux, which doesn't set a version for the resulting derivation. This commit overrides the resulting derivation to have a version set correctly. This is important for end-users to be able to easily tell what version of Anki they will get when they install `anki-bin`. It is normally very important to use the correct version of Anki. --- pkgs/games/anki/bin.nix | 51 +++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/pkgs/games/anki/bin.nix b/pkgs/games/anki/bin.nix index 38d67cb6217..c2a988d1687 100644 --- a/pkgs/games/anki/bin.nix +++ b/pkgs/games/anki/bin.nix @@ -49,28 +49,39 @@ let }; passthru = { inherit sources; }; + + fhsUserEnvAnki = buildFHSUserEnv (appimageTools.defaultFhsEnvArgs // { + name = "anki"; + + # Dependencies of anki + targetPkgs = pkgs: (with pkgs; [ xorg.libxkbfile krb5 ]); + + runScript = writeShellScript "anki-wrapper.sh" '' + exec ${unpacked}/bin/anki + ''; + + extraInstallCommands = '' + mkdir -p $out/share + cp -R ${unpacked}/share/applications \ + ${unpacked}/share/man \ + ${unpacked}/share/pixmaps \ + $out/share/ + ''; + + inherit meta passthru; + }); + + fhsUserEnvAnkiWithVersion = fhsUserEnvAnki.overrideAttrs (oldAttrs: { + # buildFHSUserEnv doesn't have an easy way to set the version of the + # resulting derivation, so we manually override it here. This makes + # it clear to end users the version of anki-bin. Without this, users + # might assume anki-bin is an old version of Anki. + name = "${pname}-${version}"; + }); in -if stdenv.isLinux then buildFHSUserEnv (appimageTools.defaultFhsEnvArgs // { - name = "anki"; - - # Dependencies of anki - targetPkgs = pkgs: (with pkgs; [ xorg.libxkbfile krb5 ]); - - runScript = writeShellScript "anki-wrapper.sh" '' - exec ${unpacked}/bin/anki - ''; - - extraInstallCommands = '' - mkdir -p $out/share - cp -R ${unpacked}/share/applications \ - ${unpacked}/share/man \ - ${unpacked}/share/pixmaps \ - $out/share/ - ''; - - inherit meta passthru; -}) else stdenv.mkDerivation { +if stdenv.isLinux then fhsUserEnvAnkiWithVersion +else stdenv.mkDerivation { inherit pname version passthru; src = if stdenv.isAarch64 then sources.darwin-aarch64 else sources.darwin-x86_64;