nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 208 lines 5.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 appimageTools, 6 makeWrapper, 7 autoPatchelfHook, 8 _7zz, 9 unzip, 10 libgcc, 11 appVariants ? [ ], 12}: 13let 14 pname = "caido"; 15 appVariantList = [ 16 "cli" 17 "desktop" 18 ]; 19 version = "0.53.1"; 20 21 system = stdenv.hostPlatform.system; 22 isLinux = stdenv.isLinux; 23 isDarwin = stdenv.isDarwin; 24 25 # CLI sources 26 cliSources = { 27 x86_64-linux = { 28 url = "https://caido.download/releases/v${version}/caido-cli-v${version}-linux-x86_64.tar.gz"; 29 hash = "sha256-qSrgEg0iEx5Mpe+meHnkrOgM9zcQJBzoH5KlMy8FE5Q="; 30 }; 31 aarch64-linux = { 32 url = "https://caido.download/releases/v${version}/caido-cli-v${version}-linux-aarch64.tar.gz"; 33 hash = "sha256-mgIjo+1y2jxC7lPUkLjuwIq4F8SagjQAyfeqaoeQX9w="; 34 }; 35 x86_64-darwin = { 36 url = "https://caido.download/releases/v${version}/caido-cli-v${version}-mac-x86_64.zip"; 37 hash = "sha256-iPDYQXWaxt32MxbAWL0496i7IO0FEt8di4E0msagfEo="; 38 }; 39 aarch64-darwin = { 40 url = "https://caido.download/releases/v${version}/caido-cli-v${version}-mac-aarch64.zip"; 41 hash = "sha256-5b9TrR5ZqlN17OgIaQ9vPIccwOiELNcidjinF3rf6Zc="; 42 }; 43 }; 44 45 # Desktop sources 46 desktopSources = { 47 x86_64-linux = { 48 url = "https://caido.download/releases/v${version}/caido-desktop-v${version}-linux-x86_64.AppImage"; 49 hash = "sha256-/puWhX5ooz994f1COw356HSfqcOmJaAweccTIWl9KCo="; 50 }; 51 aarch64-linux = { 52 url = "https://caido.download/releases/v${version}/caido-desktop-v${version}-linux-aarch64.AppImage"; 53 hash = "sha256-iYaWN6Nu0+zPSUzlhUS5EIuYO32BVkBLZrPA9h7DpfM="; 54 }; 55 x86_64-darwin = { 56 url = "https://caido.download/releases/v${version}/caido-desktop-v${version}-mac-x86_64.dmg"; 57 hash = "sha256-iPDYQXWaxt32MxbAWL0496i7IO0FEt8di4E0msagfEo="; 58 }; 59 aarch64-darwin = { 60 url = "https://caido.download/releases/v${version}/caido-desktop-v${version}-mac-aarch64.dmg"; 61 hash = "sha256-5b9TrR5ZqlN17OgIaQ9vPIccwOiELNcidjinF3rf6Zc="; 62 }; 63 }; 64 65 cliSource = cliSources.${system} or (throw "Unsupported system for caido-cli: ${system}"); 66 desktopSource = 67 desktopSources.${system} or (throw "Unsupported system for caido-desktop: ${system}"); 68 69 cli = fetchurl { 70 url = cliSource.url; 71 hash = cliSource.hash; 72 }; 73 74 desktop = fetchurl { 75 url = desktopSource.url; 76 hash = desktopSource.hash; 77 }; 78 79 appimageContents = appimageTools.extractType2 { 80 inherit pname version; 81 src = desktop; 82 }; 83 84 wrappedDesktop = 85 if isLinux then 86 appimageTools.wrapType2 { 87 src = desktop; 88 inherit pname version; 89 90 nativeBuildInputs = [ makeWrapper ]; 91 92 extraPkgs = pkgs: [ pkgs.libthai ]; 93 94 extraInstallCommands = '' 95 install -m 444 -D ${appimageContents}/caido.desktop -t $out/share/applications 96 install -m 444 -D ${appimageContents}/caido.png \ 97 $out/share/icons/hicolor/512x512/apps/caido.png 98 wrapProgram $out/bin/caido \ 99 --set WEBKIT_DISABLE_COMPOSITING_MODE 1 \ 100 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" 101 ''; 102 } 103 else if isDarwin then 104 stdenv.mkDerivation { 105 src = desktop; 106 inherit pname version; 107 108 nativeBuildInputs = [ _7zz ]; 109 sourceRoot = "."; 110 111 unpackPhase = '' 112 runHook preUnpack 113 ${_7zz}/bin/7zz x $src 114 runHook postUnpack 115 ''; 116 117 installPhase = '' 118 runHook preInstall 119 mkdir -p $out/Applications 120 cp -r Caido.app $out/Applications/ 121 mkdir -p $out/bin 122 ln -s $out/Applications/Caido.app/Contents/MacOS/Caido $out/bin/caido 123 runHook postInstall 124 ''; 125 126 meta = { 127 platforms = [ 128 "x86_64-darwin" 129 "aarch64-darwin" 130 ]; 131 }; 132 } 133 else 134 throw "Desktop variant is not supported on ${stdenv.hostPlatform.system}"; 135 136 wrappedCli = 137 if isLinux then 138 stdenv.mkDerivation { 139 src = cli; 140 inherit pname version; 141 142 nativeBuildInputs = [ autoPatchelfHook ]; 143 buildInputs = [ libgcc ]; 144 sourceRoot = "."; 145 146 installPhase = '' 147 runHook preInstall 148 install -m755 -D caido-cli $out/bin/caido-cli 149 runHook postInstall 150 ''; 151 } 152 else if isDarwin then 153 stdenv.mkDerivation { 154 src = cli; 155 inherit pname version; 156 157 nativeBuildInputs = [ unzip ]; 158 sourceRoot = "."; 159 160 installPhase = '' 161 runHook preInstall 162 install -m755 -D caido-cli $out/bin/caido-cli 163 runHook postInstall 164 ''; 165 166 meta = { 167 platforms = [ 168 "x86_64-darwin" 169 "aarch64-darwin" 170 ]; 171 }; 172 } 173 else 174 throw "CLI variant is not supported on ${stdenv.hostPlatform.system}"; 175 176 meta = { 177 description = "Lightweight web security auditing toolkit"; 178 homepage = "https://caido.io/"; 179 changelog = "https://github.com/caido/caido/releases/tag/v${version}"; 180 license = lib.licenses.unfree; 181 maintainers = with lib.maintainers; [ 182 octodi 183 blackzeshi 184 ]; 185 platforms = [ 186 "x86_64-linux" 187 "aarch64-linux" 188 "x86_64-darwin" 189 "aarch64-darwin" 190 ]; 191 }; 192in 193lib.checkListOfEnum "${pname}: appVariants" appVariantList appVariants ( 194 if appVariants == [ "desktop" ] then 195 wrappedDesktop 196 else if appVariants == [ "cli" ] then 197 wrappedCli 198 else 199 stdenv.mkDerivation { 200 inherit pname version meta; 201 dontUnpack = true; 202 installPhase = '' 203 mkdir -p $out/bin 204 ln -s ${wrappedDesktop}/bin/caido $out/bin/caido 205 ln -s ${wrappedCli}/bin/caido-cli $out/bin/caido-cli 206 ''; 207 } 208)