Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 75 lines 2.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 appimageTools 6}: 7let 8 pname = "insomnia"; 9 version = "9.0.0"; 10 11 src = fetchurl { 12 x86_64-darwin = { 13 url = "https://github.com/Kong/insomnia/releases/download/core%40${version}/Insomnia.Core-${version}.dmg"; 14 hash = "sha256-QIArPdThQcNTUgrXpWP8JHaZfrZ/6ztekIvzFdoWjsY="; 15 }; 16 x86_64-linux = { 17 url = "https://github.com/Kong/insomnia/releases/download/core%40${version}/Insomnia.Core-${version}.AppImage"; 18 hash = "sha256-2UiqopYmNxnDcIqQMn/H89ugvOtTWkHH4LrmKkQErSs="; 19 }; 20 }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}"); 21 22 meta = with lib; { 23 homepage = "https://insomnia.rest"; 24 description = " The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage."; 25 mainProgram = "insomnia"; 26 changelog = "https://github.com/Kong/insomnia/releases/tag/core@${version}"; 27 license = licenses.asl20; 28 platforms = [ "x86_64-linux" "x86_64-darwin" ]; 29 maintainers = with maintainers; [ markus1189 kashw2 DataHearth ]; 30 }; 31in 32if stdenv.isDarwin then stdenv.mkDerivation { 33 inherit pname version src meta; 34 sourceRoot = "."; 35 36 unpackCmd = '' 37 echo "Creating temp directory" 38 mnt=$(TMPDIR=/tmp mktemp -d -t nix-XXXXXXXXXX) 39 function finish { 40 echo "Ejecting temp directory" 41 /usr/bin/hdiutil detach $mnt -force 42 rm -rf $mnt 43 } 44 # Detach volume when receiving SIG "0" 45 trap finish EXIT 46 # Mount DMG file 47 echo "Mounting DMG file into \"$mnt\"" 48 /usr/bin/hdiutil attach -nobrowse -mountpoint $mnt $curSrc 49 # Copy content to local dir for later use 50 echo 'Copying extracted content into "sourceRoot"' 51 cp -a $mnt/Insomnia.app $PWD/ 52 ''; 53 54 installPhase = '' 55 runHook preInstall 56 mkdir -p "$out/Applications" 57 mv Insomnia.app $out/Applications/ 58 runHook postInstall 59 ''; 60} else appimageTools.wrapType2 { 61 inherit pname version src meta; 62 63 extraInstallCommands = let 64 appimageContents = appimageTools.extract { 65 inherit pname version src; 66 }; 67 in '' 68 # Install XDG Desktop file and its icon 69 install -Dm444 ${appimageContents}/insomnia.desktop -t $out/share/applications 70 install -Dm444 ${appimageContents}/insomnia.png -t $out/share/pixmaps 71 # Replace wrong exec statement in XDG Desktop file 72 substituteInPlace $out/share/applications/insomnia.desktop \ 73 --replace-fail 'Exec=AppRun --no-sandbox %U' 'Exec=insomnia' 74 ''; 75}