;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2015 Sou Bunnbu ;;; ;;; 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 . (define-module (gnu services dbus) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system shadow) #:use-module (gnu system pam) #:use-module ((gnu packages glib) #:select (dbus)) #:use-module (gnu packages polkit) #:use-module (gnu packages admin) #:use-module (guix gexp) #:use-module (guix records) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (dbus-configuration dbus-configuration? dbus-root-service-type dbus-service polkit-service-type polkit-service)) ;;; ;;; D-Bus. ;;; (define-record-type* dbus-configuration make-dbus-configuration dbus-configuration? (dbus dbus-configuration-dbus ; (default dbus)) (services dbus-configuration-services ;list of (default '()))) (define (system-service-directory services) "Return the system service directory, containing @code{.service} files for all the services that may be activated by the daemon."
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; 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 rrdtool)
  #:use-module (guix git-download)
  #:use-module (gnu packages)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages base)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages groff)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages xml)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages))

(define-public rrdtool
  (package
    (name "rrdtool")
    (version "1.8.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/oetiker/rrdtool-1.x")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "04dhygsp34dykrnbbcqni5f7hih0hzqbnj6d2sl439lqbx9k3q3b"))))
    (build-system gnu-build-system)
    (inputs
     (list cairo
           freetype
           glib
           libxml2
           pango
           python))
    (native-inputs
     (list groff
           pkg-config
           ;; For tests.
           bc
           perl                         ; will also build Perl bindings
           tzdata-for-tests))
    (arguments
     (list
      #:disallowed-references (list (gexp-input tzdata-for-tests))
      #:phases
      #~(modify-phases %standard-phases
          (add-before 'check 'prepare-test-environment
            (lambda* (#:key inputs #:allow-other-keys)
              (setenv "TZDIR"
                      (search-input-directory inputs "share/zoneinfo"))))
          (add-after 'install 'remove-native-input-references
            (lambda _
              (let ((examples (string-append #$output
                                             "/share/rrdtool/examples")))
                ;; Drop shebangs from examples to avoid depending on native-input
                ;; perl.  It's clear from context and extension how to run them.
                (substitute* (find-files examples "\\.pl$")
                  (("^#!.*") ""))))))))
    (home-page "https://oss.oetiker.ch/rrdtool/")
    (synopsis "Time-series data storage and display system")
    (description
     "The Round Robin Database Tool (RRDtool) is a system to store and display
time-series data (e.g. network bandwidth, machine-room temperature, server
load average).  It stores the data in Round Robin Databases (RRDs), a very
compact way that will not expand over time.  RRDtool processes the extracted
data to enforce a certain data density, allowing for useful graphical
representation of data values.")
    (license license:gpl2+))) ; with license exception that allows combining
                              ; with many other licenses.
PATH. (let ((pid (primitive-fork))) (if (zero? pid) (call-with-output-file "/etc/machine-id" (lambda (port) (close-fdes 1) (dup2 (port->fdes port) 1) (execl prog))) (waitpid pid))))))) (define dbus-shepherd-service (match-lambda (($ dbus) (list (shepherd-service (documentation "Run the D-Bus system daemon.") (provision '(dbus-system)) (requirement '(user-processes)) (start #~(make-forkexec-constructor (list (string-append #$dbus "/bin/dbus-daemon") "--nofork" "--system") #:pid-file "/var/run/dbus/pid")) (stop #~(make-kill-destructor))))))) (define dbus-root-service-type (service-type (name 'dbus) (extensions (list (service-extension shepherd-root-service-type dbus-shepherd-service) (service-extension activation-service-type dbus-activation) (service-extension etc-service-type dbus-etc-files) (service-extension account-service-type (const %dbus-accounts)) (service-extension setuid-program-service-type dbus-setuid-programs))) ;; Extensions consist of lists of packages (representing D-Bus ;; services) that we just concatenate. (compose concatenate) ;; The service's parameters field is extended by augmenting ;; its 'services' field. (extend (lambda (config services) (dbus-configuration (inherit config) (services (append (dbus-configuration-services config) services))))) (default-value (dbus-configuration)))) (define* (dbus-service #:key (dbus dbus) (services '())) "Return a service that runs the \"system bus\", using @var{dbus}, with support for @var{services}. @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication facility. Its system bus is used to allow system services to communicate and be notified of system-wide events. @var{services} must be a list of packages that provide an @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration and policy files. For example, to allow avahi-daemon to use the system bus, @var{services} must be equal to @code{(list avahi)}." (service dbus-root-service-type (dbus-configuration (dbus dbus) (services services)))) ;;; ;;; Polkit privilege management service. ;;; (define-record-type* polkit-configuration make-polkit-configuration polkit-configuration? (polkit polkit-configuration-polkit ; (default polkit)) (actions polkit-configuration-actions ;list of (default '()))) (define %polkit-accounts (list (user-group (name "polkitd") (system? #t)) (user-account (name "polkitd") (group "polkitd") (system? #t) (comment "Polkit daemon user") (home-directory "/var/empty") (shell "/run/current-system/profile/sbin/nologin")))) (define %polkit-pam-services (list (unix-pam-service "polkit-1"))) (define (polkit-directory packages) "Return a directory containing an @file{actions} and possibly a @file{rules.d} sub-directory, for use as @file{/etc/polkit-1}." (with-imported-modules '((guix build union)) (computed-file "etc-polkit-1" #~(begin (use-modules (guix build union) (srfi srfi-26)) (union-build #$output (map (cut string-append <> "/share/polkit-1") (list #$@packages))))))) (define polkit-etc-files (match-lambda (($ polkit packages) `(("polkit-1" ,(polkit-directory (cons polkit packages))))))) (define polkit-setuid-programs (match-lambda (($ polkit) (list (file-append polkit "/lib/polkit-1/polkit-agent-helper-1") (file-append polkit "/bin/pkexec"))))) (define polkit-service-type (service-type (name 'polkit) (extensions (list (service-extension account-service-type (const %polkit-accounts)) (service-extension pam-root-service-type (const %polkit-pam-services)) (service-extension dbus-root-service-type (compose list polkit-configuration-polkit)) (service-extension etc-service-type polkit-etc-files) (service-extension setuid-program-service-type polkit-setuid-programs))) ;; Extensions are lists of packages that provide polkit rules ;; or actions under share/polkit-1/{actions,rules.d}. (compose concatenate) (extend (lambda (config actions) (polkit-configuration (inherit config) (actions (append (polkit-configuration-actions config) actions))))) (default-value (polkit-configuration)))) (define* (polkit-service #:key (polkit polkit)) "Return a service that runs the @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege management service}, which allows system administrators to grant access to privileged operations in a structured way. By querying the Polkit service, a privileged system component can know when it should grant additional capabilities to ordinary users. For example, an ordinary user can be granted the capability to suspend the system if the user is logged in locally." (service polkit-service-type (polkit-configuration (polkit polkit)))) ;;; dbus.scm ends here