xmrig: 6.25.0 -> 6.26.0, make parametrizable

This introduces top-level arguments to customize the xmrig build,
exposing most of the available CMake options.

Users can now:
- Disable specific mining algorithms (e.g., KawPow, Argon2) to reduce binary size.
- Toggle core features like the HTTP API, TLS support, and MSR.

The new arguments follow Nixpkgs conventions, using `with...` for options
that pull in external dependencies and `enable...` for build-time toggles.

The installPhase is also updated to correctly handle the `xmrig-notls`
binary name when TLS support is disabled.
This commit is contained in:
Nikita Denisso
2026-05-28 09:13:01 +05:00
parent 3683ff6cd8
commit 6ede14b0ce
+61 -7
View File
@@ -9,17 +9,44 @@
hwloc,
kmod,
donateLevel ? 0,
# Algorithms
enableCnLite ? true,
enableCnHeavy ? true,
enableCnPico ? true,
enableCnFemto ? true,
enableRandomx ? true,
enableArgon2 ? true,
enableKawpow ? true,
enableGhostrider ? true,
# Features requiring external dependencies
withHwloc ? true,
withHttp ? true,
withTls ? true,
# Features (build toggles)
enableAsm ? true,
enableMsr ? true,
enableProfiling ? false,
enableSse4_1 ? true,
enableBenchmark ? true,
enableDmi ? true,
# Debug options
enableDebugLog ? false,
enableHwlocDebug ? false,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "xmrig";
version = "6.25.0";
version = "6.26.0";
src = fetchFromGitHub {
owner = "xmrig";
repo = "xmrig";
rev = "v${finalAttrs.version}";
hash = "sha256-X34djxUeSDwopwsipgrdFFFUP+tQ/uCNvupYzbegkEE=";
hash = "sha256-ZJKayM1kTLCXlQqqfN3MbAKPShi5OYafOdDbsMa0QIs=";
};
patches = [
@@ -28,10 +55,12 @@ stdenv.mkDerivation (finalAttrs: {
postPatch = ''
substituteAllInPlace src/donate.h
''
+ lib.optionalString withTls ''
substituteInPlace cmake/OpenSSL.cmake \
--replace "set(OPENSSL_USE_STATIC_LIBS TRUE)" "set(OPENSSL_USE_STATIC_LIBS FALSE)"
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
+ lib.optionalString (stdenv.hostPlatform.isLinux && enableMsr) ''
substituteInPlace src/hw/msr/Msr_linux.cpp \
--replace "/sbin/modprobe" "${kmod}/bin/modprobe"
'';
@@ -42,9 +71,34 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
libuv
libmicrohttpd
openssl
hwloc
]
++ lib.optional withHttp libmicrohttpd
++ lib.optional withTls openssl
++ lib.optional withHwloc hwloc;
cmakeFlags = [
(lib.cmakeBool "WITH_CN_LITE" enableCnLite)
(lib.cmakeBool "WITH_CN_HEAVY" enableCnHeavy)
(lib.cmakeBool "WITH_CN_PICO" enableCnPico)
(lib.cmakeBool "WITH_CN_FEMTO" enableCnFemto)
(lib.cmakeBool "WITH_RANDOMX" enableRandomx)
(lib.cmakeBool "WITH_ARGON2" enableArgon2)
(lib.cmakeBool "WITH_KAWPOW" enableKawpow)
(lib.cmakeBool "WITH_GHOSTRIDER" enableGhostrider)
(lib.cmakeBool "WITH_HWLOC" withHwloc)
(lib.cmakeBool "WITH_HTTP" withHttp)
(lib.cmakeBool "WITH_TLS" withTls)
(lib.cmakeBool "WITH_ASM" enableAsm)
(lib.cmakeBool "WITH_MSR" enableMsr)
(lib.cmakeBool "WITH_PROFILING" enableProfiling)
(lib.cmakeBool "WITH_SSE4_1" enableSse4_1)
(lib.cmakeBool "WITH_BENCHMARK" enableBenchmark)
(lib.cmakeBool "WITH_DMI" enableDmi)
(lib.cmakeBool "WITH_DEBUG_LOG" enableDebugLog)
(lib.cmakeBool "HWLOC_DEBUG" enableHwlocDebug)
];
inherit donateLevel;
@@ -52,7 +106,7 @@ stdenv.mkDerivation (finalAttrs: {
installPhase = ''
runHook preInstall
install -vD xmrig $out/bin/xmrig
install -vD ${if withTls then "xmrig" else "xmrig-notls"} $out/bin/xmrig
runHook postInstall
'';