summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ko/koito/package.nix
blob: 1b088365b8f8f1c496d3ee5799ae6f8abdc0db9f (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
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  callPackage,
  pkg-config,
  vips,
  makeWrapper,
  nixosTests,
}:
buildGoModule (finalAttrs: {
  pname = "koito";
  version = "0.3.2";
  src = fetchFromGitHub {
    owner = "gabehf";
    repo = "koito";
    rev = "v${finalAttrs.version}";
    hash = "sha256-68+Z4Alzu+4v/PxU1IOboqZkF1pO+y6gswuO+HPS7dk=";
  };
  __structuredAttrs = true;

  vendorHash = "sha256-W/+ByBlEPd4yIUD/E28q93fz6wYgvhwyBvJL8Fm1lNY=";

  nativeBuildInputs = [
    pkg-config
    makeWrapper
  ];

  buildInputs = [ vips ];

  ldflags = [
    "-s"
    "-w"
    "-X main.Version=${finalAttrs.version}"
  ];

  postInstall = ''
    mv $out/bin/api $out/bin/.koito-wrapped

    mkdir -p $out/share
    cp -r --no-preserve=mode ${finalAttrs.passthru.client}/client $out/share/client

    makeWrapper $out/bin/.koito-wrapped $out/bin/koito \
      --run "cd $out/share"
  '';

  passthru = {
    client = callPackage ./client.nix {
      inherit (finalAttrs) src version;
    };

    tests = {
      inherit (nixosTests) koito;
    };

    updateScript = ./update.sh;
  };

  meta = {
    description = "Modern, themeable scrobbler that you can use with any program that scrobbles to a custom ListenBrainz URL";
    homepage = "https://koito.io";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ iv-nn ];
    mainProgram = "koito";
  };
})