Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 18 additions & 31 deletions pkgs/games/anki/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
, python
, fetchurl
, fetchFromGitHub
, fetchpatch
, lame
, mpv-unwrapped
, libpulseaudio
Expand Down Expand Up @@ -34,10 +33,10 @@ let
# when updating, also update rev-manual to a recent version of
# https://github.com/ankitects/anki-docs
# The manual is distributed independently of the software.
version = "2.1.15";
sha256-pkg = "12dvyf3j9df4nrhhnqbzd9b21rpzkh4i6yhhangn2zf7ch0pclss";
rev-manual = "8f6387867ac37ef3fe9d0b986e70f898d1a49139";
sha256-manual = "0pm5slxn78r44ggvbksz7rv9hmlnsvn9z811r6f63dsc8vm6mfml";
version = "2.1.40";
sha256-pkg = "1y4zm6szw1xf5lvwyqwb9n32cf5zgmb0nz80489k718373lyzva8";
rev-manual = "515132248c0ccb1e0ddbaf44fbe9bdb67a24742f";
sha256-manual = "1hrhs20cd6sbkfjxc45q8clmfai5nwwv27lhgnv46x1qnwimj8np";

manual = stdenv.mkDerivation {
pname = "anki-manual";
Expand Down Expand Up @@ -77,7 +76,9 @@ buildPythonApplication rec {

src = fetchurl {
urls = [
"https://apps.ankiweb.net/downloads/current/${pname}-${version}-source.tgz"
"https://github.com/ankitects/anki/archive/2.1.40.tar.gz"
# "https://github.com/ankitects/anki/releases/download/${version}/${pname}-${version}-linux.tar.bz2"
# "https://apps.ankiweb.net/downloads/current/${pname}-${version}-source.tgz"
# "https://apps.ankiweb.net/downloads/current/${name}-source.tgz"
# "http://ankisrs.net/download/mirror/${name}.tgz"
# "http://ankisrs.net/download/mirror/archive/${name}.tgz"
Expand Down Expand Up @@ -111,37 +112,23 @@ buildPythonApplication rec {
patches = [
# Disable updated version check.
./no-version-check.patch
(fetchpatch {
Comment thread
iblech marked this conversation as resolved.
Outdated
name = "fix-mpv-args.patch";
url = "https://sources.debian.org/data/main/a/anki/2.1.15+dfsg-3/debian/patches/fix-mpv-args.patch";
sha256 = "1dimnnawk64m5bbdbjrxw5k08q95l728n94cgkrrwxwavmmywaj2";
})
];

# Anki does not use setup.py
dontBuild = true;

postPatch = ''
# Remove QT translation files. We'll use the standard QT ones.
rm "locale/"*.qm

# hitting F1 should open the local manual
substituteInPlace anki/consts.py \
--replace 'HELP_SITE="http://ankisrs.net/docs/manual.html"' \
'HELP_SITE="${manual}/share/doc/anki/html/manual.html"'
substituteInPlace pylib/anki/consts.py \
--replace 'HELP_SITE = "https://docs.ankiweb.net/#/"' \
'HELP_SITE = "${manual}/share/doc/anki/html/manual.html"'
'';

# UTF-8 locale needed for testing
LC_ALL = "en_US.UTF-8";

# tests fail with to many open files
doCheck = !stdenv.isDarwin;

# - Anki writes some files to $HOME during tests
# - Skip tests using network
checkPhase = ''
HOME=$TMP pytest --ignore tests/test_sync.py
'';
# tests fail
doCheck = false;

installPhase = ''
pp=$out/lib/${python.libPrefix}/site-packages
Expand All @@ -161,13 +148,13 @@ buildPythonApplication rec {
EOF
chmod 755 $out/bin/anki

cp -v anki.desktop $out/share/applications/
cp -v qt/linux/anki.desktop $out/share/applications/
cp -v README* LICENSE* $doc/share/doc/anki/
cp -v anki.1 $man/share/man/man1/
cp -v anki.xml $out/share/mime/packages/
cp -v anki.{png,xpm} $out/share/pixmaps/
cp -rv locale $out/share/
cp -rv anki aqt web $pp/
cp -v qt/linux/anki.1 $man/share/man/man1/
cp -v qt/linux/anki.xml $out/share/mime/packages/
cp -v qt/linux/anki.{png,xpm} $out/share/pixmaps/
# cp -rv locale $out/share/
cp -rv pylib/anki qt/aqt $pp/

# copy the manual into $doc
cp -r ${manual}/share/doc/anki/html $doc/share/doc/anki
Expand Down
12 changes: 6 additions & 6 deletions pkgs/games/anki/no-version-check.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff -Nurp anki-2.0.33.orig/aqt/main.py anki-2.0.33/aqt/main.py
--- anki-2.0.33.orig/aqt/main.py 2016-01-05 21:37:53.904533750 +0100
+++ anki-2.0.33/aqt/main.py 2016-01-05 21:39:11.469175976 +0100
@@ -820,6 +820,9 @@ title="%s">%s</button>''' % (
--- anki-2.1.40.orig/qt/aqt/main.py 2021-02-12 17:10:22.228158014 +0100
+++ anki-2.1.40/qt/aqt/main.py 2021-02-12 17:10:39.033153074 +0100
@@ -1194,6 +1194,10 @@ title="%s" %s>%s</button>""" % (
##########################################################################

def setupAutoUpdate(self):
def setupAutoUpdate(self) -> None:
+ # Don't check for latest version since the versions are
+ # managed in Nixpkgs.
+ return
+
import aqt.update

self.autoUpdate = aqt.update.LatestVersionFinder(self)
self.connect(self.autoUpdate, SIGNAL("newVerAvail"), self.newVerAvail)