diff options
Diffstat (limited to 'nongnu/services')
-rw-r--r-- | nongnu/services/nvidia.scm | 64 | ||||
-rw-r--r-- | nongnu/services/vpn.scm | 17 |
2 files changed, 65 insertions, 16 deletions
diff --git a/nongnu/services/nvidia.scm b/nongnu/services/nvidia.scm new file mode 100644 index 0000000..81a5d5f --- /dev/null +++ b/nongnu/services/nvidia.scm @@ -0,0 +1,64 @@ +;;; SPDX-License-Identifier: GPL-3.0-or-later +;;; Copyright © 2022, 2024 Hilton Chain <hako@ultrarare.space> + +(define-module (nongnu services nvidia) + #:use-module (guix gexp) + #:use-module (guix records) + #: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 (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? + (driver nvidia-configuration-driver + (default nvda)) ; file-like + (firmware nvidia-configuration-firmware + (default nvidia-firmware)) ; file-like + (module nvidia-configuration-module + (default nvidia-module))) ; file-like + +(define (nvidia-shepherd-service config) + (let ((nvidia-driver (nvidia-configuration-driver config)) + (nvidia-smi (file-append nvidia-driver "/bin/nvidia-smi"))) + (list (shepherd-service + (documentation "Prepare system environment for NVIDIA driver.") + (provision '(nvidia)) + (requirement '(udev)) + (one-shot? #t) + (modules '(((guix build utils) #:select (invoke/quiet)) + ((rnrs io ports) #:select (get-line)))) + (start + #~(lambda _ + (when (file-exists? "/proc/driver/nvidia") + (let ((modprobe (call-with-input-file + "/proc/sys/kernel/modprobe" get-line))) + (false-if-exception + (begin + (invoke/quiet modprobe "--" "nvidia_uvm") + (invoke/quiet #$nvidia-smi))))))))))) + +(define nvidia-service-type + (service-type + (name 'nvidia) + (extensions + (list (service-extension shepherd-root-service-type + nvidia-shepherd-service) + (service-extension profile-service-type + (compose list nvidia-configuration-driver)) + (service-extension udev-service-type + (compose list nvidia-configuration-driver)) + (service-extension firmware-service-type + (compose list nvidia-configuration-firmware)) + (service-extension linux-loadable-module-service-type + (compose list nvidia-configuration-module)))) + (default-value (nvidia-configuration)) + (description "Prepare system environment for NVIDIA driver."))) diff --git a/nongnu/services/vpn.scm b/nongnu/services/vpn.scm index d9f0bcc..71a15dc 100644 --- a/nongnu/services/vpn.scm +++ b/nongnu/services/vpn.scm @@ -1,20 +1,5 @@ -;;; GNU Guix --- Functional package management for GNU +;;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Copyright © 2020 Alexey Abramov <levenson@mmer.org> -;;; -;;; This file is not 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 (nongnu services vpn) #:use-module (guix gexp) |