Subject: [bug#31178] [PATCH] gnu: Add inxi.

From: Pierre Neidhardt <[email-masked]>
Date: Mon, 16 Apr 2018 18:08:30 +0530

* gnu/packages/admin.scm (inxi): New variable.
---
 gnu/packages/admin.scm               | 92 +++++++++++++++++++++++++++-
 gnu/packages/patches/inxi-path.patch | 13 ++++
 2 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/inxi-path.patch

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 6a7bed389..811e3d4cf 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -67,6 +67,7 @@
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages flex)
+  #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages mcrypt)
@@ -90,7 +91,10 @@
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages kerberos)
   #:use-module (gnu packages gtk)
-  #:use-module (gnu packages xml))
+  #:use-module (gnu packages xml)
+  #:use-module (gnu packages curl)
+  #:use-module (gnu packages file)
+  #:use-module (gnu packages web))
 
 (define-public aide
   (package
@@ -2505,3 +2509,89 @@ printed instead of after the entire file has been read, which is often too
 late.")
     (home-page "https://jwilk.net/software/hungrycat")
     (license license:expat)))
+
+(define-public inxi-minimal
+  (let ((version "3.0.04-1")
+        (real-name "inxi"))
+    (package
+      (name "inxi-minimal")
+      (version version)
+      (source
+       (origin
+         (method url-fetch)
+         (uri (string-append "https://github.com/smxi/inxi"
+                             "/archive/" version "/inxi.tar.gz"))
+         (file-name (string-append real-name "-" version ".tar.gz"))
+         (sha256
+          (base32
+           "14zxdsjgh9dbijmpp0hhvg2yiqqfwnqgcc6x8dpl1v15z1h1r7pc"))))
+      (build-system trivial-build-system)
+      (inputs
+       `(("perl" ,perl)))
+      (native-inputs `(("tar" ,tar)
+                       ("gzip" ,gzip)))
+      (arguments
+       `(#:modules
+         ((guix build utils))
+         #:builder
+         (begin
+           (use-modules (guix build utils))
+           (setenv "PATH" (string-append
+                           (assoc-ref %build-inputs "tar") "/bin" ":"
+                           (assoc-ref %build-inputs "gzip") "/bin"))
+           (system* "tar" "xvf" (assoc-ref %build-inputs "source"))
+           (with-directory-excursion ,(string-append real-name "-" version)
+             (with-fluids ((%default-port-encoding #f))
+               (substitute* "inxi"
+                 (("/usr/bin/env perl")
+                  (string-append (assoc-ref %build-inputs "perl") "/bin/perl"))))
+             (install-file "inxi" (string-append %output "/bin"))
+             (system* "gzip" "inxi.1")
+             (install-file "inxi.1.gz"
+                           (string-append %output "/share/doc/man/man1")))
+           #t)))
+      (home-page "https://smxi.org/docs/inxi.htm")
+      (synopsis "Script to get system information")
+      (description
+       "This package provides a script to get system information.")
+      (license license:gpl3+))))
+
+(define-public inxi
+  ;; Use `inxi --recommends` for a check list of all the external programs
+  ;; it can use.
+  ;; TODO: Include additional inputs once their corresponding packages is no
+  ;; longer missing: hddtemp, dig (from dnsutils), perl-xml-dumper.  ipmitool
+  ;; and ipmi-sensors.
+  (package
+    (inherit inxi-minimal)
+    (name "inxi")
+    (propagated-inputs
+     `(("coreutils" ,coreutils)         ; uptime
+       ("curl" ,curl)                   ; only if dig is missing.
+       ("dmidecode" ,dmidecode)
+       ;; ("fdisk" ,fdisk)                 ; only as fallback, but not sure for what
+       ("file" ,file)
+       ("gzip" ,gzip)
+       ("iproute2" ,iproute)            ; ip
+       ("kmod" ,kmod)                   ; modinfo
+       ("lm-sensors" ,lm-sensors)
+       ("mesa-utils" ,mesa-utils)
+       ("pciutils" ,pciutils)
+       ("perl-cpanel-json-xs" ,perl-cpanel-json-xs)
+       ("perl-http-tiny" ,perl-http-tiny)
+       ("perl-io-socket-ssl" ,perl-io-socket-ssl)
+       ("perl-json-xs" ,perl-json-xs)
+       ("perl-time-hires" ,perl-time-hires)
+       ("procps" ,procps)
+       ("tar" ,tar)
+       ("tree" ,tree)
+       ("util-linux" ,util-linux)       ; lsblk, lsusb, etc.
+       ;; ("wget" ,wget)                   ; only if dig and curl are missing.
+       ("wmctrl" ,wmctrl)
+       ("xdpyinfo" ,xdpyinfo)
+       ("xprop" ,xprop)
+       ("xrandr" ,xrandr)))
+    (synopsis "Script to get system information")
+    (description
+     "This package provides a script to get system information.")
+    (license license:gpl3+)))
diff --git a/gnu/packages/patches/inxi-path.patch b/gnu/packages/patches/inxi-path.patch
new file mode 100644
index 000000000..3f0d846bd
--- /dev/null
+++ b/gnu/packages/patches/inxi-path.patch
@@ -0,0 +1,13 @@
+Use dynamic PATH.
+
+--- a/inxi
++++ b/inxi
+@@ -75,5 +75,5 @@ my ($b_sysctl_disk,$b_update,$b_weather) = (1,1,1);
+ ## System
+ my ($bsd_type,$language,$os) = ('','','');
+ my ($cpu_sleep,$dl_timeout,$limit,$ps_count,$usb_level) = (0.35,4,10,5,0);
+-my @paths = qw(/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/X11R6/bin);
++my @paths = split /:/, $ENV{'PATH'};
+ my $sensors_cpu_nu = 0;
+
+ ## Tools
-- 
2.17.0