summaryrefslogtreecommitdiff
path: root/nongnu/services/kernel-modules.scm
blob: 92e646e2e7a4997a899d1e7960c229b962624f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; Copyright © 2019, 2020 Alex Griffin <a@ajgrf.com>
;;;
;;; 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 kernel-modules)
  #:use-module (gnu packages linux)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services shepherd)
  #:use-module (guix gexp)
  #:use-module (guix records)
  #:use-module (ice-9 match)
  #:use-module (nongnu packages linux)
  #:export (load-broadcom-sta-service))

;;;
;;; broadcom-sta
;;;

(define-record-type* <load-broadcom-sta-configuration>
  load-broadcom-sta-configuration make-load-broadcom-sta-configuration
  load-broadcom-sta-configuration?
  (package load-broadcom-sta-configuration-package
           (default broadcom-sta)))

(define load-broadcom-sta-shepherd-service
  (match-lambda
    (($ <load-broadcom-sta-configuration> package)
     (list
      (shepherd-service
       (documentation "Load nonfree Broadcom wireless driver.")
       (provision '(load-broadcom-sta))
       (respawn? #f)
       (start
        #~(lambda _
            (and
             (zero? (system* "modprobe" "cfg80211"))
             (zero? (system* "modprobe" "lib80211"))
             (zero? (system* "env" (string-append
                                    "LINUX_MODULE_DIRECTORY="
                                    #$(file-append package "/lib/modules"))
                                    "modprobe" "wl"))))))))))

(define load-broadcom-sta-service-type
  (service-type
   (name 'load-broadcom-sta)
   (extensions
    (list
     (service-extension profile-service-type
                        (compose list load-broadcom-sta-configuration-package))
     (service-extension shepherd-root-service-type
                        load-broadcom-sta-shepherd-service)))
   (description "Load the nonfree Broadcom wireless driver.")
   (default-value (load-broadcom-sta-configuration))))

(define* (load-broadcom-sta-service #:key (broadcom-sta broadcom-sta))
  "Return a service that loads the nonfree Broadcom wireless driver.
This function is here only for backwards compatibility.  You should prefer
the `kernel-loadable-modules' mechanism to this now.

Users should also blacklist conflicting modules by adding the following
to kernel-arguments:
modprobe.blacklist=b43,b43legacy,ssb,bcm43xx,brcm80211,brcmfmac,brcmsmac,bcma"
  (service load-broadcom-sta-service-type
           (load-broadcom-sta-configuration
            (package broadcom-sta))))