about summary refs log tree commit diff
path: root/pkgs/by-name/ar/artalk/package.nix
blob: ff2e0be2abdcc9b6c615e0c65e3c70b031ead8b6 (plain) (blame)
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
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  artalk,
  fetchurl,
  installShellFiles,
  stdenv,
  testers,
}:
buildGoModule rec {
  pname = "artalk";
  version = "2.8.7";

  src = fetchFromGitHub {
    owner = "ArtalkJS";
    repo = "artalk";
    rev = "refs/tags/v${version}";
    hash = "sha256-fOuZiFomXGvRUXkpEM3BpJyMOtSm6/RHd0a7dPOsoT4=";
  };
  web = fetchurl {
    url = "https://github.com/${src.owner}/${src.repo}/releases/download/v${version}/artalk_ui.tar.gz";
    hash = "sha256-3Rg5mCFigLkZ+X8Fxe6A16THd9j6hcTYMEAKU1SrLMw=";
  };

  CGO_ENABLED = 1;

  vendorHash = "sha256-Hm388ub/ja3PuSRqPkr6A+pgKUQ+czMj1WKU8W8H5wI=";

  ldflags = [
    "-s"
    "-w"
    "-X github.com/ArtalkJS/Artalk/internal/config.Version=${version}"
    "-X github.com/ArtalkJS/Artalk/internal/config.CommitHash=${version}"
  ];

  preBuild = ''
    tar -xzf ${web}
    cp -r ./artalk_ui/* ./public
  '';

  nativeBuildInputs = [ installShellFiles ];

  postInstall =
    ''
      # work around case insensitive file systems
      mv $out/bin/Artalk $out/bin/artalk.tmp
      mv $out/bin/artalk.tmp $out/bin/artalk
    ''
    + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      installShellCompletion --cmd artalk \
        --bash <($out/bin/artalk completion bash) \
        --fish <($out/bin/artalk completion fish) \
        --zsh <($out/bin/artalk completion zsh)
    '';

  passthru.tests = {
    version = testers.testVersion { package = artalk; };
  };

  meta = {
    description = "Self-hosted comment system";
    homepage = "https://github.com/ArtalkJS/Artalk";
    changelog = "https://github.com/ArtalkJS/Artalk/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ moraxyc ];
    mainProgram = "artalk";
  };
}