From efcc0e27bbaeb7d3350fa53e16858f03d01d53c1 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 10 Aug 2024 13:23:58 +0900 Subject: [PATCH 1/4] anki: 24.06.2 -> 24.06.3 This doesn't have anything too interesting that I can see but might as well update to latest release if we're going to rebuild --- pkgs/games/anki/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 88e4bfa8f470..5903ec1b5665 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -28,14 +28,14 @@ let pname = "anki"; - version = "24.06.2"; - rev = "33a923797afc9655c3b4f79847e1705a1f998d03"; + version = "24.06.3"; + rev = "d678e39350a2d243242a69f4e22f5192b04398f2"; src = fetchFromGitHub { owner = "ankitects"; repo = "anki"; rev = version; - hash = "sha256-jn8MxyDPVk36neHyiuvwOQQ+x7x4JPOR8BnNutTRmnY="; + hash = "sha256-ap8WFDDSGonk5kgXXIsADwAwd7o6Nsy6Wxsa7r1iUIM="; fetchSubmodules = true; }; @@ -50,7 +50,7 @@ let yarnOfflineCache = fetchYarnDeps { yarnLock = "${src}/yarn.lock"; - hash = "sha256-wyrVoaDdCkSe5z6C7EAw04G87s6tQ1cfc2d6ygGU0DM="; + hash = "sha256-Dbd7RtE0td7li7oqPPfBmAsbXPM8ed9NTAhM5gytpG8="; }; anki-build-python = python3.withPackages (ps: with ps; [ From f1389c6db114cd863b9b017f9fe36c2bbd107391 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 10 Aug 2024 13:32:46 +0900 Subject: [PATCH 2/4] anki: fix for rust 1.80 rust 1.80 requires updating the 'time' crate to at least 0.3.35. That update is already in anki's master branch but it isn't anywhere close to time for a new release, so just bump time and only time manually for our tree. (This also fixes anki-sync-server which usese the same sources/Cargo deps, when removing the patch during the next update it will need to be removed from both files as written in comment) Link: https://github.com/NixOS/nixpkgs/issues/332957 --- pkgs/games/anki/Cargo.lock | 8 ++-- pkgs/games/anki/default.nix | 2 + ...Cargo.lock-update-time-for-rust-1.80.patch | 40 +++++++++++++++++++ pkgs/games/anki/sync-server.nix | 4 ++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 pkgs/games/anki/patches/Cargo.lock-update-time-for-rust-1.80.patch diff --git a/pkgs/games/anki/Cargo.lock b/pkgs/games/anki/Cargo.lock index 9219317f2cea..17fb6f4a894c 100644 --- a/pkgs/games/anki/Cargo.lock +++ b/pkgs/games/anki/Cargo.lock @@ -5581,9 +5581,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -5602,9 +5602,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 5903ec1b5665..e7684b25e636 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -130,6 +130,8 @@ python3.pkgs.buildPythonApplication { ./patches/disable-auto-update.patch ./patches/remove-the-gl-library-workaround.patch ./patches/skip-formatting-python-code.patch + # Also remove from anki/sync-server.nix on next update + ./patches/Cargo.lock-update-time-for-rust-1.80.patch ]; inherit cargoDeps yarnOfflineCache; diff --git a/pkgs/games/anki/patches/Cargo.lock-update-time-for-rust-1.80.patch b/pkgs/games/anki/patches/Cargo.lock-update-time-for-rust-1.80.patch new file mode 100644 index 000000000000..58b6fc6f8d63 --- /dev/null +++ b/pkgs/games/anki/patches/Cargo.lock-update-time-for-rust-1.80.patch @@ -0,0 +1,40 @@ +From 66d9c405bfe7cb431cc52a7aec038068b364f034 Mon Sep 17 00:00:00 2001 +From: Dominique Martinet +Date: Sat, 10 Aug 2024 13:05:26 +0900 +Subject: [PATCH] Cargo.lock: update time for rust 1.80 + +--- + Cargo.lock | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Cargo.lock b/Cargo.lock +index 9219317f2cea..17fb6f4a894c 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -5581,9 +5581,9 @@ dependencies = [ + + [[package]] + name = "time" +-version = "0.3.34" ++version = "0.3.36" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" ++checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" + dependencies = [ + "deranged", + "itoa", +@@ -5602,9 +5602,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + + [[package]] + name = "time-macros" +-version = "0.2.17" ++version = "0.2.18" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" ++checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" + dependencies = [ + "num-conv", + "time-core", +-- +2.45.2 + diff --git a/pkgs/games/anki/sync-server.nix b/pkgs/games/anki/sync-server.nix index 248d3f34a06a..5900016c0b2b 100644 --- a/pkgs/games/anki/sync-server.nix +++ b/pkgs/games/anki/sync-server.nix @@ -13,6 +13,10 @@ rustPlatform.buildRustPackage { pname = "anki-sync-server"; inherit (anki) version src cargoLock; + patches = [ + ./patches/Cargo.lock-update-time-for-rust-1.80.patch + ]; + # only build sync server cargoBuildFlags = [ "--bin" From b3fe728bdc9a822957ee4968f0e6f0e08460f5e0 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 10 Aug 2024 13:39:36 +0900 Subject: [PATCH 3/4] anki: format with nixfmt-rfc-style --- pkgs/games/anki/default.nix | 223 +++++++++++++++++++----------------- 1 file changed, 120 insertions(+), 103 deletions(-) diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index e7684b25e636..452dc77c468b 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -1,29 +1,30 @@ -{ lib -, stdenv +{ + lib, + stdenv, -, buildEnv -, cargo -, fetchFromGitHub -, fetchYarnDeps -, installShellFiles -, lame -, mpv-unwrapped -, ninja -, nixosTests -, nodejs -, nodejs-slim -, fixup-yarn-lock -, protobuf -, python3 -, qt6 -, rsync -, rustPlatform -, writeShellScriptBin -, yarn + buildEnv, + cargo, + fetchFromGitHub, + fetchYarnDeps, + installShellFiles, + lame, + mpv-unwrapped, + ninja, + nixosTests, + nodejs, + nodejs-slim, + fixup-yarn-lock, + protobuf, + python3, + qt6, + rsync, + rustPlatform, + writeShellScriptBin, + yarn, -, AVKit -, CoreAudio -, swift + AVKit, + CoreAudio, + swift, }: let @@ -53,9 +54,7 @@ let hash = "sha256-Dbd7RtE0td7li7oqPPfBmAsbXPM8ed9NTAhM5gytpG8="; }; - anki-build-python = python3.withPackages (ps: with ps; [ - mypy-protobuf - ]); + anki-build-python = python3.withPackages (ps: with ps; [ mypy-protobuf ]); # anki shells out to git to check its revision, and also to update submodules # We don't actually need the submodules, so we stub that out @@ -122,7 +121,11 @@ in python3.pkgs.buildPythonApplication { inherit pname version; - outputs = [ "out" "doc" "man" ]; + outputs = [ + "out" + "doc" + "man" + ]; inherit src; @@ -154,63 +157,70 @@ python3.pkgs.buildPythonApplication { qt6.qtsvg ] ++ lib.optional stdenv.isLinux qt6.qtwayland; - propagatedBuildInputs = with python3.pkgs; [ - # This rather long list came from running: - # grep --no-filename -oE "^[^ =]*" python/{requirements.base.txt,requirements.bundle.txt,requirements.qt6_lin.txt} | \ - # sort | uniq | grep -v "^#$" - # in their repo at the git tag for this version - # There's probably a more elegant way, but the above extracted all the - # names, without version numbers, of their python dependencies. The hope is - # that nixpkgs versions are "close enough" - # I then removed the ones the check phase failed on (pythonCatchConflictsPhase) - attrs - beautifulsoup4 - blinker - build - certifi - charset-normalizer - click - colorama - decorator - flask - flask-cors - google-api-python-client - idna - importlib-metadata - itsdangerous - jinja2 - jsonschema - markdown - markupsafe - orjson - packaging - pip - pip-system-certs - pip-tools - protobuf - pyproject-hooks - pyqt6 - pyqt6-sip - pyqt6-webengine - pyrsistent - pysocks - requests - send2trash - setuptools - soupsieve - tomli - urllib3 - waitress - werkzeug - wheel - wrapt - zipp - ] ++ lib.optionals stdenv.isDarwin [ - AVKit - CoreAudio - ]; + propagatedBuildInputs = + with python3.pkgs; + [ + # This rather long list came from running: + # grep --no-filename -oE "^[^ =]*" python/{requirements.base.txt,requirements.bundle.txt,requirements.qt6_lin.txt} | \ + # sort | uniq | grep -v "^#$" + # in their repo at the git tag for this version + # There's probably a more elegant way, but the above extracted all the + # names, without version numbers, of their python dependencies. The hope is + # that nixpkgs versions are "close enough" + # I then removed the ones the check phase failed on (pythonCatchConflictsPhase) + attrs + beautifulsoup4 + blinker + build + certifi + charset-normalizer + click + colorama + decorator + flask + flask-cors + google-api-python-client + idna + importlib-metadata + itsdangerous + jinja2 + jsonschema + markdown + markupsafe + orjson + packaging + pip + pip-system-certs + pip-tools + protobuf + pyproject-hooks + pyqt6 + pyqt6-sip + pyqt6-webengine + pyrsistent + pysocks + requests + send2trash + setuptools + soupsieve + tomli + urllib3 + waitress + werkzeug + wheel + wrapt + zipp + ] + ++ lib.optionals stdenv.isDarwin [ + AVKit + CoreAudio + ]; - nativeCheckInputs = with python3.pkgs; [ pytest mock astroid ]; + nativeCheckInputs = with python3.pkgs; [ + pytest + mock + astroid + ]; # tests fail with to many open files # TODO: verify if this is still true (I can't, no mac) @@ -252,25 +262,29 @@ python3.pkgs.buildPythonApplication { ''; # mimic https://github.com/ankitects/anki/blob/76d8807315fcc2675e7fa44d9ddf3d4608efc487/build/ninja_gen/src/python.rs#L232-L250 - checkPhase = let - disabledTestsString = lib.pipe [ - # assumes / is not writeable, somehow fails on nix-portable brwap - "test_create_open" - ] [ - (lib.map (test: "not ${test}")) - (lib.concatStringsSep " and ") - lib.escapeShellArg - ]; - - in '' - runHook preCheck - HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \ - pytest -p no:cacheprovider pylib/tests -k ${disabledTestsString} - HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib:$PWD/pylib:$PWD/out/qt \ - pytest -p no:cacheprovider qt/tests -k ${disabledTestsString} - runHook postCheck - ''; + checkPhase = + let + disabledTestsString = + lib.pipe + [ + # assumes / is not writeable, somehow fails on nix-portable brwap + "test_create_open" + ] + [ + (lib.map (test: "not ${test}")) + (lib.concatStringsSep " and ") + lib.escapeShellArg + ]; + in + '' + runHook preCheck + HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \ + pytest -p no:cacheprovider pylib/tests -k ${disabledTestsString} + HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib:$PWD/pylib:$PWD/out/qt \ + pytest -p no:cacheprovider qt/tests -k ${disabledTestsString} + runHook postCheck + ''; preInstall = '' mkdir dist @@ -316,7 +330,10 @@ python3.pkgs.buildPythonApplication { homepage = "https://apps.ankiweb.net"; license = licenses.agpl3Plus; platforms = platforms.mesaPlatforms; - maintainers = with maintainers; [ euank oxij ]; + maintainers = with maintainers; [ + euank + oxij + ]; # Reported to crash at launch on darwin (as of 2.1.65) broken = stdenv.isDarwin; }; From 25ab2f0fe783e03a25141a571cc0dbd86a251ff2 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 13 Aug 2024 15:07:09 +0900 Subject: [PATCH 4/4] anki: skip flaky tests --- pkgs/games/anki/default.nix | 7 +++++++ pkgs/games/anki/sync-server.nix | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 452dc77c468b..6abe8ea7c9e1 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -226,6 +226,13 @@ python3.pkgs.buildPythonApplication { # TODO: verify if this is still true (I can't, no mac) doCheck = !stdenv.isDarwin; + checkFlags = [ + # these two tests are flaky, see https://github.com/ankitects/anki/issues/3353 + # Also removed from anki-sync-server when removing this. + "--skip=media::check::test::unicode_normalization" + "--skip=scheduler::answering::test::state_application" + ]; + dontUseNinjaInstall = false; dontWrapQtApps = true; diff --git a/pkgs/games/anki/sync-server.nix b/pkgs/games/anki/sync-server.nix index 5900016c0b2b..8dc73e405afd 100644 --- a/pkgs/games/anki/sync-server.nix +++ b/pkgs/games/anki/sync-server.nix @@ -23,6 +23,13 @@ rustPlatform.buildRustPackage { "anki-sync-server" ]; + checkFlags = [ + # these two tests are flaky, see https://github.com/ankitects/anki/issues/3353 + # Also removed from anki when removing this. + "--skip=media::check::test::unicode_normalization" + "--skip=scheduler::answering::test::state_application" + ]; + nativeBuildInputs = [ protobuf pkg-config ]; buildInputs = [