summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/anki-audio/default.nix
blob: 05badedf80012b9f7d780670d953e69c59537f67 (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
47
48
49
50
51
52
53
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  stdenv,
  hatchling,
  mpv-unwrapped,
  lame,
}:

buildPythonPackage (finalAttrs: {
  pname = "anki-audio";
  version = "0.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "ankitects";
    repo = "anki-bundle-extras";
    rev = "e83c6e64dcb110ed579fc78afbb4e72bed8fb9e9";
    hash = "sha256-iOAZ7EytEVpvsrnVFk6bkiU8FWf2Q7tTzJjawZQCW6E=";
  };

  build-system = [ hatchling ];

  env = {
    ANKI_AUDIO_TARGET_OS = "darwin";
    ANKI_AUDIO_TARGET_ARCH = stdenv.hostPlatform.darwinArch;
  };

  preBuild =
    let
      archDir = if stdenv.hostPlatform.isAarch64 then "arm64" else "amd64";
    in
    ''
      mkdir -p mac/${archDir}/dist/audio/Resources
      ln -s ${lib.getExe mpv-unwrapped} ${lib.getExe lame} mac/${archDir}/dist/audio/Resources/
    '';

  pythonImportsCheck = [ "anki_audio" ];

  meta = {
    description = "Audio binaries (mpv, lame) for Anki";
    homepage = "https://github.com/ankitects/anki-bundle-extras";
    sourceProvenance = with lib.sourceTypes; [ fromSource ];
    platforms = lib.platforms.darwin;
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [
      euank
      junestepp
      oxij
    ];
  };
})