Subject: [PATCH v2 3/3] services: Add corectrl-helper-service-type.

From: Ashvith Shetty <[email-masked]>
Date: Tue, 31 Dec 2024 23:39:49 +0530

From: Ashvith Shetty <[email-masked]>

* gnu/services/admin.scm: New file.
(corectrl-helper-service-type): new variable.
* gnu/local.mk: Add them.
* doc/guix.texi (Miscellaneous Services): Document it.
---
 doc/guix.texi          | 32 ++++++++++++++++++++++++++++++++
 gnu/services/admin.scm | 27 ++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 924f13f0f6..9330525c61 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -135,6 +135,7 @@ Copyright @copyright{} 2024 Nigko Yerden@*
 Copyright @copyright{} 2024 Troy Figiel@*
 Copyright @copyright{} 2024 Sharlatan Hellseher@*
 Copyright @copyright{} 2024 45mg@*
+Copyright @copyright{} 2024 Ashvith Shetty@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -42590,6 +42591,37 @@ empty list means that no type is specified.
 
 @end deftp
 
+@cindex corectrl-helper
+@subsubheading CoreCtrl Helper Service
+
+The @code{(gnu services admin)} module provides a DBus service for 
+interacting with system hardware resources, such as CPU and GPU, 
+enabling advanced control and management through the CoreCtrl application.
+
+@defvar corectrl-helper-service-type
+The service type for @command{corectrl}, which provides a helper service.
+
+@lisp
+(service corectrl-helper-service-type)
+@end lisp
+@end defvar
+
+
+@deftp {Data Type} corectrl-helper-configuration
+This is the data type representing the configuration of corectrl-helper.
+
+@table @asis
+@item @code{corectrl} (default: @code{corectrl}) (type: package)
+
+The @command{corectrl} executable to use.
+@end table
+@end deftp
+
+For more details, please read the 
+@uref{https://gitlab.com/corectrl/corectrl/-/wikis/Installation, Installation} 
+and 
+@uref{https://gitlab.com/corectrl/corectrl/-/wikis/Setup, Setup} wiki pages.
+
 @c %end of fragment
 
 @node Privileged Programs
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 571af6a04e..42cefdf256 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2023 Giacomo Leidi <[email-masked]>
 ;;; Copyright © 2024 Gabriel Wicki <[email-masked]>
 ;;; Copyright © 2024 Richard Sent <[email-masked]>
+;;; Copyright © 2024 Ashvith Shetty <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@ (define-module (gnu services admin)
   #:use-module (gnu packages linux)
   #:use-module (gnu services)
   #:use-module (gnu services configuration)
+  #:use-module (gnu services dbus)
   #:use-module (gnu services mcron)
   #:use-module (gnu services shepherd)
   #:use-module (gnu system accounts)
@@ -108,7 +110,11 @@ (define-module (gnu services admin)
             resize-file-system-configuration-cloud-utils
             resize-file-system-configuration-e2fsprogs
             resize-file-system-configuration-btrfs-progs
-            resize-file-system-configuration-bcachefs-tools))
+            resize-file-system-configuration-bcachefs-tools
+
+            corectrl-helper-service-type
+            corectrl-helper-configuration
+            corectrl-helper-configuration?))
 
 ;;; Commentary:
 ;;;
@@ -679,4 +685,23 @@ (define resize-file-system-service-type
      (service-extension shepherd-root-service-type
                         (compose list resize-file-system-shepherd-service))))))
 
+;;;
+;;; CoreCtrl helper service.
+;;;
+
+(define-configuration corectrl-helper-configuration
+  (corectrl (file-like corectrl) "The corectrl package"))
+
+(define (corectrl-helper-dbus-service config)
+  (list (corectrl-helper-configuration-corectrl config)))
+
+(define corectrl-helper-service-type
+  (service-type (name 'corectrl-helper)
+                (extensions (list (service-extension dbus-root-service-type
+                                                     corectrl-helper-dbus-service)
+                                  (service-extension polkit-service-type
+                                                     corectrl-helper-dbus-service)))
+                (default-value (corectrl-helper-configuration))
+                (description "Run corectrl-helper, an essential service for the corectrl application.")))
+
 ;;; admin.scm ends here
-- 
2.46.0