summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/st/statping-ng/package.nix
blob: c132dcf640d8a8dcb5c23f5e81cc461afda009c5 (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
{
  buildGoModule,
  fetchFromGitHub,
  fetchYarnDeps,
  go-rice,
  lib,
  nodejs,
  stdenv,
  yarnBuildHook,
  yarnConfigHook,
}:
let
  version = "0.93.0";

  src = fetchFromGitHub {
    owner = "statping-ng";
    repo = "statping-ng";
    tag = "v${version}";
    hash = "sha256-VVM3Jyahs0OQuHiF/r+U9vq9TBOFOtuTzBurAhR1Dhc=";
  };

  frontend = stdenv.mkDerivation {
    pname = "statping-ng-frontend";
    inherit version;
    src = "${src}/frontend";

    yarnOfflineCache = fetchYarnDeps {
      yarnLock = "${src}/frontend/yarn.lock";
      hash = "sha256-e8GyKIJ0RopRliVMVrY8eEd6Qx/gTKbW3biPCSqbRrQ=";
    };

    nativeBuildInputs = [
      nodejs
      yarnConfigHook
      yarnBuildHook
    ];

    preBuild = ''
      export NODE_OPTIONS=--openssl-legacy-provider
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p "$out"
      cp -rt "$out" dist/* src/assets/scss public/robots.txt

      runHook postInstall
    '';
  };
in
buildGoModule rec {
  pname = "statping-ng";
  inherit version src;

  proxyVendor = true;
  vendorHash = "sha256-ZcNOI5/Fs7/U8/re89YpJ3qlMaQStLrrNHXiHuBQwQk=";

  postPatch = ''
    ln -s "${frontend}" source/dist
  '';

  nativeBuildInputs = [
    go-rice
  ];

  preBuild = ''
    (cd source && rice embed-go)
  '';

  subPackages = [
    "cmd/"
  ];

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

  tags = [
    "netgo"
    "ousergo"
  ];

  doCheck = false;

  postInstall = ''
    mv $out/bin/cmd $out/bin/statping-ng
    $out/bin/statping-ng version | grep ${version} > /dev/null
  '';

  meta = {
    description = "Status Page for monitoring your websites and applications with beautiful graphs, analytics, and plugins";
    homepage = "https://github.com/statping-ng/statping-ng";
    changelog = "https://github.com/statping-ng/statping-ng/releases/tag/${src.tag}";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [
      FKouhai
    ];
    platforms = lib.platforms.linux;
    mainProgram = "statping-ng";
  };
}