summary refs log tree commit diff
path: root/pkgs/development/tools
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2021-03-30 12:10:56 +0200
committerJörg Thalheim <joerg@thalheim.io>2021-04-01 11:37:34 +0200
commitca9ca6eec9dfe610367cd82d7d20f17cf71736af (patch)
tree013f25ddbe07b232ba5087d1f8f9232c18a87c0a /pkgs/development/tools
parent77ca695ff9a78cbf40a334e4d601e5ac318b275f (diff)
downloadnixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar.gz
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar.bz2
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar.lz
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar.xz
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.tar.zst
nixpkgs-ca9ca6eec9dfe610367cd82d7d20f17cf71736af.zip
cutter: 1.12.0 -> 2.0.0
This also introduces rizin, which cutter builds on top
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r--pkgs/development/tools/analysis/radare2/cutter.nix63
-rw-r--r--pkgs/development/tools/analysis/radare2/default.nix186
-rwxr-xr-xpkgs/development/tools/analysis/radare2/update.py53
-rw-r--r--pkgs/development/tools/analysis/rizin/cutter.nix46
-rw-r--r--pkgs/development/tools/analysis/rizin/default.nix71
5 files changed, 214 insertions, 205 deletions
diff --git a/pkgs/development/tools/analysis/radare2/cutter.nix b/pkgs/development/tools/analysis/radare2/cutter.nix
deleted file mode 100644
index 6d9543e3836..00000000000
--- a/pkgs/development/tools/analysis/radare2/cutter.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ fetchFromGitHub, lib, mkDerivation
-# nativeBuildInputs
-, qmake, pkg-config
-# Qt
-, qtbase, qtsvg, qtwebengine
-# buildInputs
-, r2-for-cutter
-, python3
-, wrapQtAppsHook }:
-
-mkDerivation rec {
-  pname = "radare2-cutter";
-  version = "1.12.0";
-
-  src = fetchFromGitHub {
-    owner = "radareorg";
-    repo = "cutter";
-    rev = "v${version}";
-    sha256 = "0ljj3j3apbbw628n2nyrxpbnclixx20bqjxm0xwggqzz9vywsar0";
-  };
-
-  postUnpack = "export sourceRoot=$sourceRoot/src";
-
-  # Remove this "very helpful" helper file intended for discovering r2,
-  # as it's a doozy of harddcoded paths and unexpected behavior.
-  # Happily Nix has everything all set so we don't need it,
-  # other than as basis for the qmakeFlags set below.
-  postPatch = ''
-    substituteInPlace Cutter.pro \
-      --replace "include(lib_radare2.pri)" ""
-  '';
-
-  nativeBuildInputs = [ qmake pkg-config python3 wrapQtAppsHook ];
-  propagatedBuildInputs = [ python3.pkgs.pyside2 ];
-  buildInputs = [ qtbase qtsvg qtwebengine r2-for-cutter python3 ];
-
-  qmakeFlags = with python3.pkgs; [
-    "CONFIG+=link_pkg-config"
-    "PKGCONFIG+=r_core"
-    # Leaving this enabled doesn't break build but generates errors
-    # at runtime (to console) about being unable to load needed bits.
-    # Disable until can be looked at.
-    "CUTTER_ENABLE_JUPYTER=false"
-    # Enable support for Python plugins
-    "CUTTER_ENABLE_PYTHON=true"
-    "CUTTER_ENABLE_PYTHON_BINDINGS=true"
-    "SHIBOKEN_EXTRA_OPTIONS+=-I${r2-for-cutter}/include/libr"
-  ];
-
-  preBuild = ''
-    export NIX_LDFLAGS="$NIX_LDFLAGS $(pkg-config --libs python3-embed)"
-    qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = with lib; {
-    description = "A Qt and C++ GUI for radare2 reverse engineering framework";
-    homepage = src.meta.homepage;
-    license = licenses.gpl3;
-    maintainers = with maintainers; [ mic92 dtzWill ];
-  };
-}
diff --git a/pkgs/development/tools/analysis/radare2/default.nix b/pkgs/development/tools/analysis/radare2/default.nix
index 287321804e2..f5ce1bbde76 100644
--- a/pkgs/development/tools/analysis/radare2/default.nix
+++ b/pkgs/development/tools/analysis/radare2/default.nix
@@ -1,9 +1,21 @@
-{lib, stdenv, fetchFromGitHub
+{ lib
+, stdenv
+, fetchFromGitHub
 , buildPackages
 , pkg-config
-, libusb-compat-0_1, readline, libewf, perl, zlib, openssl
-, libuv, file, libzip, xxHash
-, gtk2 ? null, vte ? null, gtkdialog ? null
+, libusb-compat-0_1
+, readline
+, libewf
+, perl
+, zlib
+, openssl
+, libuv
+, file
+, libzip
+, xxHash
+, gtk2 ? null
+, vte ? null
+, gtkdialog ? null
 , python3 ? null
 , ruby ? null
 , lua ? null
@@ -21,108 +33,84 @@ assert pythonBindings -> python3 != null;
 let
   inherit (lib) optional;
 
-  generic = {
-    version_commit, # unused
-    gittap,
-    gittip,
-    rev,
-    version,
-    sha256,
-    cs_ver,
-    cs_sha256
-  }:
-    stdenv.mkDerivation {
-      pname = "radare2";
-      inherit version;
+  #<generated>
+  # DO NOT EDIT! Automatically generated by ./update.py
+  gittap = "5.1.1";
+  gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
+  rev = "5.1.1";
+  version = "5.1.1";
+  sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
+  cs_ver = "4.0.2";
+  cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
+  #</generated>
+in
+stdenv.mkDerivation {
+  pname = "radare2";
+  inherit version;
 
-      src = fetchFromGitHub {
-        owner = "radare";
-        repo = "radare2";
-        inherit rev sha256;
-      };
+  src = fetchFromGitHub {
+    owner = "radare";
+    repo = "radare2";
+    inherit rev sha256;
+  };
 
-      postPatch = let
-        capstone = fetchFromGitHub {
-          owner = "aquynh";
-          repo = "capstone";
-          # version from $sourceRoot/shlr/Makefile
-          rev = cs_ver;
-          sha256 = cs_sha256;
-        };
-      in ''
-        mkdir -p build/shlr
-        cp -r ${capstone} capstone-${cs_ver}
-        chmod -R +w capstone-${cs_ver}
-        # radare 3.3 compat for radare2-cutter
-        (cd shlr && ln -s ../capstone-${cs_ver} capstone)
-        tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
-      '';
+  postPatch =
+    let
+      capstone = fetchFromGitHub {
+        owner = "aquynh";
+        repo = "capstone";
+        # version from $sourceRoot/shlr/Makefile
+        rev = cs_ver;
+        sha256 = cs_sha256;
+      };
+    in
+    ''
+      mkdir -p build/shlr
+      cp -r ${capstone} capstone-${cs_ver}
+      chmod -R +w capstone-${cs_ver}
+      tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
+    '';
 
-      postInstall = ''
-        install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
-      '';
+  postInstall = ''
+    install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
+  '';
 
-      WITHOUT_PULL="1";
-      makeFlags = [
-        "GITTAP=${gittap}"
-        "GITTIP=${gittip}"
-        "RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
-      ];
-      configureFlags = [
-        "--with-sysmagic"
-        "--with-syszip"
-        "--with-sysxxhash"
-        "--with-openssl"
-      ];
+  WITHOUT_PULL = "1";
+  makeFlags = [
+    "GITTAP=${gittap}"
+    "GITTIP=${gittip}"
+    "RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
+  ];
+  configureFlags = [
+    "--with-sysmagic"
+    "--with-syszip"
+    "--with-sysxxhash"
+    "--with-openssl"
+  ];
 
-      enableParallelBuilding = true;
-      depsBuildBuild = [ buildPackages.stdenv.cc ];
+  enableParallelBuilding = true;
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
 
-      nativeBuildInputs = [ pkg-config ];
-      buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
-        ++ optional useX11 [ gtkdialog vte gtk2 ]
-        ++ optional rubyBindings [ ruby ]
-        ++ optional pythonBindings [ python3 ]
-        ++ optional luaBindings [ lua ];
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
+    ++ optional useX11 [ gtkdialog vte gtk2 ]
+    ++ optional rubyBindings [ ruby ]
+    ++ optional pythonBindings [ python3 ]
+    ++ optional luaBindings [ lua ];
 
-      propagatedBuildInputs = [
-        # radare2 exposes r_lib which depends on these libraries
-        file # for its list of magic numbers (`libmagic`)
-        libzip
-        xxHash
-      ];
+  propagatedBuildInputs = [
+    # radare2 exposes r_lib which depends on these libraries
+    file # for its list of magic numbers (`libmagic`)
+    libzip
+    xxHash
+  ];
 
-      meta = {
-        description = "unix-like reverse engineering framework and commandline tools";
-        homepage = "http://radare.org/";
-        license = lib.licenses.gpl2Plus;
-        maintainers = with lib.maintainers; [ raskin makefu mic92 ];
-        platforms = with lib.platforms; linux;
-        inherit version;
-      };
-  };
-in {
-  #<generated>
-  # DO NOT EDIT! Automatically generated by ./update.py
-  radare2 = generic {
-    version_commit = "25741";
-    gittap = "5.1.1";
-    gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
-    rev = "5.1.1";
-    version = "5.1.1";
-    sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
-    cs_ver = "4.0.2";
-    cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
-  };
-  r2-for-cutter = generic {
-    version_commit = "24959";
-    gittap = "4.5.1";
-    gittip = "293cf5ae65ba4e28828095dcae212955593ba255";
-    rev = "4.5.1";
-    version = "4.5.1";
-    sha256 = "0qigy1px0jy74c5ig73dc2fqjcy6vcy76i25dx9r3as6zfpkkaxj";
-    cs_ver = "4.0.2";
-    cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
+  meta = {
+    description = "unix-like reverse engineering framework and commandline tools";
+    homepage = "http://radare.org/";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ raskin makefu mic92 ];
+    platforms = with lib.platforms; linux;
+    inherit version;
   };
-  #</generated>
 }
diff --git a/pkgs/development/tools/analysis/radare2/update.py b/pkgs/development/tools/analysis/radare2/update.py
index a9a0a234317..ede0a6058a9 100755
--- a/pkgs/development/tools/analysis/radare2/update.py
+++ b/pkgs/development/tools/analysis/radare2/update.py
@@ -48,24 +48,6 @@ def get_radare2_rev() -> str:
     raise RuntimeError(f"No release found at {feed_url}")
 
 
-def get_cutter_version() -> str:
-    version_expr = """
-(with import <nixpkgs> {}; lib.getVersion (qt5.callPackage <radare2/cutter.nix> {}))
-"""
-    return sh("nix", "eval", "--raw", version_expr.strip(), "-I", "radare2={0}".format(SCRIPT_DIR))
-
-
-def get_r2_cutter_rev() -> str:
-    version = get_cutter_version()
-    url = f"https://api.github.com/repos/radareorg/cutter/contents?ref=v{version}"
-    with urllib.request.urlopen(url) as response:
-        data = json.load(response)  # type: ignore
-    for entry in data:
-        if entry["name"] == "radare2":
-            return entry["sha"]
-    raise Exception("no radare2 submodule found in github.com/radareorg/cutter")
-
-
 def git(dirname: str, *args: str) -> str:
     return sh("git", "-C", dirname, *args)
 
@@ -94,43 +76,23 @@ def get_repo_info(dirname: str, rev: str) -> Dict[str, str]:
     )
 
 
-def write_package_expr(version: str, info: Dict[str, str]) -> str:
-    return f"""generic {{
-    version_commit = "{info["version_commit"]}";
-    gittap = "{info["gittap"]}";
-    gittip = "{info["gittip"]}";
-    rev = "{info["rev"]}";
-    version = "{version}";
-    sha256 = "{info["sha256"]}";
-    cs_ver = "{info["cs_ver"]}";
-    cs_sha256 = "{info["cs_sha256"]}";
-  }}"""
-
-
 def main() -> None:
-    radare2_rev = get_radare2_rev()
-    r2_cutter_rev = get_r2_cutter_rev()
+    version = get_radare2_rev()
 
     with tempfile.TemporaryDirectory() as dirname:
         git(
             dirname,
             "clone",
             "--branch",
-            radare2_rev,
+            version,
             "https://github.com/radare/radare2",
             ".",
         )
         nix_file = str(SCRIPT_DIR.joinpath("default.nix"))
 
-        radare2_info = get_repo_info(dirname, radare2_rev)
-
-        git(dirname, "fetch", r2_cutter_rev)
-        git(dirname, "checkout", r2_cutter_rev)
+        info = get_repo_info(dirname, version)
 
         timestamp = git(dirname, "log", "-n1", "--format=%at")
-        r2_cutter_version = datetime.fromtimestamp(int(timestamp)).strftime("%Y-%m-%d")
-
-        r2_cutter_info = get_repo_info(dirname, r2_cutter_rev)
 
         in_block = False
         with fileinput.FileInput(nix_file, inplace=True) as f:
@@ -140,8 +102,13 @@ def main() -> None:
                     print(
                         f"""  #<generated>
   # DO NOT EDIT! Automatically generated by ./update.py
-  radare2 = {write_package_expr(radare2_rev, radare2_info)};
-  r2-for-cutter = {write_package_expr(r2_cutter_version, r2_cutter_info)};
+  gittap = "{info["gittap"]}";
+  gittip = "{info["gittip"]}";
+  rev = "{info["rev"]}";
+  version = "{version}";
+  sha256 = "{info["sha256"]}";
+  cs_ver = "{info["cs_ver"]}";
+  cs_sha256 = "{info["cs_sha256"]}";
   #</generated>"""
                     )
                 elif "#</generated>" in l:
diff --git a/pkgs/development/tools/analysis/rizin/cutter.nix b/pkgs/development/tools/analysis/rizin/cutter.nix
new file mode 100644
index 00000000000..14d815f04b1
--- /dev/null
+++ b/pkgs/development/tools/analysis/rizin/cutter.nix
@@ -0,0 +1,46 @@
+{ fetchFromGitHub, lib, mkDerivation
+# nativeBuildInputs
+, qmake, pkg-config, cmake
+# Qt
+, qtbase, qtsvg, qtwebengine, qttools
+# buildInputs
+, rizin
+, python3
+, wrapQtAppsHook
+}:
+
+mkDerivation rec {
+  pname = "cutter";
+  version = "2.0.0";
+
+  src = fetchFromGitHub {
+    owner = "rizinorg";
+    repo = "cutter";
+    rev = "v${version}";
+    sha256 = "sha256-uIN/NR+swu9Ie0wP2aBhw5WBvTe9NDmzSs+lQMCeavc=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake qmake pkg-config python3 wrapQtAppsHook ];
+  propagatedBuildInputs = [ python3.pkgs.pyside2 ];
+  buildInputs = [ qtbase qttools qtsvg qtwebengine rizin python3 ];
+
+  cmakeFlags = [
+    "-DCUTTER_USE_BUNDLED_RIZIN=OFF"
+    "-DCUTTER_ENABLE_PYTHON=ON"
+    "-DCUTTER_ENABLE_PYTHON_BINDINGS=ON"
+  ];
+
+  preBuild = ''
+    qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "Free and Open Source Reverse Engineering Platform powered by rizin";
+    homepage = src.meta.homepage;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ mic92 dtzWill ];
+  };
+}
diff --git a/pkgs/development/tools/analysis/rizin/default.nix b/pkgs/development/tools/analysis/rizin/default.nix
new file mode 100644
index 00000000000..bbcc432ea99
--- /dev/null
+++ b/pkgs/development/tools/analysis/rizin/default.nix
@@ -0,0 +1,71 @@
+{ lib
+, stdenv
+, fetchurl
+, pkg-config
+, libusb-compat-0_1
+, readline
+, libewf
+, perl
+, zlib
+, openssl
+, libuv
+, file
+, libzip
+, lz4
+, xxHash
+, meson
+, cmake
+, ninja
+, capstone
+, tree-sitter
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rizin";
+  version = "0.1.2";
+
+  src = fetchurl {
+    url = "https://github.com/rizinorg/rizin/releases/download/v${version}/rizin-src-${version}.tar.xz";
+    sha256 = "sha256-npUp8wJiKAaQKSigXtndhJLTJ4+pyFqa0FwDLBqR/sE=";
+  };
+
+  mesonFlags = [
+    "-Duse_sys_capstone=true"
+    "-Duse_sys_magic=true"
+    "-Duse_sys_libzip=true"
+    "-Duse_sys_zlib=true"
+    "-Duse_sys_xxhash=true"
+    "-Duse_sys_lz4=true"
+    "-Duse_sys_openssl=true"
+    "-Duse_sys_tree_sitter=true"
+  ];
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ pkg-config meson ninja cmake ];
+
+  buildInputs = [
+    file
+    libzip
+    capstone
+    readline
+    libusb-compat-0_1
+    libewf
+    perl
+    zlib
+    lz4
+    openssl
+    libuv
+    tree-sitter
+    xxHash
+  ];
+
+  meta = {
+    description = "UNIX-like reverse engineering framework and command-line toolset.";
+    homepage = "https://rizin.re/";
+    license = lib.licenses.gpl3Plus;
+    maintainers = with lib.maintainers; [ raskin makefu mic92 ];
+    platforms = with lib.platforms; linux;
+    inherit version;
+  };
+}