commit c9bb7d4a85e222babedb90fa11e1d452b3a2ebcb Author: bad Date: Thu Jul 28 18:42:08 2022 +0200 Initial commit diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..dcb495c --- /dev/null +++ b/flake.lock @@ -0,0 +1,39 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-94ZTF0uIX/iZdiD4RJ5f933ak/OM4XLl7hF+gCa4Iuk=", + "path": "/nix/store/9qqx4gk4qnqaqb102iwvhhwn2basmbdq-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3fac01f --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "A very basic flake"; + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + { + overlays.default = final: prev: { + rizin-unwrapped = prev.rizin; + rizin = self.packages.${prev.system}.rizin; + rizinPlugins = self.packages.${prev.system}.rizinPlugins; + + }; + } + // flake-utils.lib.eachSystem [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + ] + (system: + let + pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; + in + rec { + packages = flake-utils.lib.flattenTree { + rizin = pkgs.callPackage ./rizin-with-plugin-support.nix { }; + rizinPlugins = { + rz-ghidra = pkgs.callPackage ./rz-ghidra.nix { }; + jsdec = pkgs.callPackage ./jsdec.nix { }; + }; + }; + defaultPackage = packages.rizin; + } + ); +} diff --git a/jsdec.nix b/jsdec.nix new file mode 100644 index 0000000..96f5a96 --- /dev/null +++ b/jsdec.nix @@ -0,0 +1,15 @@ +{ lib, stdenv, fetchFromGitHub, meson, pkg-config, cmake, ninja, openssl, rizin }: stdenv.mkDerivation { + name = "jsdec"; + src = fetchFromGitHub { + owner = "rizinorg"; + repo = "jsdec"; + rev = "5ef437d181ad73fc74e406d922f02d09904ae047"; + sha256 = "sha256-Z5QU7IdMGk5IcWbmOVeblfWlo1hfulaYVt3qWRmmYjc="; + }; + preConfigure = '' + cd p + ''; + mesonFlags = [ "-Djsc_folder=/build/source/" ]; + buildInputs = [ rizin openssl ]; + nativeBuildInputs = [ meson pkg-config ninja ]; +} diff --git a/rizin-with-plugin-support.nix b/rizin-with-plugin-support.nix new file mode 100644 index 0000000..00bbb02 --- /dev/null +++ b/rizin-with-plugin-support.nix @@ -0,0 +1,27 @@ +{ rizin-unwrapped, rizinPlugins, makeWrapper, symlinkJoin }: +let + makeRizinPackageWithPlugins = plugins: + let + plugins_path = symlinkJoin { + name = "rizin-plugins"; + paths = plugins; + }; + in + symlinkJoin { + name = "rizin"; + paths = [ rizin-unwrapped ]; + buildInputs = [makeWrapper]; + postBuild = '' + wrapProgramArgs=() + for plugin in ${plugins_path}/lib/rizin/plugins/*; do + wrapProgramArgs+=("--add-flags") + wrapProgramArgs+=("-l") + wrapProgramArgs+=("--add-flags") + wrapProgramArgs+=("$plugin") + done + wrapProgram $out/bin/rizin ''${wrapProgramArgs[*]} + ''; + } // { + withPlugins = p: makeRizinPackageWithPlugins (plugins ++ (p rizinPlugins)); + }; +in makeRizinPackageWithPlugins [] diff --git a/rz-ghidra.nix b/rz-ghidra.nix new file mode 100644 index 0000000..4e2d18a --- /dev/null +++ b/rz-ghidra.nix @@ -0,0 +1,12 @@ +{ lib, stdenv, fetchgit, pkg-config, cmake, openssl, rizin, breakpointHook }: stdenv.mkDerivation { + name = "rz-ghidra"; + src = fetchgit { + url = "https://github.com/rizinorg/rz-ghidra.git"; + rev = "e70aa0f68310f18620153eed57b27fdfb9ba3018"; + sha256 = "sha256-7GZdrxHGSAf1MlMdEpKDOa4Dxu5ckG+IlgAN+mp/U5E="; + fetchSubmodules = true; + }; + mesonFlags = [ "-Djsc_folder=/build/source/" ]; + buildInputs = [ rizin cmake openssl ]; + nativeBuildInputs = [ pkg-config breakpointHook ]; +}