Subject: [PATCH] gnu: bashtop: Add dependencies and wrap program with PATH

From: Josselin Poiret <[email-masked]>
Date: Sun, 14 Nov 2021 14:01:37 +0000

You're right, none of the needed dependencies of bashtop were
actually present in the package definition.  Here is a patch that
does work on my machine using `guix shell --pure bashtop -- bashtop`.

Best,
Josselin Poiret
-- >8 --

* gnu/packages/admin.scm (bashtop): Add dependencies, wrap the script
so that it can access the commands it needs.
---
 gnu/packages/admin.scm | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 2a7b0f310d..8f9125212c 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -71,6 +71,7 @@ (define-module (gnu packages admin)
   #:use-module (guix build-system python)
   #:use-module (guix build-system ruby)
   #:use-module (guix build-system trivial)
+  #:use-module (guix build-system copy)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -670,11 +671,29 @@ (define-public bashtop
               (sha256
                (base32
                 "07nlr6vmyb7yihaxj1fp424lmhwkdjl6mls92v90f6gsvikpa13v"))))
-    (build-system gnu-build-system)
+    (build-system copy-build-system)
     (arguments
-     '(#:make-flags (list (string-append "PREFIX=" %output))
-       #:tests? #f      ; bats test fails with loading load.bash
-       #:phases (modify-phases %standard-phases (delete 'configure))))
+     '(#:install-plan '(("./bashtop" "./bin/bashtop"))
+       #:phases (modify-phases %standard-phases
+		  (add-after 'install 'wrap
+	            (lambda* (#:key outputs #:allow-other-keys)
+		      (let ((paths (map (lambda (program)
+					  (dirname (which program)))
+					'("awk" "dd" "grep" "ip"
+					  "locale" "ps" "sed")))
+			    (bashtop (string-append (assoc-ref outputs
+							       "out")
+						    "/bin/bashtop")))
+			(wrap-program bashtop
+				      `("PATH" ":" = ,paths))))))))
+    (inputs
+     `(("coreutils" ,coreutils)
+       ("gawk" ,gawk)
+       ("glibc" ,glibc) ; for 'locale'
+       ("grep" ,grep)
+       ("iproute" ,iproute)
+       ("procps" ,procps)
+       ("sed" ,sed)))
     (home-page "https://github.com/aristocratos/bashtop")
     (synopsis "Linux/OSX/FreeBSD resource monitor")
     (description "Resource monitor that shows usage and stats for processor,
-- 
2.33.1