;;; SPDX-FileCopyrightText: 2024 Brian Kubisiak ;;; ;;; SPDX-License-Identifier: CC0-1.0 (use-modules (gnu bootloader) (gnu bootloader grub) (gnu packages base) (gnu packages busybox) (gnu packages linux) (gnu services) (gnu services base) (gnu services shepherd) (gnu services sysctl) (gnu system) (gnu system accounts) (gnu system file-systems) (gnu system locale) (guix gexp) (guix records) (ice-9 match) (srfi srfi-1)) (define tinylinux (customize-linux #:name "tinylinux" #:defconfig (local-file "tinylinux_defconfig"))) (define %default-busybox-syslog.conf (plain-file "syslog.conf" "\ # Log all error messages, authentication messages of # level notice or higher and anything of level err or # higher to the console. # Don't log private authentication messages! *.alert;auth.notice;authpriv.none /dev/console # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;authpriv.none /var/log/messages # The authpriv file has restricted access. # Also include unprivileged auth logs of info or higher level # to conveniently gather the authentication data at the same place. authpriv.*;auth.info /var/log/secure ")) (define-record-type* busybox-syslog-configuration make-busybox-syslog-configuration busybox-syslog-configuration? (syslogd busybox-syslog-configuration-syslogd (default (file-append busybox "/sbin/syslogd"))) (config-file busybox-syslog-configuration-config-file (default %default-busybox-syslog.conf))) (define (busybox-syslog-shepherd-service config) (define config-file (busybox-syslog-configuration-config-file config)) (shepherd-service (documentation "Run the busybox syslog daemon (syslogd).") (provision '(syslogd)) (requirement '(user-processes)) (actions (list (shepherd-configuration-action config-file))) (start #~(make-forkexec-constructor (list #$(busybox-syslog-configuration-syslogd config) "-n" "-f" #$config-file) #:file-creation-mask #o137)) (stop #~(make-kill-destructor)))) (define busybox-syslog-service-type (service-type (name 'syslog) (default-value (busybox-syslog-configuration)) (extensions (list (service-extension shepherd-root-service-type (compose list busybox-syslog-shepherd-service)))) (description "Run busybox's @command{syslogd} as the system logger."))) (define busybox-sysctl-shepherd-service (match-lambda (($ (@@ (gnu services sysctl) ) sysctl settings) (let ((sysctl.conf ((@@ (gnu services sysctl) sysctl-configuration-settings->sysctl.conf) settings))) (shepherd-service (documentation "Configure kernel parameters at boot.") (provision '(sysctl)) (start #~(lambda _ (zero? (system* #$sysctl "-p" #$sysctl.conf)))) (one-shot? #t)))))) (define busybox-sysctl-service-type (service-type (inherit sysctl-service-type) (extensions (list (service-extension shepherd-root-service-type (compose list busybox-sysctl-shepherd-service)))))) (operating-system (host-name "pico-guix") (bootloader (bootloader-configuration (bootloader grub-efi-bootloader) (targets '("/boot/efi")))) (kernel tinylinux) (file-systems (append (list (file-system (device "/dev/vda1") (mount-point "/") (type "ext4"))) %base-file-systems)) (setuid-programs '()) (services (list (service login-service-type) (service virtual-terminal-service-type) (service busybox-syslog-service-type) (service mingetty-service-type (mingetty-configuration (tty "tty1"))) (service static-networking-service-type (list %loopback-static-networking)) (service udev-service-type) (service busybox-sysctl-service-type (sysctl-configuration (sysctl (file-append busybox "/sbin/sysctl")))) (service special-files-service-type `(("/bin/sh" ,(file-append busybox "/bin/sh")) ("/usr/bin/env" ,(file-append busybox "/bin/env")))))) (packages (list busybox)) (users (list (user-account (inherit (@@ (gnu system) %root-account)) (shell (file-append busybox "/bin/sh"))))) (locale "en_US.utf8") (locale-definitions (list (locale-definition (name "en_US.utf8") (source "en_US") (charset "UTF-8")))) (locale-libcs (list glibc)))