From 495d0374ef5f8c13425d2d0ac3df6378da5483de Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sat, 22 Jun 2024 00:32:27 -0400 Subject: [PATCH 1/2] ghidra: reformat to rfc style --- pkgs/tools/security/ghidra/build.nix | 128 ++++++++++++++++----------- 1 file changed, 75 insertions(+), 53 deletions(-) diff --git a/pkgs/tools/security/ghidra/build.nix b/pkgs/tools/security/ghidra/build.nix index ba23647c9c2d..7715b7f367b8 100644 --- a/pkgs/tools/security/ghidra/build.nix +++ b/pkgs/tools/security/ghidra/build.nix @@ -1,19 +1,20 @@ -{ stdenv -, fetchFromGitHub -, lib -, callPackage -, gradle_7 -, perl -, makeBinaryWrapper -, openjdk17 -, unzip -, makeDesktopItem -, copyDesktopItems -, desktopToDarwinBundle -, icoutils -, xcbuild -, protobuf -, ghidra-extensions +{ + stdenv, + fetchFromGitHub, + lib, + callPackage, + gradle_7, + perl, + makeBinaryWrapper, + openjdk17, + unzip, + makeDesktopItem, + copyDesktopItems, + desktopToDarwinBundle, + icoutils, + xcbuild, + protobuf, + ghidra-extensions, }: let @@ -76,26 +77,26 @@ let # Adds a gradle step that downloads all the dependencies to the gradle cache. addResolveStep = '' - cat >>build.gradle < - subProject.buildscript.configurations.each { configuration -> - resolveConfiguration(subProject, configuration, "buildscript config \''${configuration.name}") - } - subProject.configurations.each { configuration -> - resolveConfiguration(subProject, configuration, "config \''${configuration.name}") + cat >>build.gradle < + subProject.buildscript.configurations.each { configuration -> + resolveConfiguration(subProject, configuration, "buildscript config \''${configuration.name}") + } + subProject.configurations.each { configuration -> + resolveConfiguration(subProject, configuration, "config \''${configuration.name}") + } + } } } - } -} -void resolveConfiguration(subProject, configuration, name) { - if (configuration.canBeResolved) { - logger.info("Resolving project {} {}", subProject.name, name) - configuration.resolve() - } -} -HERE + void resolveConfiguration(subProject, configuration, name) { + if (configuration.canBeResolved) { + logger.info("Resolving project {} {}", subProject.name, name) + configuration.resolve() + } + } + HERE ''; # fake build to pre-download deps into fixed-output derivation @@ -106,7 +107,10 @@ HERE postPatch = addResolveStep; - nativeBuildInputs = [ gradle perl ] ++ lib.optional stdenv.isDarwin xcbuild; + nativeBuildInputs = [ + gradle + perl + ] ++ lib.optional stdenv.isDarwin xcbuild; buildPhase = '' runHook preBuild export HOME="$NIX_BUILD_TOP/home" @@ -134,9 +138,15 @@ HERE outputHashMode = "recursive"; outputHash = "sha256-nKfJiGoZlDEpbCmYVKNZXz2PYIosCd4nPFdy3MfprHc="; }; - -in stdenv.mkDerivation (finalAttrs: { - inherit pname version src patches postPatch; +in +stdenv.mkDerivation (finalAttrs: { + inherit + pname + version + src + patches + postPatch + ; desktopItems = [ (makeDesktopItem { @@ -150,16 +160,18 @@ in stdenv.mkDerivation (finalAttrs: { }) ]; - nativeBuildInputs = [ - gradle - unzip - makeBinaryWrapper - copyDesktopItems - protobuf - ] ++ lib.optionals stdenv.isDarwin [ - xcbuild - desktopToDarwinBundle - ]; + nativeBuildInputs = + [ + gradle + unzip + makeBinaryWrapper + copyDesktopItems + protobuf + ] + ++ lib.optionals stdenv.isDarwin [ + xcbuild + desktopToDarwinBundle + ]; dontStrip = true; @@ -211,7 +223,10 @@ in stdenv.mkDerivation (finalAttrs: { passthru = { inherit releaseName distroPrefix; - inherit (ghidra-extensions.override { ghidra = finalAttrs.finalPackage; }) buildGhidraExtension buildGhidraScripts; + inherit (ghidra-extensions.override { ghidra = finalAttrs.finalPackage; }) + buildGhidraExtension + buildGhidraScripts + ; withExtensions = callPackage ./with-extensions.nix { ghidra = finalAttrs.finalPackage; }; }; @@ -221,14 +236,21 @@ in stdenv.mkDerivation (finalAttrs: { description = "Software reverse engineering (SRE) suite of tools"; mainProgram = "ghidra"; homepage = "https://ghidra-sre.org/"; - platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + platforms = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; sourceProvenance = with sourceTypes; [ fromSource - binaryBytecode # deps + binaryBytecode # deps ]; license = licenses.asl20; - maintainers = with maintainers; [ roblabla vringar ]; + maintainers = with maintainers; [ + roblabla + vringar + ]; broken = stdenv.isDarwin && stdenv.isx86_64; }; - }) From adaf51e750c202827c627ce7117ce8a657371757 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sat, 22 Jun 2024 00:34:30 -0400 Subject: [PATCH 2/2] ghidra: 11.0.3 -> 11.1.1 --- pkgs/tools/security/ghidra/build.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/security/ghidra/build.nix b/pkgs/tools/security/ghidra/build.nix index 7715b7f367b8..2a3bb65f8a79 100644 --- a/pkgs/tools/security/ghidra/build.nix +++ b/pkgs/tools/security/ghidra/build.nix @@ -11,16 +11,17 @@ makeDesktopItem, copyDesktopItems, desktopToDarwinBundle, - icoutils, xcbuild, protobuf, ghidra-extensions, + python3, + python3Packages, }: let pkg_path = "$out/lib/ghidra"; pname = "ghidra"; - version = "11.0.3"; + version = "11.1.1"; releaseName = "NIX"; distroPrefix = "ghidra_${version}_${releaseName}"; @@ -28,7 +29,7 @@ let owner = "NationalSecurityAgency"; repo = "Ghidra"; rev = "Ghidra_${version}_build"; - hash = "sha256-IiLxaJvfJcK275FDZEsUCGp7haJjp8O2fUIoM4F9H30="; + hash = "sha256-t96FcAK3JwO66dOf4OhpOfU8CQfAczfF61Cg7m+B3fA="; # populate values that require us to use git. By doing this in postFetch we # can delete .git afterwards and maintain better reproducibility of the src. leaveDotGit = true; @@ -136,7 +137,7 @@ let ''; outputHashAlgo = "sha256"; outputHashMode = "recursive"; - outputHash = "sha256-nKfJiGoZlDEpbCmYVKNZXz2PYIosCd4nPFdy3MfprHc="; + outputHash = "sha256-66gL4UFlBUo2JIEOXoF6tFvXtBdEX4b2MeSrV1b6Vg4="; }; in stdenv.mkDerivation (finalAttrs: { @@ -148,6 +149,12 @@ stdenv.mkDerivation (finalAttrs: { postPatch ; + # Don't create .orig files if the patch isn't an exact match. + patchFlags = [ + "--no-backup-if-mismatch" + "-p1" + ]; + desktopItems = [ (makeDesktopItem { name = "ghidra"; @@ -167,6 +174,8 @@ stdenv.mkDerivation (finalAttrs: { makeBinaryWrapper copyDesktopItems protobuf + python3 + python3Packages.pip ] ++ lib.optionals stdenv.isDarwin [ xcbuild