Loading pkgs/by-name/im/imhex/package.nix +78 −27 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ lib, stdenv, cmake, llvm, darwin, fetchpatch, llvmPackages_17, fetchFromGitHub, mbedtls, gtk3, Loading @@ -21,13 +23,24 @@ nlohmann_json, yara, rsync, nix-update-script, autoPatchelfHook, makeWrapper, overrideSDK, }: let version = "1.35.4"; patterns_version = "1.35.4"; llvmPackages = llvmPackages_17; stdenv' = let baseStdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; in if stdenv.isDarwin then overrideSDK baseStdenv "11.0" else baseStdenv; patterns_src = fetchFromGitHub { name = "ImHex-Patterns-source-${patterns_version}"; owner = "WerWolv"; Loading @@ -37,7 +50,7 @@ let }; in stdenv.mkDerivation rec { stdenv'.mkDerivation (finalAttrs: { pname = "imhex"; inherit version; Loading @@ -46,19 +59,38 @@ stdenv.mkDerivation rec { fetchSubmodules = true; owner = "WerWolv"; repo = "ImHex"; rev = "refs/tags/v${version}"; rev = "refs/tags/v${finalAttrs.version}"; hash = "sha256-6QpmFkSMQpGlEzo7BHZn20c+q8CTDUB4yO87wMU5JT4="; }; nativeBuildInputs = [ autoPatchelfHook patches = [ # https://github.com/WerWolv/ImHex/pull/1910 # during https://github.com/NixOS/nixpkgs/pull/330303 it was discovered that ImHex # would not build on Darwin x86-64 # this temporary patch can be removed when the above PR is merged (fetchpatch { url = "https://github.com/WerWolv/ImHex/commit/69624a2661ea44db9fb8b81c3278ef69016ebfcf.patch"; hash = "sha256-LcUCl8Rfz6cbhop2StksuViim2bH4ma3/8tGVKFdAgg="; }) ]; # Comment out fixup_bundle in PostprocessBundle.cmake as we are not building a standalone application postPatch = lib.optionalString stdenv.isDarwin '' substituteInPlace cmake/modules/PostprocessBundle.cmake \ --replace-fail "fixup_bundle" "#fixup_bundle" ''; nativeBuildInputs = [ cmake llvm llvmPackages.llvm python3 perl pkg-config rsync ]; ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ] ++ lib.optionals stdenv.isDarwin [ makeWrapper ]; buildInputs = [ capstone Loading @@ -73,31 +105,50 @@ stdenv.mkDerivation rec { mbedtls nlohmann_json yara ]; ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk_11_0.frameworks.UniformTypeIdentifiers ]; # autoPatchelfHook only searches for *.so and *.so.*, and won't find *.hexpluglib # however, we will append to RUNPATH ourselves autoPatchelfIgnoreMissingDeps = [ "*.hexpluglib" ]; appendRunpaths = [ autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [ "*.hexpluglib" ]; appendRunpaths = lib.optionals stdenv.isLinux [ (lib.makeLibraryPath [ libGL ]) "${placeholder "out"}/lib/imhex/plugins" ]; cmakeFlags = [ "-DIMHEX_OFFLINE_BUILD=ON" "-DUSE_SYSTEM_CAPSTONE=ON" "-DUSE_SYSTEM_CURL=ON" "-DUSE_SYSTEM_FMT=ON" "-DUSE_SYSTEM_LLVM=ON" "-DUSE_SYSTEM_NLOHMANN_JSON=ON" "-DUSE_SYSTEM_YARA=ON" (lib.cmakeBool "IMHEX_OFFLINE_BUILD" true) (lib.cmakeBool "IMHEX_COMPRESS_DEBUG_INFO" false) # avoids error: cannot compress debug sections (zstd not enabled) (lib.cmakeBool "IMHEX_GENERATE_PACKAGE" stdenv.isDarwin) (lib.cmakeBool "USE_SYSTEM_CAPSTONE" true) (lib.cmakeBool "USE_SYSTEM_CURL" true) (lib.cmakeBool "USE_SYSTEM_FMT" true) (lib.cmakeBool "USE_SYSTEM_LLVM" true) (lib.cmakeBool "USE_SYSTEM_NLOHMANN_JSON" true) (lib.cmakeBool "USE_SYSTEM_YARA" true) ]; # rsync is used here so we can not copy the _schema.json files postInstall = '' postInstall = if stdenv.isLinux then '' mkdir -p $out/share/imhex rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,patterns} $out/share/imhex ''; rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,nodes,patterns} $out/share/imhex '' else if stdenv.isDarwin then '' mkdir -p $out/Applications mv $out/imhex.app $out/Applications rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,nodes,patterns} "$out/Applications/imhex.app/Contents/MacOS" install_name_tool \ -change "$out/lib/libimhex.${finalAttrs.version}${stdenv.hostPlatform.extensions.sharedLibrary}" \ "@executable_path/../Frameworks/libimhex.${finalAttrs.version}${stdenv.hostPlatform.extensions.sharedLibrary}" \ "$out/Applications/imhex.app/Contents/MacOS/imhex" makeWrapper "$out/Applications/imhex.app/Contents/MacOS/imhex" "$out/bin/imhex" '' else throw "Unsupported system"; passthru.updateScript = nix-update-script { }; meta = with lib; { description = "Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM"; Loading @@ -107,6 +158,6 @@ stdenv.mkDerivation rec { kashw2 cafkafk ]; platforms = platforms.linux; platforms = platforms.linux ++ platforms.darwin; }; } }) pkgs/top-level/all-packages.nix +0 −4 Original line number Diff line number Diff line Loading @@ -30180,10 +30180,6 @@ with pkgs; imgp = python3Packages.callPackage ../applications/graphics/imgp { }; imhex = callPackage ../by-name/im/imhex/package.nix { llvm = llvm_17; }; inframap = callPackage ../applications/networking/cluster/inframap { }; inkcut = libsForQt5.callPackage ../applications/misc/inkcut { }; Loading
pkgs/by-name/im/imhex/package.nix +78 −27 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ lib, stdenv, cmake, llvm, darwin, fetchpatch, llvmPackages_17, fetchFromGitHub, mbedtls, gtk3, Loading @@ -21,13 +23,24 @@ nlohmann_json, yara, rsync, nix-update-script, autoPatchelfHook, makeWrapper, overrideSDK, }: let version = "1.35.4"; patterns_version = "1.35.4"; llvmPackages = llvmPackages_17; stdenv' = let baseStdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; in if stdenv.isDarwin then overrideSDK baseStdenv "11.0" else baseStdenv; patterns_src = fetchFromGitHub { name = "ImHex-Patterns-source-${patterns_version}"; owner = "WerWolv"; Loading @@ -37,7 +50,7 @@ let }; in stdenv.mkDerivation rec { stdenv'.mkDerivation (finalAttrs: { pname = "imhex"; inherit version; Loading @@ -46,19 +59,38 @@ stdenv.mkDerivation rec { fetchSubmodules = true; owner = "WerWolv"; repo = "ImHex"; rev = "refs/tags/v${version}"; rev = "refs/tags/v${finalAttrs.version}"; hash = "sha256-6QpmFkSMQpGlEzo7BHZn20c+q8CTDUB4yO87wMU5JT4="; }; nativeBuildInputs = [ autoPatchelfHook patches = [ # https://github.com/WerWolv/ImHex/pull/1910 # during https://github.com/NixOS/nixpkgs/pull/330303 it was discovered that ImHex # would not build on Darwin x86-64 # this temporary patch can be removed when the above PR is merged (fetchpatch { url = "https://github.com/WerWolv/ImHex/commit/69624a2661ea44db9fb8b81c3278ef69016ebfcf.patch"; hash = "sha256-LcUCl8Rfz6cbhop2StksuViim2bH4ma3/8tGVKFdAgg="; }) ]; # Comment out fixup_bundle in PostprocessBundle.cmake as we are not building a standalone application postPatch = lib.optionalString stdenv.isDarwin '' substituteInPlace cmake/modules/PostprocessBundle.cmake \ --replace-fail "fixup_bundle" "#fixup_bundle" ''; nativeBuildInputs = [ cmake llvm llvmPackages.llvm python3 perl pkg-config rsync ]; ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ] ++ lib.optionals stdenv.isDarwin [ makeWrapper ]; buildInputs = [ capstone Loading @@ -73,31 +105,50 @@ stdenv.mkDerivation rec { mbedtls nlohmann_json yara ]; ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk_11_0.frameworks.UniformTypeIdentifiers ]; # autoPatchelfHook only searches for *.so and *.so.*, and won't find *.hexpluglib # however, we will append to RUNPATH ourselves autoPatchelfIgnoreMissingDeps = [ "*.hexpluglib" ]; appendRunpaths = [ autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [ "*.hexpluglib" ]; appendRunpaths = lib.optionals stdenv.isLinux [ (lib.makeLibraryPath [ libGL ]) "${placeholder "out"}/lib/imhex/plugins" ]; cmakeFlags = [ "-DIMHEX_OFFLINE_BUILD=ON" "-DUSE_SYSTEM_CAPSTONE=ON" "-DUSE_SYSTEM_CURL=ON" "-DUSE_SYSTEM_FMT=ON" "-DUSE_SYSTEM_LLVM=ON" "-DUSE_SYSTEM_NLOHMANN_JSON=ON" "-DUSE_SYSTEM_YARA=ON" (lib.cmakeBool "IMHEX_OFFLINE_BUILD" true) (lib.cmakeBool "IMHEX_COMPRESS_DEBUG_INFO" false) # avoids error: cannot compress debug sections (zstd not enabled) (lib.cmakeBool "IMHEX_GENERATE_PACKAGE" stdenv.isDarwin) (lib.cmakeBool "USE_SYSTEM_CAPSTONE" true) (lib.cmakeBool "USE_SYSTEM_CURL" true) (lib.cmakeBool "USE_SYSTEM_FMT" true) (lib.cmakeBool "USE_SYSTEM_LLVM" true) (lib.cmakeBool "USE_SYSTEM_NLOHMANN_JSON" true) (lib.cmakeBool "USE_SYSTEM_YARA" true) ]; # rsync is used here so we can not copy the _schema.json files postInstall = '' postInstall = if stdenv.isLinux then '' mkdir -p $out/share/imhex rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,patterns} $out/share/imhex ''; rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,nodes,patterns} $out/share/imhex '' else if stdenv.isDarwin then '' mkdir -p $out/Applications mv $out/imhex.app $out/Applications rsync -av --exclude="*_schema.json" ${patterns_src}/{constants,encodings,includes,magic,nodes,patterns} "$out/Applications/imhex.app/Contents/MacOS" install_name_tool \ -change "$out/lib/libimhex.${finalAttrs.version}${stdenv.hostPlatform.extensions.sharedLibrary}" \ "@executable_path/../Frameworks/libimhex.${finalAttrs.version}${stdenv.hostPlatform.extensions.sharedLibrary}" \ "$out/Applications/imhex.app/Contents/MacOS/imhex" makeWrapper "$out/Applications/imhex.app/Contents/MacOS/imhex" "$out/bin/imhex" '' else throw "Unsupported system"; passthru.updateScript = nix-update-script { }; meta = with lib; { description = "Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM"; Loading @@ -107,6 +158,6 @@ stdenv.mkDerivation rec { kashw2 cafkafk ]; platforms = platforms.linux; platforms = platforms.linux ++ platforms.darwin; }; } })
pkgs/top-level/all-packages.nix +0 −4 Original line number Diff line number Diff line Loading @@ -30180,10 +30180,6 @@ with pkgs; imgp = python3Packages.callPackage ../applications/graphics/imgp { }; imhex = callPackage ../by-name/im/imhex/package.nix { llvm = llvm_17; }; inframap = callPackage ../applications/networking/cluster/inframap { }; inkcut = libsForQt5.callPackage ../applications/misc/inkcut { };