Subject: [bug#54068] [PATCH] Add xmrig and p2pool

From: Justin Veilleux <[email-masked]>
Date: Tue, 5 Apr 2022 20:51:12 -0400

This is the updated patch for xmrig, but I still have to figure out how 
to package some of p2pool's c++ dependencies.

Cheers.

From a8003036d713228d0f24324992d296161ac3187b Mon Sep 17 00:00:00 2001
From: terramorpha <[email-masked]>
Date: Tue, 5 Apr 2022 20:46:35 -0400
Subject: [PATCH] gnu: Add xmrig.

* gnu/packages/finance.scm (xmrig): New variable.
---
 gnu/packages/finance.scm | 50 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index 9f2d055048..953e6dd075 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -26,6 +26,7 @@
 ;;; Copyright © 2021 François J <[email-masked]>
 ;;; Copyright © 2021 Foo Chuan Wei <[email-masked]>
 ;;; Copyright © 2021 John Kehayias <[email-masked]>
+;;; Copyright © 2022 Justin Veilleux <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -93,6 +94,7 @@ (define-module (gnu packages finance)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages man)
   #:use-module (gnu packages maths)
+  #:use-module (gnu packages mpi)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages networking)
@@ -1978,3 +1980,51 @@ (define-public python-mt-940
 format used by SWIFT.  It returns smart Python collections for statistics
 and manipulation.")
     (license license:bsd-3)))
+
+(define-public xmrig
+  (package
+   (name "xmrig")
+    (version "6.16.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri
+        (git-reference
+         (url "https://github.com/xmrig/xmrig")
+         (commit (string-append "v" version))))
+       (sha256 (base32 "0mp7q14pfbdjvjai6nw6psqakr1hnzkkn4c51iw578866n2lmxw5"))))
+    (build-system cmake-build-system)
+    (inputs
+     (list
+      `(,hwloc "lib")
+      libuv
+      openssl))
+    (arguments
+     (list
+      ;; There are no tests.
+      #:tests? #f
+      #:modules '((guix build utils)
+                  (guix build cmake-build-system))
+      #:phases
+      #~(modify-phases
+         %standard-phases
+         (add-before 'configure 'disable-default-donation
+                     (lambda* (#:key outputs #:allow-other-keys)
+                       (substitute* "src/donate.h"
+                         (("constexpr const int kDefaultDonateLevel = 1;")
+                          "constexpr const int kDefaultDonateLevel = 0;")
+                         (("constexpr const int kMinimumDonateLevel = 1;")
+                          "constexpr const int kMinimumDonateLevel = 0;"))))
+         (replace 'install
+                  ;; There is no 'install' target, we must install xmrig manually
+                  (lambda* (#:key #:allow-other-keys)
+                    (install-file "xmrig"
+                                  (string-append #$output "/bin")))))))
+    (home-page "https://xmrig.com/")
+    (synopsis "Monero miner")
+    (description
+     "XMRig is a high performance, open source, cross platform RandomX, KawPow,
+CryptoNight, AstroBWT and GhostRider unified CPU/GPU miner and RandomX
+benchmark. Warning: This software, because of it's nature, has high energy
+consumption.")
+    (license license:gpl3+)))
-- 
2.34.0