nongnu: Add nvidia-service-type.

* nongnu/services/nvidia.scm: New file.
(<nvidia-configuration>): New data type.
(nvidia-shepherd-service,nvidia-service-type): New variables.
* nongnu/packages/nvidia.scm (nvidia-driver)[description]: Adjust accordingly.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Hilton Chain 2022-10-01 15:08:38 +08:00 committed by Jonathan Brielmaier
parent cbb9b59c11
commit 6874c66ddc
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F
2 changed files with 77 additions and 6 deletions

View file

@ -256,12 +256,12 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
wayland)) wayland))
(home-page "https://www.nvidia.com") (home-page "https://www.nvidia.com")
(synopsis "Proprietary NVIDIA driver") (synopsis "Proprietary NVIDIA driver")
(description "This is the evil NVIDIA driver. Don't forget to add (description
@code{nvidia-driver} to the @code{udev-rules} in your @file{config.scm}: "This is the evil NVIDIA driver. Don't forget to add @code{service
@code{(simple-service 'custom-udev-rules udev-service-type (list nvidia-service-type} to your @file{config.scm}. Further xorg should be
nvidia-driver))}. Further xorg should be configured by adding: @code{(modules configured by adding: @code{(modules (cons* nvidia-driver
(cons* nvidia-driver %default-xorg-modules)) (drivers '(\"nvidia\"))} to %default-xorg-modules)) (drivers '(\"nvidia\"))} to @code{xorg-configuration}.
@code{xorg-configuration}.") ")
(license (license
(license:nonfree (license:nonfree
(format #f "file:///share/doc/nvidia-driver-~a/LICENSE" version))))) (format #f "file:///share/doc/nvidia-driver-~a/LICENSE" version)))))

View file

@ -0,0 +1,71 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Hilton Chain <hako@ultrarare.space>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; This program 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.
;;;
;;; This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
(define-module (nongnu services nvidia)
#:use-module (gnu packages)
#:use-module (gnu packages linux)
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services linux)
#:use-module (gnu services shepherd)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (nongnu packages nvidia)
#:export (nvidia-configuration
nvidia-configuration?
nvidia-configuration-record?
nvidia-service-type))
(define-record-type* <nvidia-configuration>
nvidia-configuration make-nvidia-configuration
nvidia-configuration?
(nvidia-driver nvidia-configuration-nvidia-driver
(default (list nvidia-driver))) ; list of file-like
(nvidia-firmware nvidia-configuration-nvidia-firmware
(default (list nvidia-firmware))) ; list of file-like
(nvidia-module nvidia-configuration-nvidia-module
(default (list nvidia-module))) ; list of file-like
(modules nvidia-configuration-modules
(default (list "nvidia-uvm")))) ; list of string
(define (nvidia-shepherd-service config)
(list (shepherd-service
(documentation "Unload nvidia-uvm module on powering off.")
(provision '(nvidia))
(requirement '(user-processes))
(start #~(const #t))
(stop #~(lambda _
(let ((rmmod #$(file-append kmod "/bin/rmmod")))
(zero? (system* rmmod "nvidia-uvm"))))))))
(define nvidia-service-type
(service-type
(name 'nvidia)
(extensions
(list (service-extension shepherd-root-service-type
nvidia-shepherd-service)
(service-extension udev-service-type
nvidia-configuration-nvidia-driver)
(service-extension firmware-service-type
nvidia-configuration-nvidia-firmware)
(service-extension linux-loadable-module-service-type
nvidia-configuration-nvidia-module)
(service-extension kernel-module-loader-service-type
nvidia-configuration-modules)))
(default-value (nvidia-configuration))
(description "Load NVIDIA modules.")))