Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
GuixSD with custom kernel
(define-module (my packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages linux)
#:use-module (guix build-system trivial)
#:use-module (gnu)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages))
(define (linux-nonfree-urls version)
"Return a list of URLs for Linux-Nonfree VERSION."
(list (string-append
"linux-" version ".tar.xz")))
;; Remove this and native-inputs below to use the default config from Guix.
;; Make sure the kernel minor version matches, though.
(define kernel-config
(string-append (dirname (current-filename)) "/kernel.config"))
(define-public linux-nonfree
(inherit linux-libre)
(name "linux-nonfree")
(version "4.13.11")
(source (origin
(method url-fetch)
(uri (linux-nonfree-urls version))
`(("kconfig" ,kernel-config)
,@(alist-delete "kconfig"
(package-native-inputs linux-libre))))
(synopsis "Mainline Linux kernel, nonfree binary blobs included")
(description "Linux is a kernel.")
(license license:gpl2) ;XXX with proprietary firmware
(home-page "")))
(define (linux-firmware-version) "9d40a17beaf271e6ad47a5e714a296100eef4692")
(define (linux-firmware-source version)
(method git-fetch)
(uri (git-reference
(url (string-append ""
(commit version)))
(file-name (string-append "linux-firmware-" version "-checkout"))
(define-public iwlwifi-firmware-nonfree
(name "iwlwifi-firmware-nonfree")
(version (linux-firmware-version))
(source (linux-firmware-source version))
(build-system trivial-build-system)
`(#:modules ((guix build utils))
#:builder (begin
(use-modules (guix build utils))
(let ((source (assoc-ref %build-inputs "source"))
(fw-dir (string-append %output "/lib/firmware/")))
(mkdir-p fw-dir)
(for-each (lambda (file)
(copy-file file
(string-append fw-dir (basename file))))
(find-files source
(home-page "")
(synopsis "Non-free firmware for Intel wifi chips")
(description "Non-free iwlwifi firmware")
(license (license:non-copyleft
(define %sysctl-activation-service
(simple-service 'sysctl activation-service-type
#~(let ((sysctl
(lambda (str)
(zero? (apply system*
#$(file-append procps
"-w" (string-tokenize str))))))
;; Enable IPv6 privacy extensions.
(sysctl "net.ipv6.conf.eth0.use_tempaddr=2")
;; Enable SYN cookie protection.
(sysctl "net.ipv4.tcp_syncookies=1")
;; Log Martian packets.
(sysctl "net.ipv4.conf.default.log_martians=1")))))
(define %powertop-service
(simple-service 'powertop activation-service-type
#~(zero? (system* #$(file-append powertop "/sbin/powertop")
(use-modules (gnu)
(guix store) ;for %default-substitute-urls
(gnu system nss)
(my packages)
(srfi srfi-1))
(use-service-modules admin base dbus desktop mcron networking ssh xorg sddm)
(use-package-modules admin bootloaders certs disk fonts file emacs
libusb linux version-control
ssh tls tmux wm xdisorg xorg)
(host-name "kirby")
(timezone "Europe/Oslo")
(kernel linux-nonfree)
(kernel-arguments '("modprobe.blacklist=pcspkr,snd_pcsp"))
;; (locale "en_GB.utf8")
;; (locale-libcs (list glibc-2.24 (canonical-package glibc)))
(firmware (append (list
(mapped-devices (list (mapped-device
(source "/dev/sda4")
(type luks-device-mapping)
(target "guixhome"))))
(bootloader (bootloader-configuration
(bootloader grub-efi-bootloader)
(target "/boot/efi")))
(file-systems (cons* (file-system
(device "guixroot")
(title 'label)
(mount-point "/")
(needed-for-boot? #t)
(type "ext4"))
(device "/dev/mapper/guixhome")
(mount-point "/home")
(type "ext4"))
(device "/dev/sda2")
(mount-point "/boot")
(type "vfat"))
(groups (cons (user-group
(name "marius"))
(users (cons (user-account
(name "marius")
(comment "Meh")
(group "marius")
(supplementary-groups '("wheel" "netdev" "audio" "video" "kvm" "disk"))
(home-directory "/home/marius"))
(packages (cons*
(services (cons*
(screen-locker-service xscreensaver)
(service wpa-supplicant-service-type)
(service network-manager-service-type)
(service rottlog-service-type (rottlog-configuration))
(service mcron-service-type)
;; Add udev rules for MTP devices so that non-root users can access
;; them.
(simple-service 'mtp udev-service-type (list libmtp))
;; Store the current configuration with the generation.
(simple-service 'store-my-config
,(local-file (assoc-ref
(ntp-service #:servers '(""
(modify-services %base-services
config =>
(inherit config)
(cons* ""
Copy link

ison5002 commented Feb 3, 2018

I am very interested in giving this a try.
Is it actually in a working state currently? Also do you know anything about the current working status of the original from mbakke?

Copy link

I used this as a template for setting up a custom kernel 4.15.6 as of today. Took some finessing to figure out how to get and assign version and sha256 hashes, but everything works smoothly here, and I can have some wifi at last on my mostly libre machine. Ask me if you have a question with getting a custom kernel to boot your guixSD

Copy link

Do you a recipe of the steps you followed to set up the custom kernel??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment