From fef7e8294baa79538ebf4aae204abf836c79d831 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Wed, 31 Jan 2024 07:13:42 -0700 Subject: [PATCH] Upgrade Anki version. --- hive/framework/default.nix | 2 +- users/jrpotter/anki/anki-bin.nix | 63 +++++++++++++++++++ users/jrpotter/{anki.nix => anki/default.nix} | 19 ++---- 3 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 users/jrpotter/anki/anki-bin.nix rename users/jrpotter/{anki.nix => anki/default.nix} (80%) diff --git a/hive/framework/default.nix b/hive/framework/default.nix index bd99506..7f9d769 100644 --- a/hive/framework/default.nix +++ b/hive/framework/default.nix @@ -57,7 +57,7 @@ users.jrpotter = { pkgs, ... }: { imports = [ ../../users/jrpotter - ../../users/jrpotter/anki.nix + ../../users/jrpotter/anki ]; dconf.settings = { diff --git a/users/jrpotter/anki/anki-bin.nix b/users/jrpotter/anki/anki-bin.nix new file mode 100644 index 0000000..a94e974 --- /dev/null +++ b/users/jrpotter/anki/anki-bin.nix @@ -0,0 +1,63 @@ +{ pkgs, lib, commandLineArgs ? [] }: +let + pname = "anki-bin"; + version = "23.12.1"; + + linux = pkgs.fetchurl { + url = "https://github.com/ankitects/anki/releases/download/${version}/anki-${version}-linux-qt6.tar.zst"; + sha256 = "sha256-Kv0SH+bLnBSM/tYHe2kEJc4n7izZTBNWQs2nm/teLEU="; + }; + + unpacked = pkgs.stdenv.mkDerivation { + inherit pname version; + + nativeBuildInputs = [ pkgs.zstd ]; + src = pkgs.fetchurl { + url = "https://github.com/ankitects/anki/releases/download/${version}/anki-${version}-linux-qt6.tar.zst"; + sha256 = "sha256-Kv0SH+bLnBSM/tYHe2kEJc4n7izZTBNWQs2nm/teLEU="; + }; + + installPhase = '' + runHook preInstall + xdg-mime () { + echo Stubbed! + } + export -f xdg-mime + PREFIX=$out bash install.sh + runHook postInstall + ''; + }; + + passthru.sources = { inherit linux; }; + + meta = with lib; { + inherit (pkgs.anki.meta) license homepage description longDescription; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ mahmoudk1000 ]; + }; +in + pkgs.buildFHSEnv (pkgs.appimageTools.defaultFhsEnvArgs // { + inherit pname version; + name = null; # Appimage sets it to "appimage-env" + + targetPkgs = pkgs: (with pkgs; [ + xorg.libxkbfile + xcb-util-cursor-HEAD + krb5 + ]); + + runScript = pkgs.writeShellScript "anki-wrapper.sh" '' + exec ${unpacked}/bin/anki ${ lib.strings.escapeShellArgs commandLineArgs } "$@" + ''; + + extraInstallCommands = '' + ln -s ${pname} $out/bin/anki + mkdir -p $out/share + cp -R ${unpacked}/share/applications \ + ${unpacked}/share/man \ + ${unpacked}/share/pixmaps \ + $out/share/ + ''; + + inherit meta passthru; + }) diff --git a/users/jrpotter/anki.nix b/users/jrpotter/anki/default.nix similarity index 80% rename from users/jrpotter/anki.nix rename to users/jrpotter/anki/default.nix index 46185c0..7118c98 100644 --- a/users/jrpotter/anki.nix +++ b/users/jrpotter/anki/default.nix @@ -1,15 +1,7 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let addons = id: "Anki2/addons21/${toString id}"; - FlexibleGrading = pkgs.fetchFromGitHub { - owner = "jrpotter"; - repo = "FlexibleGrading"; - rev = "d9cd06bbb154a0740518e58e4619d3855e22c027"; - hash = "sha256-ciIVFyt7TDBeC+h5feA5I17Ld1Pge/hRDqGMMcLTJiM="; - fetchSubmodules = true; - }; - anki-connect = pkgs.stdenv.mkDerivation { name = "anki-connect"; src = pkgs.fetchFromGitea { @@ -69,11 +61,6 @@ let in { xdg.dataFile = { - "${addons 1715096333}" = { - source = FlexibleGrading; - recursive = true; # Let's addon write to directory. - }; - "${addons 2055492159}".source = anki-connect; @@ -84,5 +71,7 @@ in syntax-highlighting-ng; }; - home.packages = [ pkgs.anki-bin ]; + home.packages = [ + (import ./anki-bin.nix { inherit pkgs lib; }) + ]; }