From baf9ef419fb36a2198597894c72b23d8553b012a Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Tue, 27 Oct 2020 10:56:35 +0100
Subject: [PATCH v2] gnu: Add nut.
* gnu/packages/admin.scm (nut): New variable.
---
gnu/packages/admin.scm | 87 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
@@ -35,6 +35,7 @@
;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -70,6 +71,7 @@
#:use-module (gnu packages algebra)
#:use-module (gnu packages autogen)
#:use-module (gnu packages autotools)
+ #:use-module (gnu packages avahi)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
@@ -85,8 +87,10 @@
#:use-module (gnu packages elf)
#:use-module (gnu packages file)
#:use-module (gnu packages flex)
+ #:use-module (gnu packages freeipmi)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gettext)
+ #:use-module (gnu packages gd)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
@@ -110,6 +114,7 @@
#:use-module (gnu packages mcrypt)
#:use-module (gnu packages mpi)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages networking)
#:use-module (gnu packages openldap)
#:use-module (gnu packages patchutils)
#:use-module (gnu packages pciutils)
@@ -880,6 +885,88 @@ IPv6, proxies, and Unix sockets.")
(license (list license:bsd-3
license:bsd-2)))) ; atomicio.*, socks.c
+(define-public nut
+ (package
+ (name "nut")
+ (version "2.7.4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://networkupstools.org/source/" (version-major+minor version)
+ "/nut-" version ".tar.gz"))
+ (sha256
+ (base32
+ "19r5dm07sfz495ckcgbfy0pasx0zy3faa0q7bih69lsjij8q43lq"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:configure-flags
+ `("--with-all"
+ "--with-openssl"
+ ;; nut supports a bridge to the powerman-daemon to handle
+ ;; powerman-supported devices. For this bridge, powerman is
+ ;; required.
+ "--without-powerman"
+ ,(string-append "--with-udev-dir="
+ (assoc-ref %outputs "out")
+ "/lib/udev"))
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'fix-libgd-check
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (substitute* "configure"
+ (("-L/usr/X11R6/lib")
+ ;; without --static, it won't find zlib and libjpeg
+ "$(pkg-config --static --libs gdlib)"))
+ #t))
+ (add-before 'build 'fix-search-paths
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; nutscan will search libraries only under output/lib, and in
+ ;; some standard path (e.g., /usr/lib). Add correct paths here
+ (substitute* "tools/nut-scanner/nutscan-init.c"
+ (("LIBDIR,")
+ (string-append
+ "LIBDIR,\n"
+ (string-join
+ (map (lambda (label)
+ (string-append "\"" (assoc-ref inputs label) "/lib/\""))
+ '("avahi" "freeipmi" "libusb" "neon" "net-snmp"))
+ ",\n")
+ ",\n")))
+ #t)))))
+ (native-inputs
+ `(("autoconf" ,autoconf)
+ ("cppunit" ,cppunit)
+ ("pkg-config" ,pkg-config)))
+ (inputs
+ `(("avahi" ,avahi)
+ ("libusb" ,libusb-compat)
+ ("libltdl" ,libltdl)
+ ;; libxpm and libx11 required when cgi is enabled
+ ("libxpm" ,libxpm)
+ ("libx11" ,libx11)
+ ("freeipmi" ,freeipmi)
+ ("gd" ,gd)
+ ("neon" ,neon)
+ ("openssl" ,openssl-1.0)
+ ("net-snmp" ,net-snmp)))
+ (home-page "https://networkupstools.org")
+ (license
+ (list
+ ;; - most files under gpl2+
+ license:gpl2+
+ ;; - scripts/python/ under gpl3+
+ license:gpl3+
+ ;; - scripts/perl/Nut.pm same as perl (either gpl1+ or artistic)
+ license:gpl1+ license:artistic2.0))
+ (synopsis "Collection of programs for monitoring and administering UPS")
+ (description "Network @acronym{UPS, Uninterruptible Power Supply} Tools is
+a collection of programs which provide a common interface for monitoring and
+administering @acronym{UPS} @acronym{PDU,Power Distribution Unit} and
+@acronym{SCD, Solar Controller Device} hardware. It uses a layered approach
+to connect all of the parts. Drivers are provided for a wide assortment of
+equipment.")))
+
(define-public sipcalc
(package
(name "sipcalc")
--
2.29.2