all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob dfe7d3616b1b6830d0f0e7b91867de4e821aa3f2 10318 bytes (raw)
name: gnu/packages/tlp.scm 	 # note: path name is non-authoritative(*)

  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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2018-2022 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2019 Stefan Stefanović <stefanx2ovic@gmail.com>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages tlp)
  #:use-module (guix packages)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (guix git-download)
  #:use-module (gnu packages admin) ;inetutils
  #:use-module (gnu packages base) ;grep
  #:use-module (gnu packages bash)
  #:use-module (gnu packages check) ;python-discover
  #:use-module (gnu packages glib) ;dbus
  #:use-module (gnu packages haskell-apps) ;shellcheck
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages linux) ;eudev
  #:use-module (gnu packages networking) ;ethtool
  #:use-module (gnu packages pciutils)
  #:use-module (gnu packages perl) ;ethtool
  #:use-module ((guix licenses) #:prefix license:))

(define-public tlp
  (package
    (name "tlp")
    (version "1.5.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/linrunner/TLP")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0cssclk2brhwvn9dm7h5snm2svwy0c8cfr4z2cgkdkac2pfaaxw4"))))
    (native-inputs
     (list shellcheck))
    (inputs
     `(("bash" ,bash)
       ("dbus" ,dbus)
       ("ethtool" ,ethtool)
       ("eudev" ,eudev)
       ("grep" ,grep)
       ("hdparm" ,hdparm)
       ("inetutils" ,inetutils)
       ("iw" ,iw)
       ("kmod" ,kmod)
       ("pciutils" ,pciutils)
       ("perl" ,perl)
       ("rfkill" ,rfkill)
       ("sed" ,sed)
       ("usbutils" ,usbutils)
       ("util-linux" ,util-linux)
       ("wireless-tools" ,wireless-tools)
       ,@(if (let ((system (or (%current-target-system)
                               (%current-system))))
               (or (string-prefix? "i686-" system)
                   (string-prefix? "x86_64-" system)))
             `(("x86-energy-perf-policy" ,x86-energy-perf-policy))
             '())))
    (build-system gnu-build-system)
    (arguments
     ;; XXX: The full test suite is run with "checkall" but it requires
     ;; "checkbashisms" and "perlcritic", not yet packaged in Guix.
     `(#:test-target "shellcheck"
       #:modules ((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-1))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)            ; no configure script
         (add-before 'build 'setenv
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (setenv "TLP_WITH_SYSTEMD" "0")
               (setenv "TLP_NO_INIT" "1")
               (setenv "TLP_NO_PMUTILS" "1")
               (setenv "TLP_SBIN" (string-append out "/bin"))
               (setenv "TLP_BATD" (string-append out "/share/tlp/bat.d"))
               (setenv "TLP_BIN" (string-append out "/bin"))
               (setenv "TLP_TLIB" (string-append out "/share/tlp"))
               (setenv "TLP_FLIB" (string-append out "/share/tlp/func.d"))
               (setenv "TLP_ULIB" (string-append out "/lib/udev"))
               (setenv "TLP_CONFDEF"
                       (string-append out "/share/tlp/defaults.conf"))
               (setenv "TLP_CONFDIR" (string-append out "/etc/tlp.d"))
               (setenv "TLP_CONFREN"
                       (string-append out "/share/tlp/rename.conf"))
               (setenv "TLP_ELOD"
                       (string-append out "/lib/elogind/system-sleep"))
               (setenv "TLP_SHCPL"
                       (string-append out "/share/bash-completion/completions"))
               (setenv "TLP_MAN" (string-append out "/share/man"))
               (setenv "TLP_META" (string-append out "/share/metainfo")))))
         (add-before 'install 'fix-installation
           (lambda _
             ;; Stop the Makefile from trying to create system directories.
             (substitute* "Makefile"
               (("\\[ -f \\$\\(_CONFUSR\\) \\]") "#")
               (("install -d -m 755 \\$\\(_VAR\\)") "#"))))
         (replace 'install
           (lambda _ (invoke "make" "install-tlp" "install-man-tlp")))
         (add-after 'install 'wrap
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
                    (bin-files (find-files bin ".*")))
               (define (bin-directory input-name)
                 (let ((p (assoc-ref inputs input-name)))
                   (and p (string-append p "/bin"))))
               (define (sbin-directory input-name)
                 (string-append (assoc-ref inputs input-name) "/sbin"))
               (for-each (lambda (program)
                           (wrap-program program
                             `("PATH" ":" prefix
                               ,(append
                                 (filter-map bin-directory
                                             '("bash"
                                               "coreutils"
                                               "dbus"
                                               "eudev"
                                               "grep"
                                               "inetutils"
                                               "kmod"
                                               "perl"
                                               "sed"
                                               "usbutils"
                                               "util-linux"
                                               "x86-energy-perf-policy"))
                                 (filter-map sbin-directory
                                             '("ethtool"
                                               "hdparm"
                                               "iw"
                                               "pciutils"
                                               "rfkill"
                                               "wireless-tools"))))))
                         bin-files)))))))
    (home-page "https://linrunner.de/en/tlp/tlp.html")
    (synopsis "Power management tool for Linux")
    (description "TLP is a power management tool for Linux.  It comes with
a default configuration already optimized for battery life.  Nevertheless,
TLP is customizable to fulfil system requirements.  TLP settings are applied
every time the power supply source is changed.")
    ;; 'COPYING' is a custom version that says that one file is GPLv3+ and the
    ;; rest is GPLv2+.
    (license (list license:gpl2+ license:gpl3+))))

