[bug#75159,v2,3/3] services: Add corectrl-helper-service-type.

Message ID 87ikqg2f5h.fsf@iscas.ac.cn
State New
Headers
Series None |

Commit Message

Zheng Junjie Jan. 15, 2025, 4:52 p.m. UTC
  Ashvith Shetty <ashvithshetty10@gmail.com> writes:

> From: Ashvith Shetty <ashvith@noreply.codeberg.org>
>
> * 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 <goodoldpaul@autistici.org>
>  ;;; Copyright © 2024 Gabriel Wicki <gabriel@erlikon.ch>
>  ;;; Copyright © 2024 Richard Sent <richard@freakingpenguin.com>
> +;;; Copyright © 2024 Ashvith Shetty <ashvithshetty10@gmail.com>
>  ;;;
>  ;;; 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

I think it's better this way, I am not good at how to write the document
and description, may you modify it?
  

Patch

From 7ce5d94bf29d5877449345651ff7fcff921778cd Mon Sep 17 00:00:00 2001
Message-ID: <7ce5d94bf29d5877449345651ff7fcff921778cd.1736958803.git.zhengjunjie@iscas.ac.cn>
From: Ashvith Shetty <ashvith@noreply.codeberg.org>
Date: Wed, 15 Jan 2025 23:08:48 +0800
Subject: [PATCH] gnu: services: Add corectrl-service-type.

* gnu/services/admin.scm: (corectrl-service-type): new variable.
* doc/guix.texi (Miscellaneous Services): Document it.

Change-Id: If7df1e67b227b86bcf827be28c35181128579589
---
 doc/guix.texi             | 27 +++++++++++++++++++++
 gnu/local.mk              |  1 +
 gnu/services/corectrl.scm | 51 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100644 gnu/services/corectrl.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index 3cf1fedc301..a6d1256361f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -136,6 +136,7 @@ 
 Copyright @copyright{} 2024 Sharlatan Hellseher@*
 Copyright @copyright{} 2024 45mg@*
 Copyright @copyright{} 2025 Sören Tempel@*
+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
@@ -42730,6 +42731,32 @@  Miscellaneous Services
 
 @end deftp
 
+@cindex corectrl
+@subsubheading CoreCtrl Service
+
+The @code{(gnu services corectrl)} 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-service-type
+The service type for @command{corectrl}, which provides a service.
+
+@lisp
+(service corectrl-service-type)
+@end lisp
+@end defvar
+
+
+@deftp {Data Type} corectrl-configuration
+This is the data type representing the configuration of corectrl.
+
+@table @asis
+@item @code{package} (default: @code{corectrl}) (type: file-like)
+
+The @command{corectrl} executable to use.
+@end table
+@end deftp
+
 @c %end of fragment
 
 @node Privileged Programs
diff --git a/gnu/local.mk b/gnu/local.mk
index e0faa1f9fc2..9c41d90ec0e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -726,6 +726,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/services/backup.scm			\
   %D%/services/certbot.scm			\
   %D%/services/cgit.scm			\
+  %D%/services/corectrl.scm			\
   %D%/services/ci.scm				\
   %D%/services/configuration.scm		\
   %D%/services/containers.scm   		\
diff --git a/gnu/services/corectrl.scm b/gnu/services/corectrl.scm
new file mode 100644
index 00000000000..14d42cd7206
--- /dev/null
+++ b/gnu/services/corectrl.scm
@@ -0,0 +1,51 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Ashvith Shetty <ashvithshetty10@gmail.com>
+;;;
+;;; 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 services corectrl)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu services)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services dbus)
+  #:use-module (guix gexp)
+  #:export (corectrl-service-type
+            corectrl-configuration
+            corectrl-configuration?
+            corectrl-configuration-package))
+
+;;;
+;;; CoreCtrl service.
+;;;
+
+(define-configuration/no-serialization corectrl-configuration
+  (package (file-like corectrl) "The corectrl package"))
+
+(define corectrl-service-type
+  (service-type
+   (name 'corectrl)
+   (extensions
+    (list (service-extension profile-service-type
+                             (compose list corectrl-configuration-package))
+          (service-extension dbus-root-service-type
+                             (compose list corectrl-configuration-package))
+          (service-extension polkit-service-type
+                             (compose list corectrl-configuration-package))))
+   (default-value (corectrl-configuration))
+   (description "Run corectrl-helper, an essential service for the corectrl
+application.")))
+
+;;; corectrl.scm ends here

base-commit: b696658ee8e0655b17f5d26e024956b5148e36d6
prerequisite-patch-id: 09f39e5f8e208bc1f1f09dfb62f0bdf99415e0da
prerequisite-patch-id: 6ca76593d42480b0b7166923064adc0dd15ba822
-- 
2.47.1