summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/anki-mac-helper/default.nix
blob: 9197c5e2cdad7e969fd57c5b01c204bd76073785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
  lib,
  buildPythonPackage,
  stdenv,
  anki,
  hatchling,
  swift,
}:

buildPythonPackage (finalAttrs: {
  pname = "anki-mac-helper";
  inherit (anki) version src;
  pyproject = true;

  sourceRoot = "${finalAttrs.src.name}/qt/mac";

  build-system = [ hatchling ];
  nativeBuildInputs = [ swift ];

  # This is intended to emulate github:ankitects/anki/qt/mac/helper_build.py,
  # but targets the platform directly instead of universal binary + lipo.
  preBuild = ''
    swiftc \
      -target ${stdenv.hostPlatform.darwinArch}-apple-macos11 \
      -emit-library \
      -module-name ankihelper \
      -O \
      *.swift \
      -o anki_mac_helper/libankihelper.dylib
  '';

  pythonImportsCheck = [ "anki_mac_helper" ];

  meta = {
    description = "Small support library for Anki on Macs";
    homepage = "https://github.com/ankitects/anki";
    sourceProvenance = with lib.sourceTypes; [ fromSource ];
    platforms = lib.platforms.darwin;
    license = lib.licenses.agpl3Plus;
    maintainers = with lib.maintainers; [
      euank
      junestepp
      oxij
    ];
  };
})