summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ko/kotonoha/package.nix
blob: 3229209899aaad656c61b022551975a03a187953 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
  lib,
  cmake,
  desktop-file-utils,
  fetchFromGitHub,
  kdePackages,
  ninja,
  pkg-config,
  python3Packages,
  qt6,
  wayland,
  wayland-scanner,
}:

python3Packages.buildPythonApplication (finalAttrs: {
  pname = "kotonoha";
  version = "0.2.1";
  pyproject = true;
  __structuredAttrs = true;

  src = fetchFromGitHub {
    owner = "locez";
    repo = "kotonoha";
    tag = "v${finalAttrs.version}";
    hash = "sha256-vym24/K7K4vVFzGnNTCasLkZirsqLRuMNe+vtlDglPQ=";
  };

  build-system = [ python3Packages.scikit-build-core ];

  nativeBuildInputs = [
    cmake
    ninja
    pkg-config
    qt6.wrapQtAppsHook
    wayland-scanner
  ];

  buildInputs = [
    kdePackages.layer-shell-qt
    qt6.qtbase
    qt6.qtsvg
    qt6.qtwayland
    wayland
  ];

  dependencies = with python3Packages; [
    aiohttp
    dbus-fast
    mutagen
    pyqt6
    qasync
  ];

  # scikit-build-core owns the CMake configure/build lifecycle for the wheel.
  dontUseCmakeConfigure = true;
  cmakeFlags = [
    (lib.cmakeFeature "KOTONOHA_INSTALL_DIR" "kotonoha")
    (lib.cmakeBool "KOTONOHA_INSTALL_LICENSE" false)
  ];

  postInstall = ''
    install -Dm644 packaging/kotonoha.desktop \
      "$out/share/applications/kotonoha.desktop"
    install -Dm644 src/kotonoha/assets/icon.png \
      "$out/share/icons/hicolor/1024x1024/apps/kotonoha.png"
    install -Dm644 packaging/dev.locez.kotonoha.metainfo.xml \
      "$out/share/metainfo/dev.locez.kotonoha.metainfo.xml"
    install -Dm644 packaging/kotonoha.1 \
      "$out/share/man/man1/kotonoha.1"
  '';

  # Pass Qt's wrapper arguments to Python's generated launcher directly.
  # This avoids wrapping the same script a second time.
  dontWrapQtApps = true;
  preFixup = ''
    makeWrapperArgs+=("''${qtWrapperArgs[@]}")
  '';

  pythonImportsCheck = [
    "kotonoha"
    "kotonoha.platform.native"
    "PyQt6.QtCore"
    "PyQt6.QtSvg"
  ];

  nativeCheckInputs = [ desktop-file-utils ];
  doCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck

    test -x "$out/bin/kotonoha"
    test -f "$out/${python3Packages.python.sitePackages}/kotonoha/libkoto-layer.so"
    desktop-file-validate "$out/share/applications/kotonoha.desktop"
    "$out/bin/kotonoha" --help > /dev/null

    runHook postInstallCheck
  '';

  meta = {
    description = "Linux desktop lyrics overlay for MPRIS players";
    homepage = "https://github.com/locez/kotonoha";
    changelog = "https://github.com/locez/kotonoha/releases/tag/v${finalAttrs.version}";
    license = with lib.licenses; [
      lgpl21Plus
      mit
    ];
    maintainers = with lib.maintainers; [ _27Aaron ];
    mainProgram = "kotonoha";
    platforms = lib.platforms.linux;
  };
})