Subject: Re: bug#49578: [PATCH] Add bolt

From: phodina <[email-masked]>
Date: Tue, 10 Jan 2023 02:49:12 +0000

Hi Ludo’,

removed the deprecated contruct make-forkexec-constructor/container and changed bolt into boltd.

Also added plasma-thunderbolt package and documentation for the service.

----
Petr

From 7b87d90d8bf6d6b8188f90f2308a1d96a7a2095c Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sun, 14 Aug 2022 22:13:48 +0200
Subject: [PATCH v5 3/4] gnu: Add plasma-thunderbolt.

* gnu/packages/kde-plasma.scm (plasma-thunderbolt): New variable.

diff --git a/gnu/packages/kde-plasma.scm b/gnu/packages/kde-plasma.scm
index 2a3d86f801..3a392bedc9 100644
--- a/gnu/packages/kde-plasma.scm
+++ b/gnu/packages/kde-plasma.scm
@@ -1477,6 +1477,40 @@ (define-public plasma-bigscreen
 is controllable via voice or TV remote.")
     (license license:gpl2+)))
 
+(define-public plasma-thunderbolt
+  (package
+    (name "plasma-thunderbolt")
+    (version "5.25.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://kde/stable/plasma/"
+                                  version
+                                  "/"
+                                  name
+                                  "-"
+                                  version
+                                  ".tar.xz"))
+              (sha256
+               (base32
+                "0hjvkss0qfmwhrsba83wfxwxhikvzf56faan325ic0iv7fdaj3ns"))))
+    (build-system qt-build-system)
+    (native-inputs (list dbus extra-cmake-modules))
+    (arguments
+     (list #:tests? #f))
+    (inputs (list bolt
+                  kcmutils
+                  kcoreaddons
+                  kdbusaddons
+                  kdeclarative
+                  ki18n
+                  knotifications
+                  qtdeclarative-5))
+    (home-page "https://invent.kde.org/plasma/plasma-thunderbolt")
+    (synopsis "Plasma integration for controlling Thunderbolt devices")
+    (description "This package provides Plasma integration for controlling
+Thunderbolt devices.")
+    (license (list license:bsd-3 license:gpl2 license:gpl3))))
+
 (define-public plasmatube
   (package
     (name "plasmatube")
-- 
2.38.1

From 0bea70cd8e565b6e03b756ca380ffc16274822c4 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Thu, 15 Dec 2022 10:26:08 +0100
Subject: [PATCH v5 4/4] gnu: kinfocenter: Add plasma-thunderbolt.

* gnu/packages/kde-plasma.scm (plasma-thunderbolt): New variable.

diff --git a/gnu/packages/kde-plasma.scm b/gnu/packages/kde-plasma.scm
index 3a392bedc9..5904eba391 100644
--- a/gnu/packages/kde-plasma.scm
+++ b/gnu/packages/kde-plasma.scm
@@ -1416,7 +1416,7 @@ (define-public plasma
                              plasma-nm
                              plasma-pa
                              plasma-systemmonitor
-                             ;; plasma-thunderbolt ;; waiting for bolt
+                             plasma-thunderbolt
                              plasma-vault
                              plasma-workspace
                              plasma-workspace-wallpapers
-- 
2.38.1

From 64d4fe982b19440925895cf18e4be0385bcaaeeb Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
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 <[email-masked]>
 ;;; Copyright © 2021 B. Wilson <[email-masked]>
 ;;; Copyright © 2022 Josselin Poiret <[email-masked]>
+;;; Copyright © 2021-2022 Petr Hodina <[email-masked]>
 ;;;
 ;;; 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>
+  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

From 51112a1d2a5a1fadeafce288270aa5ea17cc23b7 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Tue, 10 Jan 2023 03:15:27 +0100
Subject: [PATCH v5 2/4] gnu: linux: Add boltd-service-type.

* doc/guix.texi ("Linux Services")[boltd-service-type]: Document them.

diff --git a/doc/guix.texi b/doc/guix.texi
index aef3890298..fbd006f120 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36940,6 +36940,38 @@ The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}
 @end table
 @end deftp
 
+@cindex boltd
+@cindex thunderbolt daemon
+@cindex Thunderbolt daemon
+@subsubheading Thunderbolt daemon Service
+
+The Thunderbolt daemon service provides a managment for the Thunderbolt 3
+interface bus found on newer machines.  The daemon configures
+the Thunderbolt security levels:
+@itemize
+@item No security - device works without requesting authorization
+@item User authorization - user must approve the device first
+@item Secure Connect - uses pre-shared keys to approve specific devices
+@item Display Port Only - port functions only as a video output
+@end itemize
+
+@deffn {Scheme Variable} boltd-device-service-type
+This service starts the @code{boltd} daemon that manages the connected device
+on the Thunderbolt bus.  The service's value is a
+@code{boltd-device-configuration} record.
+
+@deftp {Data Type} boltd-device-configuration
+This is the data type representing the configuration for the boltd-device
+service.
+
+@table @asis
+@item @code{bolt} (default @code{bolt})
+This is the default package that will be used.
+@end table
+
+@end deftp
+@end deffn
+
 @cindex zram
 @cindex compressed swap
 @cindex Compressed RAM-based block devices
-- 
2.38.1