Commit b3fe728b authored by Dominique Martinet's avatar Dominique Martinet
Browse files

anki: format with nixfmt-rfc-style

parent f1389c6d
Loading
Loading
Loading
Loading
+123 −106
Original line number Diff line number Diff line
{ 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

, AVKit
, CoreAudio
, swift
{
  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,

  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,7 +157,9 @@ python3.pkgs.buildPythonApplication {
    qt6.qtsvg
  ] ++ lib.optional stdenv.isLinux qt6.qtwayland;

  propagatedBuildInputs = with python3.pkgs; [
  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 "^#$"
@@ -205,12 +210,17 @@ python3.pkgs.buildPythonApplication {
      wheel
      wrapt
      zipp
  ] ++ lib.optionals stdenv.isDarwin [
    ]
    ++ 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,17 +262,22 @@ python3.pkgs.buildPythonApplication {
  '';

  # mimic https://github.com/ankitects/anki/blob/76d8807315fcc2675e7fa44d9ddf3d4608efc487/build/ninja_gen/src/python.rs#L232-L250
  checkPhase = let
    disabledTestsString = lib.pipe [
  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 ''
    in
    ''
      runHook preCheck
      HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \
        pytest -p no:cacheprovider pylib/tests -k ${disabledTestsString}
@@ -271,7 +286,6 @@ python3.pkgs.buildPythonApplication {
      runHook postCheck
    '';


  preInstall = ''
    mkdir dist
    mv out/wheels/* 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;
  };