kernel-modules.scm 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
  2. ;;;
  3. ;;; This program is free software: you can redistribute it and/or modify
  4. ;;; it under the terms of the GNU General Public License as published by
  5. ;;; the Free Software Foundation, either version 3 of the License, or
  6. ;;; (at your option) any later version.
  7. ;;;
  8. ;;; This program is distributed in the hope that it will be useful,
  9. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;;; GNU General Public License for more details.
  12. ;;;
  13. ;;; You should have received a copy of the GNU General Public License
  14. ;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. (define-module (nongnu services kernel-modules)
  16. #:use-module (gnu packages linux)
  17. #:use-module (gnu services)
  18. #:use-module (gnu services base)
  19. #:use-module (gnu services shepherd)
  20. #:use-module (guix gexp)
  21. #:use-module (guix records)
  22. #:use-module (ice-9 match)
  23. #:use-module (nongnu packages linux)
  24. #:export (load-broadcom-sta-service))
  25. ;;;
  26. ;;; broadcom-sta
  27. ;;;
  28. (define-record-type* <load-broadcom-sta-configuration>
  29. load-broadcom-sta-configuration make-load-broadcom-sta-configuration
  30. load-broadcom-sta-configuration?
  31. (package load-broadcom-sta-configuration-package
  32. (default broadcom-sta)))
  33. (define load-broadcom-sta-shepherd-service
  34. (match-lambda
  35. (($ <load-broadcom-sta-configuration> package)
  36. (list
  37. (shepherd-service
  38. (documentation "Load nonfree Broadcom wireless driver.")
  39. (provision '(load-broadcom-sta))
  40. (respawn? #f)
  41. (start
  42. #~(lambda _
  43. (and
  44. (zero? (system* "modprobe" "cfg80211"))
  45. (zero? (system* "modprobe" "lib80211"))
  46. (zero? (system* "env" (string-append
  47. "LINUX_MODULE_DIRECTORY="
  48. #$(file-append package "/lib/modules"))
  49. "modprobe" "wl"))))))))))
  50. (define load-broadcom-sta-service-type
  51. (service-type
  52. (name 'load-broadcom-sta)
  53. (extensions
  54. (list
  55. (service-extension profile-service-type
  56. (compose list load-broadcom-sta-configuration-package))
  57. (service-extension shepherd-root-service-type
  58. load-broadcom-sta-shepherd-service)))
  59. (description "Load the nonfree Broadcom wireless driver.")
  60. (default-value (load-broadcom-sta-configuration))))
  61. (define* (load-broadcom-sta-service #:key (broadcom-sta broadcom-sta))
  62. "Return a service that loads the nonfree Broadcom wireless driver.
  63. Users should also blacklist conflicting modules by adding the following
  64. to kernel-arguments:
  65. modprobe.blacklist=b43,b43legacy,ssb,bcm43xx,brcm80211,brcmfmac,brcmsmac,bcma"
  66. (service load-broadcom-sta-service-type
  67. (load-broadcom-sta-configuration
  68. (package broadcom-sta))))