diff options
author | Pavel Sobolev <paveloom@riseup.net> | 2023-09-02 16:31:28 +0300 |
---|---|---|
committer | Pavel Sobolev <paveloom@riseup.net> | 2023-09-02 19:19:02 +0300 |
commit | aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e (patch) | |
tree | 7f6e2db731158731b720e4f65028226be00aeb74 /pkgs/games/anki/default.nix | |
parent | 818441a0cfa929adb5979c4674840aff587c053b (diff) | |
download | nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar.gz nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar.bz2 nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar.lz nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar.xz nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.tar.zst nixpkgs-aa2f2dd7df771a8c94b7f92d2ca09789e7525a1e.zip |
anki: refactor
Diffstat (limited to 'pkgs/games/anki/default.nix')
-rw-r--r-- | pkgs/games/anki/default.nix | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 18ffb1558f5..c06a4a5a2fc 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -1,10 +1,11 @@ { lib , stdenv + , buildEnv +, cargo , fetchFromGitHub , fetchYarnDeps , fixup_yarn_lock -, cargo , installShellFiles , lame , mpv-unwrapped @@ -18,9 +19,10 @@ , rustPlatform , writeShellScriptBin , yarn -, swift + , AVKit , CoreAudio +, swift }: let @@ -36,7 +38,6 @@ let fetchSubmodules = true; }; - cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; outputHashes = { @@ -46,6 +47,11 @@ let }; }; + yarnOfflineCache = fetchYarnDeps { + yarnLock = "${src}/yarn.lock"; + hash = "sha256-66mYsHojQQBfLTHd12+/HEf7FKF5Y2RZRFeYRS2yZco="; + }; + anki-build-python = python3.withPackages (ps: with ps; [ mypy-protobuf ]); @@ -87,20 +93,16 @@ let pathsToLink = [ "/bin" ]; }; - yarnOfflineCache = fetchYarnDeps { - yarnLock = "${src}/yarn.lock"; - hash = "sha256-66mYsHojQQBfLTHd12+/HEf7FKF5Y2RZRFeYRS2yZco="; - }; - # https://discourse.nixos.org/t/mkyarnpackage-lockfile-has-incorrect-entry/21586/3 anki-nodemodules = stdenv.mkDerivation { pname = "anki-nodemodules"; + inherit version src yarnOfflineCache; nativeBuildInputs = [ fixup_yarn_lock - yarn nodejs-slim + yarn ]; configurePhase = '' @@ -118,35 +120,37 @@ let }; in python3.pkgs.buildPythonApplication { - inherit pname version src; + inherit pname version; - outputs = [ "out" "doc" "man" ]; + outputs = [ "doc" "man" "out" ]; + + inherit src; patches = [ ./patches/gl-fixup.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 = [ fakeGit fixup_yarn_lock offlineYarn - installShellFiles cargo - rustPlatform.cargoSetupHook + installShellFiles ninja qt6.wrapQtAppsHook rsync + rustPlatform.cargoSetupHook ] ++ lib.optional stdenv.isDarwin swift; - nativeCheckInputs = with python3.pkgs; [ pytest mock astroid ]; buildInputs = [ qt6.qtbase ] ++ 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_4.txt} | \ @@ -174,13 +178,13 @@ python3.pkgs.buildPythonApplication { markupsafe orjson pep517 - python3.pkgs.protobuf pyparsing pyqt6 pyqt6-sip pyqt6-webengine pyrsistent pysocks + python3.pkgs.protobuf requests send2trash six @@ -194,23 +198,30 @@ python3.pkgs.buildPythonApplication { CoreAudio ]; - # Activate optimizations - RELEASE = true; + nativeCheckInputs = with python3.pkgs; [ pytest mock astroid ]; - PROTOC_BINARY = lib.getExe protobuf; - NODE_BINARY = lib.getExe nodejs; - YARN_BINARY = lib.getExe offlineYarn; - PYTHON_BINARY = lib.getExe python3; + # tests fail with to many open files + # TODO: verify if this is still true (I can't, no mac) + doCheck = !stdenv.isDarwin; - inherit yarnOfflineCache; 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 = '' export RUST_BACKTRACE=1 export RUST_LOG=debug - mkdir -p out/pylib/anki \ - .git + mkdir -p out/pylib/anki .git echo ${builtins.substring 0 8 rev} > out/buildhash touch out/env @@ -228,9 +239,6 @@ python3.pkgs.buildPythonApplication { 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 checkPhase = '' HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \ @@ -252,7 +260,6 @@ python3.pkgs.buildPythonApplication { installManPage qt/bundle/lin/anki.1 ''; - dontWrapQtApps = true; preFixup = '' makeWrapperArgs+=( "''${qtWrapperArgs[@]}" @@ -261,7 +268,6 @@ python3.pkgs.buildPythonApplication { ''; meta = with lib; { - homepage = "https://apps.ankiweb.net/"; description = "Spaced repetition flashcard program"; longDescription = '' Anki is a program which makes remembering things easy. Because it is a lot @@ -275,9 +281,10 @@ python3.pkgs.buildPythonApplication { people's names and faces, brushing up on geography, mastering long poems, or even practicing guitar chords! ''; + homepage = "https://apps.ankiweb.net"; license = licenses.agpl3Plus; 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) broken = stdenv.isDarwin; }; |