(define-public tlpui
  (package
    (name "tlpui")
    (version "1.5.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/d4nj1/TLPUI")
             (commit (string-append "tlpui-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0ca18hazxksx516nkh28f6rd0l1039nkn7mszqfy68c461061q1h"))))
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-setup.py
           ;; Install data_files to $out/share instead of /usr/share.
           (lambda _
             (substitute* "setup.py"
               (("/usr/") ""))))
         (add-after 'unpack 'use-tlp-input
           ;; Hard-code tlp-stat filename to avoid propagating "tlp".
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((tlp-stat (search-input-file inputs "/bin/tlp-stat")))
               (with-directory-excursion "tlpui"
                 (substitute* '("file.py" "settingshelper.py" "statui.py")
                   (("which\\(\"tlp-stat\"\\)")
                    (string-append "'" tlp-stat "'"))
                   (("\"tlp-stat\"")
                    (string-append "'" tlp-stat "'")))))))
         (add-before 'check 'fix-home-directory
           (lambda _
             ;; Tests fail with "Permission denied:
             ;; '/homeless-shelter'".
             (setenv "HOME" "/tmp")))
         ;; `sanity-check' phase errors out with the following
         ;; messages: "Unable to init server: Could not connect:
         ;; Connection refused" and "Error: cannot read user
         ;; configuration from /etc/tlp.conf or /etc/default/tlp".
         (delete 'sanity-check)
         (replace 'check
           (lambda _
             (invoke "python" "-m" "discover")))
         (add-after 'install 'wrap-gi-python
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (gi-typelib-path (getenv "GI_TYPELIB_PATH")))
               (wrap-program (string-append out "/bin/tlpui")
                 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path)))))))))
    (native-inputs
     (list `(,glib "bin") gobject-introspection python-discover))
    (inputs
     (list gtk+ python-pygobject tlp))
    (home-page "https://github.com/d4nj1/TLPUI")
    (synopsis "User interface for TLP written in Python")
    (description
     "The Python scripts in this project generate a GTK-UI to change
TLP configuration files easily.  It aims to protect users from setting
bad configuration and to deliver a basic overview of all the valid
configuration values.")
    (license license:gpl2+)))

debug log:

solving dfe7d3616b ...
found dfe7d3616b in https://yhetil.org/guix/20220323184855.25241-3-maximedevos@telenet.be/

applying [1/1] https://yhetil.org/guix/20220323184855.25241-3-maximedevos@telenet.be/
diff --git a/gnu/packages/tlp.scm b/gnu/packages/tlp.scm
new file mode 100644
index 0000000000..dfe7d3616b

Checking patch gnu/packages/tlp.scm...
Applied patch gnu/packages/tlp.scm cleanly.

index at:
100644 dfe7d3616b1b6830d0f0e7b91867de4e821aa3f2	gnu/packages/tlp.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.