;;; GNU Guix --- Functional package management for GNU
;;;
;;; 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 (bolt)
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services configuration)
#:use-module (gnu services linux)
#:use-module (gnu services shepherd)
#:use-module (gnu services dbus)
#:use-module (gnu services admin)
#:use-module (gnu system shadow)
#:use-module (gnu system pam)
#:use-module ((gnu system file-systems)
#:select (file-system-mapping))
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages cluster)
#:use-module (gnu packages connman)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages linux)
#:use-module (gnu packages firmware)
#:use-module (nongnu packages firmware)
#:use-module (gnu packages tor)
#:use-module (gnu packages usb-modeswitch)
#:use-module (gnu packages messaging)
#:use-module (gnu packages networking)
#:use-module (gnu packages ntp)
#:use-module (gnu packages gnome)
#:use-module (gnu packages ipfs)
#:use-module (gnu build linux-container)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix deprecation)
#:use-module (guix diagnostics)
#:use-module (guix i18n)
#:use-module (rnrs enums)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-43)
#:use-module (ice-9 match)
#:use-module (json)
#:export (bolt-configuration bolt-configuration? bolt-service-type))
;;
;;; Thunderbolt daemon.
;;;
(define-record-type* bolt-configuration
make-bolt-configuration
bolt-configuration?
(package
bolt-configuration-package ;package
(default bolt)))
(define (bolt-shepherd-service config)
(list (shepherd-service (documentation "Thunderbolt daemon")
(provision '(bolt))
(requirement '(dbus-system udev))
(start #~(make-forkexec-constructor '(#$(file-append
(bolt-configuration-package
config)
"/libexec/boltd")
"-v")
#:log-file "/var/log/bolt.log"))
(stop #~(make-kill-destructor)))))
(define %bolt-activation
#~(begin
(use-modules (guix build utils))
(mkdir-p "/var/lib/boltd/")))
(define (bolt-dbus-service config)
(list (wrapped-dbus-service (bolt-configuration-package config)
"libexec/boltd"
`(("BOLT_CONF_FILE_NAME" ,(file-append (bolt-configuration-package
config)
"/share/dbus-1/interfaces/org.freedesktop.bolt.xml"))))))
(define bolt-service-type
(service-type (name 'boltd)
(description
"Thunderbolt daemon manages the devices attached to the Thunderbolt
interface.")
(extensions (list (service-extension udev-service-type
(compose list
bolt-configuration-package))
(service-extension dbus-root-service-type
bolt-dbus-service)
(service-extension activation-service-type
(const %bolt-activation))
(service-extension
shepherd-root-service-type
bolt-shepherd-service)))
(default-value (bolt-configuration))))