nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 appimageTools,
6 undmg,
7}:
8let
9 pname = "insomnia";
10 version = "12.2.0";
11
12 src =
13 fetchurl
14 {
15 aarch64-darwin = {
16 url = "https://github.com/Kong/insomnia/releases/download/core%40${version}/Insomnia.Core-${version}.dmg";
17 hash = "sha256-ISQVIhR5TWY/Xk6sXeL89/srxppqBS7wdoRINwuoQqg=";
18 };
19 x86_64-darwin = {
20 url = "https://github.com/Kong/insomnia/releases/download/core%40${version}/Insomnia.Core-${version}.dmg";
21 hash = "sha256-ISQVIhR5TWY/Xk6sXeL89/srxppqBS7wdoRINwuoQqg=";
22 };
23 x86_64-linux = {
24 url = "https://github.com/Kong/insomnia/releases/download/core%40${version}/Insomnia.Core-${version}.AppImage";
25 hash = "sha256-/0fJmbXhjrcVVSFvxd847mSKrzrZRK3Sqi6rjyaBOUw=";
26 };
27 }
28 .${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
29
30 meta = {
31 homepage = "https://insomnia.rest";
32 description = "Open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC, with Cloud, Local and Git storage";
33 mainProgram = "insomnia";
34 changelog = "https://github.com/Kong/insomnia/releases/tag/core@${version}";
35 license = lib.licenses.asl20;
36 platforms = [
37 "aarch64-darwin"
38 "x86_64-linux"
39 "x86_64-darwin"
40 ];
41 maintainers = with lib.maintainers; [
42 markus1189
43 kashw2
44 DataHearth
45 ];
46 };
47in
48if stdenv.hostPlatform.isDarwin then
49 stdenv.mkDerivation {
50 inherit
51 pname
52 version
53 src
54 meta
55 ;
56 sourceRoot = ".";
57
58 nativeBuildInputs = [ undmg ];
59
60 installPhase = ''
61 runHook preInstall
62 mkdir -p "$out/Applications"
63 mv Insomnia.app $out/Applications/
64 runHook postInstall
65 '';
66 }
67else
68 appimageTools.wrapType2 {
69 inherit
70 pname
71 version
72 src
73 meta
74 ;
75
76 extraInstallCommands =
77 let
78 appimageContents = appimageTools.extract {
79 inherit pname version src;
80 };
81 in
82 ''
83 # Install XDG Desktop file and its icon
84 install -Dm444 ${appimageContents}/insomnia.desktop -t $out/share/applications
85 install -Dm444 ${appimageContents}/insomnia.png -t $out/share/pixmaps
86 # Replace wrong exec statement in XDG Desktop file
87 substituteInPlace $out/share/applications/insomnia.desktop \
88 --replace-fail 'Exec=AppRun --no-sandbox %U' 'Exec=insomnia'
89 '';
90 }