btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / ar / artalk / package.nix
blob96de91650e7b52b1bf7e14daf00a851cc0931e99
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   artalk,
6   fetchurl,
7   installShellFiles,
8   versionCheckHook,
9   stdenv,
10   testers,
11   nixosTests,
13 buildGoModule rec {
14   pname = "artalk";
15   version = "2.9.1";
17   src = fetchFromGitHub {
18     owner = "ArtalkJS";
19     repo = "artalk";
20     rev = "refs/tags/v${version}";
21     hash = "sha256-gzagE3muNpX/dwF45p11JAN9ElsGXNFQ3fCvF1QhvdU=";
22   };
23   web = fetchurl {
24     url = "https://github.com/${src.owner}/${src.repo}/releases/download/v${version}/artalk_ui.tar.gz";
25     hash = "sha256-ckKC4lErKVdJuJ+pGysmMR96a9LkrCYnWB4j6VPP8OY=";
26   };
28   vendorHash = "sha256-oAqYQzOUjly97H5L5PQ9I2SO2KqiUVxdJA+eoPrHD6Q=";
30   ldflags = [
31     "-s"
32     "-w"
33   ];
35   preBuild = ''
36     tar -xzf ${web}
37     cp -r ./artalk_ui/* ./public
38   '';
40   nativeBuildInputs = [ installShellFiles ];
42   postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
43     installShellCompletion --cmd artalk \
44       --bash <($out/bin/artalk completion bash) \
45       --fish <($out/bin/artalk completion fish) \
46       --zsh <($out/bin/artalk completion zsh)
47   '';
49   doInstallCheck = true;
51   versionCheckProgramArg = "-v";
53   nativeInstallCheckInputs = [
54     versionCheckHook
55   ];
57   passthru.tests = {
58     inherit (nixosTests) artalk;
59   };
61   meta = {
62     description = "Self-hosted comment system";
63     homepage = "https://github.com/ArtalkJS/Artalk";
64     changelog = "https://github.com/ArtalkJS/Artalk/releases/tag/v${version}";
65     license = lib.licenses.mit;
66     sourceProvenance = with lib.sourceTypes; [
67       fromSource
68       binaryBytecode
69     ];
70     maintainers = with lib.maintainers; [ moraxyc ];
71     mainProgram = "artalk";
72   };