| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 |
|
| 22 | |
| 23 |
|
| 24 | |
| 25 |
|
| 26 | |
| 27 |
|
| 28 | (define-module (gnu packages power)
|
| 29 | #:use-module (gnu packages)
|
| 30 | #:use-module (gnu packages admin)
|
| 31 | #:use-module (gnu packages base)
|
| 32 | #:use-module (gnu packages bash)
|
| 33 | #:use-module (gnu packages check)
|
| 34 | #:use-module (gnu packages disk)
|
| 35 | #:use-module (gnu packages file-systems)
|
| 36 | #:use-module (gnu packages freedesktop)
|
| 37 | #:use-module (gnu packages gawk)
|
| 38 | #:use-module (gnu packages glib)
|
| 39 | #:use-module (gnu packages instrumentation)
|
| 40 | #:use-module (gnu packages libusb)
|
| 41 | #:use-module (gnu packages linux)
|
| 42 | #:use-module (gnu packages man)
|
| 43 | #:use-module (gnu packages networking)
|
| 44 | #:use-module (gnu packages pkg-config)
|
| 45 | #:use-module (gnu packages python-xyz)
|
| 46 | #:use-module (gnu packages ruby-xyz)
|
| 47 | #:use-module (gnu packages virtualization)
|
| 48 | #:use-module (guix build-system gnu)
|
| 49 | #:use-module (guix build-system pyproject)
|
| 50 | #:use-module (guix download)
|
| 51 | #:use-module (guix git-download)
|
| 52 | #:use-module (guix gexp)
|
| 53 | #:use-module ((guix licenses) #:prefix license:)
|
| 54 | #:use-module (guix packages))
|
| 55 |
|
| 56 | (define-public apcupsd
|
| 57 | (package
|
| 58 | (name "apcupsd")
|
| 59 | (version "3.14.14")
|
| 60 | (source (origin
|
| 61 | (method url-fetch)
|
| 62 | (uri
|
| 63 | (string-append
|
| 64 | "mirror://sourceforge/" name "/" name " - Stable/" version
|
| 65 | "/" name "-" version ".tar.gz"))
|
| 66 | (sha256
|
| 67 | (base32
|
| 68 | "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv"))))
|
| 69 | (outputs '("out" "doc"))
|
| 70 | (build-system gnu-build-system)
|
| 71 | (arguments
|
| 72 | (list
|
| 73 | #:configure-flags
|
| 74 | #~(list
|
| 75 | |
| 76 | (string-append "--exec-prefix=" #$output)
|
| 77 | (string-append "--mandir=" #$output "/share/man")
|
| 78 | (string-append "--sbindir=" #$output "/sbin")
|
| 79 | (string-append "--sysconfdir=" #$output "/etc/apcupsd")
|
| 80 | (string-append "--with-halpolicydir=" #$output "/share/halpolicy")
|
| 81 |
|
| 82 | |
| 83 | "--with-distname=GNU Guix"
|
| 84 | "--disable-install-distdir"
|
| 85 |
|
| 86 | |
| 87 | "--localstatedir=/var"
|
| 88 | "--with-log-dir=/var/log"
|
| 89 | "--with-pid-dir=/run"
|
| 90 | "--with-lock-dir=/run/apcupsd/lock"
|
| 91 | "--with-nologin=/run/apcupsd"
|
| 92 | "--with-pwrfail-dir=/run/apcupsd"
|
| 93 |
|
| 94 | |
| 95 | |
| 96 | |
| 97 | (string-append "ac_cv_path_SHUTDOWN=/nope")
|
| 98 | (string-append "ac_cv_path_APCUPSD_MAIL=/nope")
|
| 99 | |
| 100 | |
| 101 | (string-append "ac_cv_path_WALL=/nope")
|
| 102 |
|
| 103 | |
| 104 | "--enable-usb"
|
| 105 | "--enable-modbus-usb")
|
| 106 | #:tests? #f |
| 107 | #:modules (cons '(ice-9 ftw) %default-gnu-modules)
|
| 108 | #:phases
|
| 109 | #~(modify-phases %standard-phases
|
| 110 | (add-before 'configure 'remove-time-from-manual
|
| 111 | (lambda _
|
| 112 | |
| 113 | (substitute* "doc/manual/manual.rst"
|
| 114 | (("\\| \\|date\\| \\|time\\|") ""))
|
| 115 | (substitute* "autoconf/variables.mak.in"
|
| 116 | (("^(RST2HTMLOPTS = .*) --time (.*)" all pref suff)
|
| 117 | (string-append pref " " suff)))))
|
| 118 | (add-after 'build 'build-manual
|
| 119 | (lambda _
|
| 120 | (invoke "make" "-C" "doc/manual" "manual.html")))
|
| 121 | (add-after 'install-license-files 'move-doc
|
| 122 | (lambda _
|
| 123 | (let ((target (string-append #$output:doc
|
| 124 | "/share/doc/"
|
| 125 | (strip-store-file-name #$output))))
|
| 126 | (mkdir-p target)
|
| 127 | (for-each (lambda (f)
|
| 128 | (copy-file (string-append "doc/manual/" f)
|
| 129 | (string-append target "/" f)))
|
| 130 | (scandir "doc/manual"
|
| 131 | (lambda (f)
|
| 132 | (or (string-suffix? ".png" f)
|
| 133 | (string-suffix? ".html" f))))))))
|
| 134 | |
| 135 | (add-after 'install 'remove-smtp
|
| 136 | (lambda _
|
| 137 | (delete-file (string-append #$output "/sbin/smtp"))))
|
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | (add-after 'install 'remove-etc-apcupsd
|
| 144 | (lambda _
|
| 145 | (delete-file-recursively
|
| 146 | (string-append #$output "/etc/apcupsd")))))))
|
| 147 | (native-inputs (list mandoc pkg-config python-docutils-0.19 util-linux))
|
| 148 | (inputs (list libusb libusb-compat))
|
| 149 | (home-page "http://www.apcupsd.org")
|
| 150 | (synopsis "Daemon for controlling APC UPSes")
|
| 151 | (description "@command{apcupsd} can be used for power management and
|
| 152 | controlling most of @acronym{APC, American Power Conversion}’s @acronym{UPS,
|
| 153 | Uninterruptible Power Supply} models. @command{apcupsd} works with most of
|
| 154 | APC’s Smart-UPS models as well as most simple signalling models such a
|
| 155 | Back-UPS, and BackUPS-Office.")
|
| 156 | (license license:gpl2)))
|
| 157 |
|
| 158 | (define-public tuned-minimal
|
| 159 | (package
|
| 160 | (name "tuned-minimal")
|
| 161 | (version "2.27.0")
|
| 162 | (source (origin
|
| 163 | (method git-fetch)
|
| 164 | (uri (git-reference
|
| 165 | (url "https://github.com/redhat-performance/tuned")
|
| 166 | (commit (string-append "v" version))))
|
| 167 | (file-name (git-file-name name version))
|
| 168 | (sha256
|
| 169 | (base32
|
| 170 | "11h65i65y0ly3iw8kkhzq6mv8csw9jkgy57k51jf3g99w57pcl9y"))))
|
| 171 | (build-system pyproject-build-system)
|
| 172 | (arguments
|
| 173 | (list
|
| 174 | |
| 175 | #:test-flags #~'("-k" "not udev and not get_device")
|
| 176 | #:phases
|
| 177 | #~(modify-phases %standard-phases
|
| 178 | (add-after 'unpack 'patch-paths
|
| 179 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 180 | (substitute* "Makefile"
|
| 181 | (("^PYTHON_SITELIB = .*")
|
| 182 | (simple-format #f "PYTHON_SITELIB = ~a\n"
|
| 183 | (site-packages inputs outputs)))
|
| 184 | |
| 185 | (("mkdir -p \\$\\(DESTDIR\\)/var/lib/tuned") "")
|
| 186 | (("mkdir -p \\$\\(DESTDIR\\)/var/log/tuned") "")
|
| 187 | (("mkdir -p \\$\\(DESTDIR\\)/run/tuned") "")
|
| 188 | |
| 189 | ((".*\\$\\(DESTDIR\\)\\$\\(UNITDIR\\).*\\.service.*") "")
|
| 190 | |
| 191 | |
| 192 | ((".*\\$\\(DESTDIR\\).*tuned-gui.*") ""))
|
| 193 | |
| 194 | (substitute* (cons*
|
| 195 | "experiments/powertop2tuned.py"
|
| 196 | "tuned-adm.bash"
|
| 197 | "tuned/consts.py"
|
| 198 | (find-files "profiles"
|
| 199 | (lambda (name stat)
|
| 200 | (and (string-suffix? ".sh" name)
|
| 201 | (eq? 'regular (stat:type stat))
|
| 202 | (access? name X_OK)))))
|
| 203 | (("/etc/tuned")
|
| 204 | (string-append #$output "/etc/tuned"))
|
| 205 | (("/usr/lib/tuned")
|
| 206 | (string-append #$output "/lib/tuned")))
|
| 207 | (substitute* "experiments/powertop2tuned.py"
|
| 208 | (("/usr/sbin/powertop")
|
| 209 | (search-input-file inputs "sbin/powertop")))
|
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | (substitute* "tuned/consts.py"
|
| 215 | (("/etc/modprobe\\.d/tuned\\.conf")
|
| 216 | "/etc/tuned/modprobe.d/tuned.conf"))))
|
| 217 | |
| 218 | |
| 219 | |
| 220 | (replace 'build
|
| 221 | (lambda* (#:key inputs #:allow-other-keys)
|
| 222 | (invoke "make" "html"
|
| 223 | (string-append
|
| 224 | "PYTHON=" (search-input-file inputs "bin/python3")))))
|
| 225 | (replace 'install
|
| 226 | (lambda _
|
| 227 | (invoke "make" "install" "install-ppd" "install-html"
|
| 228 | (string-append "PREFIX=" #$output)
|
| 229 | (string-append "SYSCONFDIR=" #$output "/etc")
|
| 230 | (string-append "TMPFILESDIR=" #$output "/run/tuned"))))
|
| 231 | (add-before 'check 'set-check-pythonpath
|
| 232 | (lambda _
|
| 233 | (setenv "PYTHONPATH" "tests/unit")))
|
| 234 | (add-before 'wrap 'wrap-gi-and-path
|
| 235 | (lambda* (#:key inputs #:allow-other-keys)
|
| 236 | (for-each
|
| 237 | (lambda (binary)
|
| 238 | (wrap-program binary
|
| 239 | `("GI_TYPELIB_PATH" =
|
| 240 | (,(string-append #$(this-package-input "glib")
|
| 241 | "/lib/girepository-1.0")))))
|
| 242 | (find-files (string-append #$output "/sbin"))))))))
|
| 243 | (native-inputs (list python-pytest
|
| 244 | ruby-asciidoctor))
|
| 245 | (inputs
|
| 246 | (list bash-minimal
|
| 247 | ethtool
|
| 248 | gawk
|
| 249 | glib
|
| 250 | hdparm
|
| 251 | kmod
|
| 252 | iproute
|
| 253 | powertop
|
| 254 | python-dbus
|
| 255 | python-pyinotify
|
| 256 | python-linux-procfs
|
| 257 | python-pygobject
|
| 258 | python-pyudev
|
| 259 | systemtap
|
| 260 | util-linux
|
| 261 | virt-what))
|
| 262 | (synopsis "Dynamic adaptive system tuning daemon")
|
| 263 | (description
|
| 264 | "The TuneD package contains a daemon that tunes system settings
|
| 265 | dynamically. It does so by monitoring the usage of several system components
|
| 266 | periodically. Based on that information components will then be put into lower
|
| 267 | or higher power saving modes to adapt to the current usage.")
|
| 268 | (home-page "https://tuned-project.org")
|
| 269 | (license (list license:gpl2+ license:cc-by-sa3.0))))
|
| 270 |
|
| 271 | (define-public tuned
|
| 272 | (package
|
| 273 | (inherit tuned-minimal)
|
| 274 | (name "tuned")
|
| 275 | (inputs
|
| 276 | (modify-inputs inputs
|
| 277 | (prepend dmidecode perf wireless-tools)))))
|