nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 appimageTools,
6 makeWrapper,
7 autoPatchelfHook,
8 libgcc,
9 appVariants ? [ ],
10}:
11
12let
13 pname = "caido";
14 appVariantList = [
15 "cli"
16 "desktop"
17 ];
18 version = "0.50.1";
19 cli = fetchurl {
20 url = "https://caido.download/releases/v${version}/caido-cli-v${version}-linux-x86_64.tar.gz";
21 hash = "sha256-mHB0nyU0nQg7duPcQf3NNz5vcnIfZcPLkAc+LoWdH58=";
22 };
23 desktop = fetchurl {
24 url = "https://caido.download/releases/v${version}/caido-desktop-v${version}-linux-x86_64.AppImage";
25 hash = "sha256-mVK/valleYH3qZdxRBCbmC7MTEE/Cn6MJwZviMgHL08=";
26 };
27 appimageContents = appimageTools.extractType2 {
28 inherit pname version;
29 src = desktop;
30 };
31
32 wrappedDesktop = appimageTools.wrapType2 {
33 src = desktop;
34 inherit pname version;
35
36 nativeBuildInputs = [ makeWrapper ];
37
38 extraPkgs = pkgs: [ pkgs.libthai ];
39
40 extraInstallCommands = ''
41 install -m 444 -D ${appimageContents}/caido.desktop -t $out/share/applications
42 install -m 444 -D ${appimageContents}/caido.png \
43 $out/share/icons/hicolor/512x512/apps/caido.png
44 wrapProgram $out/bin/caido \
45 --set WEBKIT_DISABLE_COMPOSITING_MODE 1
46 '';
47 };
48
49 wrappedCli = stdenv.mkDerivation {
50 src = cli;
51 inherit pname version;
52
53 nativeBuildInputs = [ autoPatchelfHook ];
54
55 buildInputs = [ libgcc ];
56
57 sourceRoot = ".";
58
59 installPhase = ''
60 runHook preInstall
61 install -m755 -D caido-cli $out/bin/caido-cli
62 '';
63 };
64
65 meta = {
66 description = "Lightweight web security auditing toolkit";
67 homepage = "https://caido.io/";
68 changelog = "https://github.com/caido/caido/releases/tag/v${version}";
69 license = lib.licenses.unfree;
70 maintainers = with lib.maintainers; [
71 octodi
72 d3vil0p3r
73 blackzeshi
74 ];
75 platforms = [ "x86_64-linux" ];
76 };
77
78in
79lib.checkListOfEnum "${pname}: appVariants" appVariantList appVariants (
80 if appVariants == [ "desktop" ] then
81 wrappedDesktop
82 else if appVariants == [ "cli" ] then
83 wrappedCli
84 else
85 stdenv.mkDerivation {
86 inherit pname version meta;
87 dontUnpack = true;
88 installPhase = ''
89 mkdir -p $out/bin
90 ln -s ${wrappedDesktop}/bin/caido $out/bin/caido
91 ln -s ${wrappedCli}/bin/caido-cli $out/bin/caido-cli
92 '';
93 }
94)