about summary refs log tree commit diff
path: root/pkgs/by-name/st/stats/package.nix
blob: 803898ea36c5e52bf65a0a3e42d2018b0e8b861d (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
{ lib
, stdenvNoCC
, fetchurl
, undmg
, writeShellApplication
, curl
, jq
, common-updater-scripts
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "stats";
  version = "2.10.11";

  src = fetchurl {
    url = "https://github.com/exelban/stats/releases/download/v${finalAttrs.version}/Stats.dmg";
    hash = "sha256-vF32tDuSAZJrZ21iKtM+/2qk9WWoyMddrtg5wK2+IaI=";
  };

  sourceRoot = ".";

  nativeBuildInputs = [ undmg ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/Applications
    cp -r *.app $out/Applications

    runHook postInstall
  '';

  passthru.updateScript = lib.getExe (writeShellApplication {
    name = "stats-update-script";
    runtimeInputs = [ curl jq common-updater-scripts ];
    text = ''
      set -euo pipefail
      url="$(curl --silent "https://api.github.com/repos/exelban/stats/tags?per_page=1")"
      version="$(echo "$url" | jq -r '.[0].name' | cut -c 2-)"
      update-source-version stats "$version" --file=./pkgs/by-name/st/stats/package.nix
    '';
  });

  meta = with lib; {
    description = "macOS system monitor in your menu bar";
    homepage = "https://github.com/exelban/stats";
    license = licenses.mit;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    maintainers = with maintainers; [ emilytrau Enzime donteatoreo ];
    platforms = platforms.darwin;
  };
})