about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ho/hoppscotch/package.nix
blob: 3e6bf1ac190caf2f28df050de65265f2ccdb2ab4 (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
70
71
{ lib
, stdenv
, fetchurl
, appimageTools
, undmg
, nix-update-script
}:

let
  pname = "hoppscotch";
  version = "23.12.5";

  src = fetchurl {
    aarch64-darwin = {
      url = "https://github.com/hoppscotch/releases/releases/download/v${version}-1/Hoppscotch_mac_aarch64.dmg";
      hash = "sha256-WUJW38vQ7o5KEmCxhVnJ03/f5tPOTYcczrEcmt6NSCY=";
    };
    x86_64-darwin = {
      url = "https://github.com/hoppscotch/releases/releases/download/v${version}-1/Hoppscotch_mac_x64.dmg";
      hash = "sha256-bQFD+9IoelinWYUndzbVvPNaRde6ACPvw9ifX9mYdno=";
    };
    x86_64-linux = {
      url = "https://github.com/hoppscotch/releases/releases/download/v${version}-1/Hoppscotch_linux_x64.AppImage";
      hash = "sha256-MYQ7SRm+CUPIXROZxejbbZ0/wH+U5DQO4YGbE/HQAj8=";
    };
  }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");

  meta = {
    description = "Open source API development ecosystem";
    homepage = "https://hoppscotch.com";
    changelog = "https://github.com/hoppscotch/hoppscotch/releases/tag/${version}";
    platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ DataHearth ];
  };
in
if stdenv.isDarwin then stdenv.mkDerivation
{
  inherit pname version src meta;

  sourceRoot = ".";

  nativeBuildInputs = [ undmg ];

  installPhase = ''
    runHook preInstall

    mkdir -p "$out/Applications"
    mv Hoppscotch.app $out/Applications/

    runHook postInstall
  '';
}
else appimageTools.wrapType2 {
  inherit pname version src meta;

  extraPkgs = pkgs:
    appimageTools.defaultFhsEnvArgs.multiPkgs pkgs;

  extraInstallCommands =
    let
      appimageContents = appimageTools.extractType2 { inherit pname version src; };
    in
    ''
      mv $out/bin/${pname}-${version} $out/bin/${pname}

      # Install .desktop files
      install -Dm444 ${appimageContents}/hoppscotch.desktop -t $out/share/applications
      install -Dm444 ${appimageContents}/hoppscotch.png -t $out/share/pixmaps
    '';
}