linux.scm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. ;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
  2. ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
  3. ;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
  4. ;;;
  5. ;;; This program is free software: you can redistribute it and/or modify
  6. ;;; it under the terms of the GNU General Public License as published by
  7. ;;; the Free Software Foundation, either version 3 of the License, or
  8. ;;; (at your option) any later version.
  9. ;;;
  10. ;;; This program is distributed in the hope that it will be useful,
  11. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;;; GNU General Public License for more details.
  14. ;;;
  15. ;;; You should have received a copy of the GNU General Public License
  16. ;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. (define-module (nongnu packages linux)
  18. #:use-module (gnu packages)
  19. #:use-module (gnu packages compression)
  20. #:use-module (gnu packages linux)
  21. #:use-module (guix packages)
  22. #:use-module (guix utils)
  23. #:use-module (guix download)
  24. #:use-module (guix git-download)
  25. #:use-module (guix build-system linux-module)
  26. #:use-module (guix build-system trivial)
  27. #:use-module (nonguix licenses))
  28. (define (linux-urls version)
  29. "Return a list of URLS for Linux VERSION."
  30. (list (string-append "https://www.kernel.org/pub/linux/kernel/v"
  31. (version-major version) ".x/linux-" version ".tar.xz")))
  32. (define (corrupt-linux freedo version hash)
  33. (package
  34. (inherit freedo)
  35. (name "linux")
  36. (version version)
  37. (source (origin
  38. (method url-fetch)
  39. (uri (linux-urls version))
  40. (sha256 (base32 hash))))
  41. (home-page "https://www.kernel.org/")
  42. (synopsis "Linux kernel with nonfree binary blobs included")
  43. (description
  44. "The unmodified Linux kernel, including nonfree blobs, for running GuixSD
  45. on hardware which requires nonfree software to function.")))
  46. (define-public linux
  47. (corrupt-linux linux-libre "5.2.8"
  48. "0dv91zfjkil29lp2l35lswkrhrqbc4kjh965ciaqwih1rh3cs9x1
  49. "))
  50. (define-public linux-4.19
  51. (corrupt-linux linux-libre-4.19 "4.19.67"
  52. "00m5k0nfcvgff70686rbhn3w8c9wc3jxqvyddw40lylaqdh3s72s"))
  53. (define-public linux-4.14
  54. (corrupt-linux linux-libre-4.14 "4.14.139"
  55. "0hkhwcbxg6bry13w9kspx48b10274w6pgv200wh91fjd8jax8qlc"))
  56. (define-public linux-4.9
  57. (corrupt-linux linux-libre-4.9 "4.9.189"
  58. "1cyhwnxkjd0qa5d48657yppjnzbi830q0p25jjv2dxs629k4bnck"))
  59. (define-public linux-4.4
  60. (corrupt-linux linux-libre-4.4 "4.4.189"
  61. "0nc8v62gw89m3ykqg6nqf749fzm8y1n481ns8vny4gbinyikjhlp"))
  62. (define-public linux-firmware
  63. (let ((commit "92e17d0dd2437140fab044ae62baf69b35d7d1fa")
  64. (revision "1"))
  65. (package
  66. (name "linux-firmware")
  67. (version (git-version "20190502" revision commit))
  68. (source (origin
  69. (method git-fetch)
  70. (uri (git-reference
  71. (url (string-append
  72. "https://git.kernel.org/pub/scm/"
  73. "linux/kernel/git/firmware/linux-firmware.git"))
  74. (commit commit)))
  75. (file-name (git-file-name name version))
  76. (sha256
  77. (base32
  78. "1bsgp124jhs9bbjjq0fzmdsziwx1y5aivkgpj8v56ar0y2zmrw2d"))))
  79. (build-system trivial-build-system)
  80. (arguments
  81. `(#:modules ((guix build utils))
  82. #:builder (begin
  83. (use-modules (guix build utils))
  84. (let ((source (assoc-ref %build-inputs "source"))
  85. (destination (string-append %output "/lib/firmware")))
  86. (mkdir-p destination)
  87. (copy-recursively source destination #:follow-symlinks? #t)
  88. #t))))
  89. (home-page
  90. "http://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git")
  91. (synopsis "Nonfree firmware blobs for Linux")
  92. (description "Nonfree firmware blobs for enabling support for various
  93. hardware in the Linux kernel. This is a large package which may be overkill
  94. if your hardware is supported by one of the smaller firmware packages.")
  95. (license
  96. (nonfree
  97. (string-append "https://git.kernel.org/pub/scm/linux/kernel/git/"
  98. "firmware/linux-firmware.git/plain/WHENCE"))))))
  99. (define-public amdgpu-firmware
  100. (package
  101. (inherit linux-firmware)
  102. (name "amdgpu-firmware")
  103. (build-system trivial-build-system)
  104. (arguments
  105. `(#:modules ((guix build utils))
  106. #:builder
  107. (begin
  108. (use-modules (guix build utils))
  109. (let* ((source (assoc-ref %build-inputs "source"))
  110. (fw-dir (string-append %output "/lib/firmware/"))
  111. (bin-dir (string-append fw-dir "/amdgpu")))
  112. (mkdir-p bin-dir)
  113. (copy-recursively (string-append source "/amdgpu") bin-dir)
  114. (install-file (string-append source "/LICENSE.amdgpu") fw-dir)
  115. #t))))
  116. (home-page "http://support.amd.com/en-us/download/linux")
  117. (synopsis "Nonfree firmware for AMD graphics chips")
  118. (description "Nonfree firmware for AMD graphics chips. While most AMD
  119. graphics cards can be run with the free Mesa, many modern cards require a
  120. nonfree kernel module to run properly and support features like hibernation and
  121. advanced 3D.")
  122. (license
  123. (nonfree
  124. (string-append
  125. "https://git.kernel.org/pub/scm/linux/kernel/git/firmware"
  126. "/linux-firmware.git/plain/LICENSE.amdgpu")))))
  127. (define-public ath3k-firmware
  128. (package
  129. (inherit linux-firmware)
  130. (name "ath3k-firmware")
  131. (build-system trivial-build-system)
  132. (arguments
  133. `(#:modules ((guix build utils))
  134. #:builder
  135. (begin
  136. (use-modules (guix build utils))
  137. (let ((source (assoc-ref %build-inputs "source"))
  138. (fw-dir (string-append %output "/lib/firmware")))
  139. (mkdir-p fw-dir)
  140. (for-each (lambda (file)
  141. (copy-file (string-append source "/" file)
  142. (string-append fw-dir "/" file)))
  143. (list "ath3k-1.fw"
  144. "LICENCE.atheros_firmware"
  145. "LICENSE.QualcommAtheros_ar3k"
  146. "WHENCE"))
  147. (copy-recursively (string-append source "/ar3k")
  148. (string-append fw-dir "/ar3k"))
  149. #t))))
  150. (synopsis "Nonfree firmware blobs for the ath3k Bluetooth driver")
  151. (description "Nonfree firmware blobs for the ath3k Bluetooth driver. ath3k
  152. is the Linux Bluetooth driver for Atheros AR3011/AR3012 Bluetooth chipsets.")
  153. (license
  154. (list
  155. (nonfree
  156. (string-append
  157. "https://git.kernel.org/pub/scm/linux/kernel/git/firmware"
  158. "/linux-firmware.git/plain/LICENCE.atheros_firmware"))
  159. (nonfree
  160. (string-append
  161. "https://git.kernel.org/pub/scm/linux/kernel/git/firmware"
  162. "/linux-firmware.git/plain/LICENSE.QualcommAtheros_ar3k"))))))
  163. (define-public iwlwifi-firmware
  164. (package
  165. (inherit linux-firmware)
  166. (name "iwlwifi-firmware")
  167. (build-system trivial-build-system)
  168. (arguments
  169. `(#:modules ((guix build utils))
  170. #:builder
  171. (begin
  172. (use-modules (guix build utils))
  173. (let ((source (assoc-ref %build-inputs "source"))
  174. (fw-dir (string-append %output "/lib/firmware/")))
  175. (mkdir-p fw-dir)
  176. (for-each (lambda (file)
  177. (copy-file file
  178. (string-append fw-dir (basename file))))
  179. (cons*
  180. (string-append source "/LICENCE.iwlwifi_firmware")
  181. (find-files source
  182. "iwlwifi-.*\\.ucode$")))
  183. #t))))
  184. (home-page "https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi")
  185. (synopsis "Nonfree firmware for Intel wifi chips")
  186. (description "The proprietary iwlwifi kernel module is required by many
  187. modern Intel wifi cards (commonly found in laptops). This blob enables
  188. support for 5GHz and 802.11ac, among others.")
  189. (license
  190. (nonfree (string-append
  191. "https://git.kernel.org/pub/scm/linux/kernel/git/firmware"
  192. "/linux-firmware.git/plain/LICENCE.iwlwifi_firmware")))))
  193. (define-public broadcom-sta
  194. (package
  195. (name "broadcom-sta")
  196. (version "6.30.223.271")
  197. (source
  198. (origin
  199. (method url-fetch/tarbomb)
  200. (uri (string-append "https://docs.broadcom.com/docs-and-downloads/"
  201. "docs/linux_sta/hybrid-v35_64-nodebug-pcoem-"
  202. (string-replace-substring version "." "_")
  203. ".tar.gz"))
  204. (patches
  205. (parameterize
  206. ((%patch-path
  207. (map (lambda (directory)
  208. (string-append directory "/nongnu/packages/patches"))
  209. %load-path)))
  210. ;; https://github.com/NixOS/nixpkgs/tree/master/pkgs/os-specific/linux/broadcom-sta
  211. ;; https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/broadcom-wl-dkms
  212. (search-patches "broadcom-sta-gcc.patch"
  213. "broadcom-sta-license.patch"
  214. "broadcom-sta-null-pointer-fix.patch"
  215. "broadcom-sta-rdtscl.patch"
  216. "broadcom-sta-linux-4.7.patch"
  217. "broadcom-sta-linux-4.8.patch"
  218. "broadcom-sta-debian-fix-kernel-warnings.patch"
  219. "broadcom-sta-linux-4.11.patch"
  220. "broadcom-sta-linux-4.12.patch"
  221. "broadcom-sta-linux-4.15.patch"
  222. "broadcom-sta-fix_mac_profile_discrepancy.patch"
  223. "broadcom-sta-linux-5.1.patch")))
  224. (sha256
  225. (base32
  226. "1gj485qqr190idilacpxwgqyw21il03zph2rddizgj7fbd6pfyaz"))))
  227. (build-system linux-module-build-system)
  228. (arguments
  229. `(#:linux ,linux
  230. #:tests? #f))
  231. (supported-systems '("x86_64-linux"))
  232. (home-page "https://www.broadcom.com/support/802.11")
  233. (synopsis "Broadcom 802.11 Linux STA wireless driver")
  234. (description "This package contains Broadcom's IEEE 802.11a/b/g/n/ac hybrid
  235. Linux device driver for the following chipsets:
  236. @itemize
  237. @item BCM4311
  238. @item BCM4312
  239. @item BCM4313
  240. @item BCM4321
  241. @item BCM4322
  242. @item BCM43224
  243. @item BCM43225
  244. @item BCM43227
  245. @item BCM43228
  246. @item BCM43142
  247. @item BCM4331
  248. @item BCM4352
  249. @item BCM4360
  250. @end itemize")
  251. (license (nonfree "https://www.broadcom.com/support/802.11"))))
  252. (define-public broadcom-bt-firmware
  253. (package
  254. (name "broadcom-bt-firmware")
  255. (version "12.0.1.1012")
  256. (source
  257. (origin
  258. (method url-fetch)
  259. (uri
  260. (string-append
  261. "http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/04/"
  262. "852bb503-de7b-4810-a7dd-cbab62742f09_7cf83a4c194116648d17707ae37d564f9c70bec2"
  263. ".cab"))
  264. (file-name (string-append name "-" version ".cab"))
  265. (sha256
  266. (base32
  267. "1b1qjwxjk4y91l3iz157kms8601n0mmiik32cs6w9b1q4sl4pxx9"))))
  268. (build-system trivial-build-system)
  269. (arguments
  270. `(#:modules ((guix build utils)
  271. (ice-9 rdelim)
  272. (ice-9 regex))
  273. #:builder
  274. (begin
  275. (use-modules (guix build utils)
  276. (ice-9 rdelim)
  277. (ice-9 regex))
  278. (let ((PATH (string-append (assoc-ref %build-inputs "cabextract") "/bin:"
  279. (assoc-ref %build-inputs "bluez") "/bin"))
  280. (source (assoc-ref %build-inputs "source"))
  281. (firmware-dir (string-append %output "/lib/firmware/brcm/")))
  282. (setenv "PATH" PATH)
  283. (system* "cabextract" source)
  284. (mkdir-p firmware-dir)
  285. ;; process the inf file to get the correct filenames
  286. (with-input-from-file "bcbtums.inf"
  287. (lambda ()
  288. (do ((line (read-line) (read-line))
  289. (devices '()))
  290. ((eof-object? line) #t)
  291. ;; these two `lets' are like awk patterns matching against
  292. ;; records. link devices in this file with its vids and pids
  293. (let ((rcrd (string-match "%.*%=(.*),.*VID_(....).*PID_(....)"
  294. line)))
  295. (when rcrd
  296. (set! devices
  297. (assoc-set! devices (match:substring rcrd 1)
  298. `((vid . ,(match:substring rcrd 2))
  299. (pid . ,(match:substring rcrd 3)))))))
  300. ;; find the hex file associated with each device, build the
  301. ;; output file name
  302. (let ((rcrd (string-match "\\[(RAMUSB.*)\\.CopyList\\]" line)))
  303. (when rcrd
  304. (let* ((key (match:substring rcrd 1))
  305. (hex-file (begin (do ((line (read-line) (read-line)))
  306. ((string-match "^([0-9A-Z_.]+\\.hex)" line)
  307. (string-drop-right line 1)))))
  308. (chipset (car (string-tokenize
  309. hex-file
  310. char-set:letter+digit)))
  311. (vid (assoc-ref (assoc-ref devices key) 'vid))
  312. (pid (assoc-ref (assoc-ref devices key) 'pid))
  313. (hcd-file (string-append chipset "-"
  314. (string-downcase vid) "-"
  315. (string-downcase pid)
  316. ".hcd")))
  317. ;; finally convert the file, phew!
  318. (system* "hex2hcd"
  319. "-o" (string-append firmware-dir hcd-file)
  320. hex-file)))))))))))
  321. (native-inputs
  322. `(("bluez" ,bluez)
  323. ("cabextract" ,cabextract)))
  324. (home-page "http://www.broadcom.com/support/bluetooth")
  325. (synopsis "Broadcom bluetooth firmware")
  326. (description
  327. "This package contains nonfree firmware for the following bluetooth
  328. chipsets from Broadcom:
  329. @itemize
  330. @item BCM4335C0
  331. @item BCM4350C5
  332. @item BCM4356A2
  333. @item BCM4371C2
  334. @item BCM20702A1
  335. @item BCM20702B0
  336. @item BCM20703A1
  337. @item BCM43142A0
  338. @end itemize")
  339. (license
  340. (undistributable
  341. (string-append
  342. "https://raw.githubusercontent.com/winterheart/broadcom-bt-firmware"
  343. "/b60fa04881bf8f9b9d578f57d1dfa596cae2a82e"
  344. "/LICENSE.broadcom_bcm20702")))))
  345. (define-public rtlwifi-firmware
  346. (package
  347. (inherit linux-firmware)
  348. (name "rtlwifi-firmware")
  349. (build-system trivial-build-system)
  350. (arguments
  351. `(#:modules ((guix build utils))
  352. #:builder
  353. (begin
  354. (use-modules (guix build utils))
  355. (let* ((source (assoc-ref %build-inputs "source"))
  356. (fw-dir (string-append %output "/lib/firmware/"))
  357. (bin-dir (string-append fw-dir "/rtlwifi")))
  358. (mkdir-p bin-dir)
  359. (copy-recursively (string-append source "/rtlwifi") bin-dir)
  360. (install-file (string-append source "/LICENCE.rtlwifi_firmware.txt") fw-dir)
  361. #t))))
  362. (home-page "https://wireless.wiki.kernel.org/en/users/drivers/rtl819x")
  363. (synopsis "Nonfree firmware for Realtek wifi chips")
  364. (description
  365. "Nonfree firmware for Realtek wifi chips. This package contains nonfree
  366. firmware for the following chips:
  367. @itemize
  368. @item Realtek RTL8188EE firmware (rtlwifi/rtl8188efw.bin)
  369. @item Realtek RTL8188EU firmware (rtlwifi/rtl8188eufw.bin)
  370. @item Realtek RTL8192CE/RTL8188CE firmware (rtlwifi/rtl8192cfw.bin)
  371. @item Realtek RTL8192CE/RTL8188CE B-cut firmware (rtlwifi/rtl8192cfwU_B.bin)
  372. @item Realtek RTL8188CE A-cut firmware, version 4.816.2011 (rtlwifi/rtl8192cfwU.bin)
  373. @item Realtek RTL8192CU/RTL8188CU UMC A-cut firmware (rtlwifi/rtl8192cufw_A.bin)
  374. @item Realtek RTL8192CU/RTL8188CU UMC B-cut firmware (rtlwifi/rtl8192cufw_B.bin)
  375. @item Realtek RTL8192CU/RTL8188CU TMSC firmware (rtlwifi/rtl8192cufw_TMSC.bin)
  376. @item Realtek RTL8192CU/RTL8188CU fallback firmware (rtlwifi/rtl8192cufw.bin)
  377. @item Realtek RTL8192DE firmware (rtlwifi/rtl8192defw.bin)
  378. @item Realtek RTL8192EE wifi firmware (rtlwifi/rtl8192eefw.bin)
  379. @item Realtek RTL8192EU non-WoWLAN firmware (rtlwifi/rtl8192eu_nic.bin)
  380. @item Realtek RTL8192EU WoWLAN firmware (rtlwifi/rtl8192eu_wowlan.bin)
  381. @item Realtek RTL8192SE/RTL8191SE firmware, version 4.816.2011 (rtlwifi/rtl8192sefw.bin)
  382. @item Realtek RTL8192SU/RTL8712U firmware (rtlwifi/rtl8712u.bin)
  383. @item Realtek RTL8723AU rev A wifi-with-BT firmware (rtlwifi/rtl8723aufw_A.bin)
  384. @item Realtek RTL8723AU rev B wifi-with-BT firmware (rtlwifi/rtl8723aufw_B.bin)
  385. @item Realtek RTL8723AU rev B wifi-only firmware (rtlwifi/rtl8723aufw_B_NoBT.bin)
  386. @item Realtek RTL8723BE firmware, version 36 (rtlwifi/rtl8723befw_36.bin)
  387. @item Realtek RTL8723BE firmware (rtlwifi/rtl8723befw.bin)
  388. @item Realtek RTL8723BS BT firmware (rtlwifi/rtl8723bs_bt.bin)
  389. @item Realtek RTL8723BS wifi non-WoWLAN firmware (rtlwifi/rtl8723bs_nic.bin)
  390. @item Realtek RTL8723BS wifi WoWLAN firmware (rtlwifi/rtl8723bs_wowlan.bin)
  391. @item Realtek RTL8723BU non-WoWLAN firmware (rtlwifi/rtl8723bu_nic.bin)
  392. @item Realtek RTL8723BU WoWLAN firmware (rtlwifi/rtl8723bu_wowlan.bin)
  393. @item Realtek RTL8723DE firmware (rtlwifi/rtl8723defw.bin)
  394. @item Realtek RTL8723AE rev B firmware (rtlwifi/rtl8723fw_B.bin)
  395. @item Realtek RTL8723AE rev A firmware (rtlwifi/rtl8723fw.bin)
  396. @item Realtek RTL8821AE firmware, version 29 (rtlwifi/rtl8821aefw_29.bin)
  397. @item Realtek RTL8821AE firmware (rtlwifi/rtl8821aefw_wowlan.bin)
  398. @item Realtek RTL8821AE firmware (rtlwifi/rtl8821aefw.bin)
  399. @item Realtek RTL8822BE firmware (rtlwifi/rtl8822befw.bin)
  400. @end itemize")
  401. (license
  402. (nonfree
  403. (string-append
  404. "https://git.kernel.org/pub/scm/linux/kernel/git/firmware"
  405. "/linux-firmware.git/plain/LICENCE.rtlwifi_firmware.txt")))))