From 64d4fe982b19440925895cf18e4be0385bcaaeeb Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Wed, 14 Dec 2022 23:23:48 +0100 Subject: [PATCH v5 1/4] gnu: Add bolt-service-type. * gnu/services/linux.scm (bolt-service-type): New variable. diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index 60e2093e1d..3d0cb80b8b 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 raid5atemyhomework ;;; Copyright © 2021 B. Wilson ;;; Copyright © 2022 Josselin Poiret +;;; Copyright © 2021-2022 Petr Hodina ;;; ;;; This file is part of GNU Guix. ;;; @@ -29,15 +30,21 @@ (define-module (gnu services linux) #:use-module (guix i18n) #:use-module (guix ui) #:use-module (gnu services) + #:use-module (gnu services dbus) #:use-module (gnu services base) #:use-module (gnu services shepherd) + #:use-module (gnu system shadow) #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (ice-9 match) - #:export (earlyoom-configuration + #:export (boltd-configuration + boltd-configuration? + boltd-service-type + + earlyoom-configuration earlyoom-configuration? earlyoom-configuration-earlyoom earlyoom-configuration-minimum-available-memory @@ -65,6 +72,52 @@ (define-module (gnu services linux) zram-device-configuration-priority zram-device-service-type)) + +;;; +;;; Thunderbolt daemon. +;;; + +(define-record-type* + boltd-configuration make-boltd-configuration boltd-configuration? + (package boltd-configuration-package ; package + (default bolt))) + +(define boltd-activation-service + #~(begin + (use-modules (guix build utils)) + (mkdir-p "/var/lib/boltd"))) + +(define (boltd-shepherd-service config) + (shepherd-service (documentation "Run the boltd daemon.") + (provision '(boltd)) + (requirement '(dbus-system udev)) + (start #~(make-forkexec-constructor (list (string-append #$bolt + "/libexec/boltd")))) + (stop #~(make-kill-destructor)))) + +(define (boltd-udev-rule config) + (let ((package (boltd-configuration-package config))) + (file->udev-rule "90-bolt.rules" (file-append package + "/lib/udev/rules.d/90-bolt.rules")))) + + +(define boltd-service-type + (service-type (name 'boltd) + (default-value (boltd-configuration)) + (extensions + (list (service-extension udev-service-type + (compose list boltd-udev-rule)) + (service-extension dbus-root-service-type + (compose list boltd-configuration-package)) + (service-extension activation-service-type + (const + boltd-activation-service)) + (service-extension + shepherd-root-service-type + (compose list boltd-shepherd-service)))) + (description + "Run @command{boltd}, the Thunderbolt daemon."))) + ;;; ;;; Early OOM daemon. -- 2.38.1