Merge pull request #252981 from paveloom/anki

anki: 2.1.65 -> 2.1.66 + refactor
This commit is contained in:
Weijia Wang 2023-09-05 23:54:32 +02:00 committed by GitHub
commit a0fa1b765f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 769 additions and 821 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,11 @@
{ lib { lib
, stdenv , stdenv
, buildEnv , buildEnv
, cargo
, fetchFromGitHub , fetchFromGitHub
, fetchYarnDeps , fetchYarnDeps
, fixup_yarn_lock , fixup_yarn_lock
, cargo
, installShellFiles , installShellFiles
, lame , lame
, mpv-unwrapped , mpv-unwrapped
@ -18,25 +19,25 @@
, rustPlatform , rustPlatform
, writeShellScriptBin , writeShellScriptBin
, yarn , yarn
, swift
, AVKit , AVKit
, CoreAudio , CoreAudio
, swift
}: }:
let let
pname = "anki"; pname = "anki";
version = "2.1.65"; version = "2.1.66";
rev = "aa9a734f695d0b0981aa3c0aaa2745ce86832f08"; rev = "70506aeb99d4afbe73321feaf75a2fabaa011d55";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "ankitects"; owner = "ankitects";
repo = "anki"; repo = "anki";
rev = version; rev = version;
hash = "sha256-l+RTot8pJFJDDiapmQdKJ9WfwAuwRFiNJMbX+fBETeU="; hash = "sha256-eE64i/jTMvipakbQXzKu/dN+dyim7E4M+eP3d9GZhII=";
fetchSubmodules = true; fetchSubmodules = true;
}; };
cargoDeps = rustPlatform.importCargoLock { cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
outputHashes = { outputHashes = {
@ -46,6 +47,11 @@ let
}; };
}; };
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-3DUiwGTg7Nzd+bPJlc8aUW8bYrl7BF+CcjqkF6nW0qc=";
};
anki-build-python = python3.withPackages (ps: with ps; [ anki-build-python = python3.withPackages (ps: with ps; [
mypy-protobuf mypy-protobuf
]); ]);
@ -87,20 +93,16 @@ let
pathsToLink = [ "/bin" ]; pathsToLink = [ "/bin" ];
}; };
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-66mYsHojQQBfLTHd12+/HEf7FKF5Y2RZRFeYRS2yZco=";
};
# https://discourse.nixos.org/t/mkyarnpackage-lockfile-has-incorrect-entry/21586/3 # https://discourse.nixos.org/t/mkyarnpackage-lockfile-has-incorrect-entry/21586/3
anki-nodemodules = stdenv.mkDerivation { anki-nodemodules = stdenv.mkDerivation {
pname = "anki-nodemodules"; pname = "anki-nodemodules";
inherit version src yarnOfflineCache; inherit version src yarnOfflineCache;
nativeBuildInputs = [ nativeBuildInputs = [
fixup_yarn_lock fixup_yarn_lock
yarn
nodejs-slim nodejs-slim
yarn
]; ];
configurePhase = '' configurePhase = ''
@ -109,7 +111,6 @@ let
fixup_yarn_lock yarn.lock fixup_yarn_lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/ patchShebangs node_modules/
yarn run postinstall --offline
''; '';
installPhase = '' installPhase = ''
@ -118,35 +119,37 @@ let
}; };
in in
python3.pkgs.buildPythonApplication { python3.pkgs.buildPythonApplication {
inherit pname version src; inherit pname version;
outputs = [ "out" "doc" "man" ]; outputs = [ "doc" "man" "out" ];
inherit src;
patches = [ patches = [
./patches/gl-fixup.patch ./patches/gl-fixup.patch
./patches/no-update-check.patch ./patches/no-update-check.patch
./patches/0001-Skip-formatting-python-code.patch ./patches/skip-formatting-python-code.patch
]; ];
inherit cargoDeps; inherit cargoDeps yarnOfflineCache;
nativeBuildInputs = [ nativeBuildInputs = [
fakeGit fakeGit
fixup_yarn_lock fixup_yarn_lock
offlineYarn offlineYarn
installShellFiles
cargo cargo
rustPlatform.cargoSetupHook installShellFiles
ninja ninja
qt6.wrapQtAppsHook qt6.wrapQtAppsHook
rsync rsync
rustPlatform.cargoSetupHook
] ++ lib.optional stdenv.isDarwin swift; ] ++ lib.optional stdenv.isDarwin swift;
nativeCheckInputs = with python3.pkgs; [ pytest mock astroid ];
buildInputs = [ buildInputs = [
qt6.qtbase qt6.qtbase
] ++ lib.optional stdenv.isLinux qt6.qtwayland; ] ++ lib.optional stdenv.isLinux qt6.qtwayland;
propagatedBuildInputs = with python3.pkgs; [ propagatedBuildInputs = with python3.pkgs; [
# This rather long list came from running: # This rather long list came from running:
# grep --no-filename -oE "^[^ =]*" python/{requirements.base.txt,requirements.bundle.txt,requirements.qt6_4.txt} | \ # grep --no-filename -oE "^[^ =]*" python/{requirements.base.txt,requirements.bundle.txt,requirements.qt6_4.txt} | \
@ -174,13 +177,13 @@ python3.pkgs.buildPythonApplication {
markupsafe markupsafe
orjson orjson
pep517 pep517
python3.pkgs.protobuf
pyparsing pyparsing
pyqt6 pyqt6
pyqt6-sip pyqt6-sip
pyqt6-webengine pyqt6-webengine
pyrsistent pyrsistent
pysocks pysocks
python3.pkgs.protobuf
requests requests
send2trash send2trash
six six
@ -194,23 +197,30 @@ python3.pkgs.buildPythonApplication {
CoreAudio CoreAudio
]; ];
# Activate optimizations nativeCheckInputs = with python3.pkgs; [ pytest mock astroid ];
RELEASE = true;
PROTOC_BINARY = lib.getExe protobuf; # tests fail with to many open files
NODE_BINARY = lib.getExe nodejs; # TODO: verify if this is still true (I can't, no mac)
YARN_BINARY = lib.getExe offlineYarn; doCheck = !stdenv.isDarwin;
PYTHON_BINARY = lib.getExe python3;
inherit yarnOfflineCache;
dontUseNinjaInstall = false; dontUseNinjaInstall = false;
dontWrapQtApps = true;
env = {
# Activate optimizations
RELEASE = true;
NODE_BINARY = lib.getExe nodejs;
PROTOC_BINARY = lib.getExe protobuf;
PYTHON_BINARY = lib.getExe python3;
YARN_BINARY = lib.getExe offlineYarn;
};
buildPhase = '' buildPhase = ''
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
export RUST_LOG=debug export RUST_LOG=debug
mkdir -p out/pylib/anki \ mkdir -p out/pylib/anki .git
.git
echo ${builtins.substring 0 8 rev} > out/buildhash echo ${builtins.substring 0 8 rev} > out/buildhash
touch out/env touch out/env
@ -228,9 +238,6 @@ python3.pkgs.buildPythonApplication {
PIP_USER=1 ./ninja build wheels PIP_USER=1 ./ninja build wheels
''; '';
# tests fail with to many open files
# TODO: verify if this is still true (I can't, no mac)
doCheck = !stdenv.isDarwin;
# mimic https://github.com/ankitects/anki/blob/76d8807315fcc2675e7fa44d9ddf3d4608efc487/build/ninja_gen/src/python.rs#L232-L250 # mimic https://github.com/ankitects/anki/blob/76d8807315fcc2675e7fa44d9ddf3d4608efc487/build/ninja_gen/src/python.rs#L232-L250
checkPhase = '' checkPhase = ''
HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \ HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \
@ -252,7 +259,6 @@ python3.pkgs.buildPythonApplication {
installManPage qt/bundle/lin/anki.1 installManPage qt/bundle/lin/anki.1
''; '';
dontWrapQtApps = true;
preFixup = '' preFixup = ''
makeWrapperArgs+=( makeWrapperArgs+=(
"''${qtWrapperArgs[@]}" "''${qtWrapperArgs[@]}"
@ -261,7 +267,6 @@ python3.pkgs.buildPythonApplication {
''; '';
meta = with lib; { meta = with lib; {
homepage = "https://apps.ankiweb.net/";
description = "Spaced repetition flashcard program"; description = "Spaced repetition flashcard program";
longDescription = '' longDescription = ''
Anki is a program which makes remembering things easy. Because it is a lot Anki is a program which makes remembering things easy. Because it is a lot
@ -275,9 +280,10 @@ python3.pkgs.buildPythonApplication {
people's names and faces, brushing up on geography, mastering long poems, people's names and faces, brushing up on geography, mastering long poems,
or even practicing guitar chords! or even practicing guitar chords!
''; '';
homepage = "https://apps.ankiweb.net";
license = licenses.agpl3Plus; license = licenses.agpl3Plus;
platforms = platforms.mesaPlatforms; platforms = platforms.mesaPlatforms;
maintainers = with maintainers; [ oxij euank ]; maintainers = with maintainers; [ euank oxij paveloom ];
# Reported to crash at launch on darwin (as of 2.1.65) # Reported to crash at launch on darwin (as of 2.1.65)
broken = stdenv.isDarwin; broken = stdenv.isDarwin;
}; };