aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/linux.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2020-04-08 13:00:50 +0200
committerMarius Bakke <mbakke@fastmail.com>2020-04-08 13:00:50 +0200
commit27783023993f9272ce422868d14529159c4a5218 (patch)
tree9013b08aa39e497b1fd8e01a05254278d83f0ff7 /gnu/services/linux.scm
parentbe1e842ad78ac6c52fc7790f4a3ffd716673c111 (diff)
parentba6f2bda18ed19fa486a9c3e2c3baea6c66c6867 (diff)
downloadpatches-27783023993f9272ce422868d14529159c4a5218.tar
patches-27783023993f9272ce422868d14529159c4a5218.tar.gz
Merge branch 'master' into core-updates
Conflicts: etc/news.scm gnu/local.mk gnu/packages/check.scm gnu/packages/cross-base.scm gnu/packages/gimp.scm gnu/packages/java.scm gnu/packages/mail.scm gnu/packages/sdl.scm gnu/packages/texinfo.scm gnu/packages/tls.scm gnu/packages/version-control.scm
Diffstat (limited to 'gnu/services/linux.scm')
-rw-r--r--gnu/services/linux.scm57
1 files changed, 56 insertions, 1 deletions
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index caa0326c31..781a61973c 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +26,8 @@
#: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
earlyoom-configuration?
@@ -37,7 +40,9 @@
earlyoom-configuration-ignore-positive-oom-score-adj?
earlyoom-configuration-show-debug-messages?
earlyoom-configuration-send-notification-command
- earlyoom-service-type))
+ earlyoom-service-type
+
+ kernel-module-loader-service-type))
;;;
@@ -123,3 +128,53 @@ representation."
(list (service-extension shepherd-root-service-type
(compose list earlyoom-shepherd-service))))
(description "Run @command{earlyoom}, the Early OOM daemon.")))
+
+
+;;;
+;;; Kernel module loader.
+;;;
+
+(define kernel-module-loader-shepherd-service
+ (match-lambda
+ ((and (? list? kernel-modules) ((? string?) ...))
+ (list
+ (shepherd-service
+ (documentation "Load kernel modules.")
+ (provision '(kernel-module-loader))
+ (requirement '(file-systems))
+ (respawn? #f)
+ (one-shot? #t)
+ (modules `((srfi srfi-1)
+ (srfi srfi-34)
+ (srfi srfi-35)
+ (rnrs io ports)
+ ,@%default-modules))
+ (start
+ #~(lambda _
+ (cond
+ ((null? '#$kernel-modules) #t)
+ ((file-exists? "/proc/sys/kernel/modprobe")
+ (let ((modprobe (call-with-input-file
+ "/proc/sys/kernel/modprobe" get-line)))
+ (guard (c ((message-condition? c)
+ (format (current-error-port) "~a~%"
+ (condition-message c))
+ #f))
+ (every (lambda (module)
+ (invoke/quiet modprobe "--" module))
+ '#$kernel-modules))))
+ (else
+ (format (current-error-port) "error: ~a~%"
+ "Kernel is missing loadable module support.")
+ #f)))))))))
+
+(define kernel-module-loader-service-type
+ (service-type
+ (name 'kernel-module-loader)
+ (description "Load kernel modules.")
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ kernel-module-loader-shepherd-service)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())))