diff --git a/buer.scm b/buer.scm new file mode 100644 index 0000000..bc42c04 --- /dev/null +++ b/buer.scm @@ -0,0 +1,277 @@ +#|Modules|# +(use-modules + #|GNU |# (gnu) (gnu artwork) (gnu services) (gnu system nss) + #|Guix |# (guix gexp) (guix packages) (guix records) + #|Misc |# (ice-9 match) + #|Radix|# (radix packages linux) (radix services linux) (radix system setuid) + (radix utils) (radix config secrets)) + +(use-service-modules + #|A|# admin + #|C|# configuration + #|D|# desktop + #|L|# linux + #|M|# mcron + #|N|# networking + #|S|# sound sysctl shepherd) + +(use-package-modules + #|A|# admin + #|B|# base bash + #|C|# certs compression curl + #|F|# file + #|G|# gawk glib guile guile-xyz + #|L|# less linux + #|M|# man maths + #|P|# pulseaudio + #|T|# texinfo text-editors tmux + #|V|# vpn) + +(define* (permit #:key (persist #f) + (keepenv #f) + (nopass #f) + (group "wheel") + (commands '(""))) + (format #f "~{~a~%~}" + (map (lambda (command) + (match (string-split command #\space) + ((command . args) + (format #f + "permit ~:[~;persist ~]~ + ~:[~;keepenv ~]~ + ~:[~;nopass ~]:~a~:[ cmd ~a args~{ ~a~}~;~]" + persist keepenv nopass group (string-null? command) command args)))) + commands))) + +#|Mcron jobs|# +(define garbage-collector-job + #~(job "5 0 * * *" "guix gc --optimize -F 5G")) + +#|Kernel modules configuration|# +(define modprobe-thinkfan-config + (plain-file "thinkfan.conf" + "options thinkpad_acpi experimental=1 fan_control=1")) + +#|etc files|# +(define thinkfan-config + (plain-file "thinkfan.conf" + (format #f "~@{~a~%~}" + "fans:" + "- tpacpi: /proc/acpi/ibm/fan" + + "sensors:" + " - hwmon: /sys/devices/platform/coretemp.0/hwmon" + " indices: [1,2,3]" + + "levels:" + " - [0, 0, 35]" + " - [1, 30, 40]" + " - [2, 35, 45]" + " - [3, 40, 50]" + " - [4, 45, 55]" + " - [5, 50, 60]" + " - [6, 55, 65]" + " - [7, 60, 70]" + " - [\"level full-speed\", 65, 260]"))) + +(define doas-config + (plain-file "doas.conf" + (format #f "~@{~a~%~}" + "permit setenv { GUILE_LOAD_PATH } :wheel" + (permit #:keepenv #t + #:commands '("kak" "emacsclient")) + (permit #:nopass #t + #:commands '("halt" "reboot" "guix pull" "herd status")) + (permit #:nopass #t + #:commands + (flatmap (lambda (service-name action) + (format #f "herd ~a ~a" action service-name)) + '("thinkfan" "wpa-supplicant") + '("doc" "stop" "start" "status" "restart")))))) + +#|Operating system definition|# +(operating-system + (host-name "buer") + (timezone "America/Sao_Paulo") + (locale "en_US.utf8") + + (keyboard-layout + (keyboard-layout "us,br" + #:options '("grp:menu_switch" + "parens:swap_brackets" + "caps:swapescape"))) + + (bootloader + (bootloader-configuration + (bootloader grub-bootloader) + (targets '("/dev/sda")) + (theme (grub-theme + (image (file-append %artwork-repository + "/backgrounds/guix-silver-checkered-16-9.svg")) + (resolution '(1280 . 720)) + (gfxmode '("1280x720x32")))))) + + (kernel linux-libre-6.4) + (kernel-arguments '("modprobe.blacklist=usbmouse,usbkbd" + "thinkpad_acpi.fan_control=1" + "loglevel=5" + "quiet")) + + (file-systems + (cons* (file-system + (device (file-system-label "guix-root")) + (mount-point "/") + (type "ext4")) + (file-system + (device (file-system-label "HOME")) ;doas e2label /dev/sda5 home + (mount-point "/home") + (type "ext4")) + %base-file-systems)) + + (swap-devices + (list (swap-space + (target (file-system-label "swap"))))) + + (users + (cons (user-account + (name "radio") + (password %radio-password) + (group "users") + (supplementary-groups `("audio" "input" "video" "wheel"))) + %base-user-accounts)) + + #|System level packages|# + (packages + (list #|admin |# htop inetutils isc-dhcp opendoas shadow + #|base |# bash coreutils diffutils findutils grep patch sed tar + which + #|certs |# nss-certs + #|compression |# bzip2 gzip lzip unzip xz + #|curl |# curl + #|file |# file + #|gawk |# gawk + #|glib |# dbus + #|guile |# guile-3.0-latest guile-colorized guile-irregex + guile-reader guile-readline + #|less |# less + #|linux |# acpi alsa-lib alsa-plugins alsa-utils e2fsprogs + eudev fuse inetutils inotify-tools iproute kbd kmod + lm-sensors procps psmisc thinkfan-next usbutils + util-linux + #|man |# man-db mandoc man-pages + #|math |# libqalculate + #|pulseaudio |# pulseaudio + #|texinfo |# info-reader + #|text-editors|# kak-lsp kakoune + #|tmux |# tmux + #|vpn |# wireguard-tools)) + + #|Do not generate a sudoers file|# + (sudoers-file #f) + + #|Run some programs from each package with file owner privileges|# + (setuid-programs + (map-setuid-programs + (shadow '("passwd" "chfn" "sg" "su" "newgrp" "newuidmap" "newgidmap")) + (inetutils '("ping" "ping6")) + (opendoas '("doas")) + (fuse '("fusermount")) + (util-linux '("mount" "umount")))) + + #|Allow resolution of '.local' host names with mDNS|# + (name-service-switch %mdns-host-lookup-nss) + + #|System services|# + (services + (list #|TTY services|# + (service virtual-terminal-service-type) + (service console-font-service-type + (associate-right + (%default-console-font '("tty1" "tty2")))) + (service agetty-service-type + (agetty-configuration + (extra-options '("-L")) + (term "vt100") + (tty #f))) + (service mingetty-service-type + (mingetty-configuration (tty "tty1"))) + (service mingetty-service-type + (mingetty-configuration (tty "tty2"))) + + #|Login services|# + (service login-service-type) + (service elogind-service-type) + + #|Log services|# + (service rottlog-service-type) + (service syslog-service-type + (syslog-configuration + (syslogd (file-append inetutils "/libexec/syslogd")) + (config-file %default-syslog.conf))) + (service log-cleanup-service-type + (log-cleanup-configuration + (directory "/var/log/guix/drvs") + (expiry (* 3 30 24 3600)))) + + #|Guix services|# + (service guix-service-type + (guix-configuration + (build-accounts 16) + (extra-options '("--max-jobs=8" "--cores=4")))) + + #|Mcron service|# + (simple-service 'mcron-jobs mcron-service-type + (list garbage-collector-job)) + + #|Device management services|# + (service udev-service-type + (udev-configuration + (udev eudev) + (rules (list lvm2 fuse alsa-utils crda)))) + + #|Sound services|# + (service alsa-service-type) + + #|Network services|# + (service static-networking-service-type + (list (static-networking + (addresses + (list (network-address (device "lo") + (value "127.0.0.1/8")))) + (provision '(loopback))))) + (service wpa-supplicant-service-type + (wpa-supplicant-configuration + (config-file "/etc/wpa_supplicant.conf") + (interface "wlp2s0") + (extra-options '("-B")))) + (service dhcp-client-service-type + (dhcp-client-configuration + (interfaces 'all))) + + #|Thinkfan services|# + (simple-service 'thinkfan-config etc-service-type + `(("modprobe.d/thinkfan.conf" ,modprobe-thinkfan-config) + ("thinkfan.conf" ,thinkfan-config))) + (service thinkfan-service-type + (thinkfan-configuration + (config-file thinkfan-config) + (respawn? #f))) + + #|Doas config service|# + (simple-service 'doas-config etc-service-type + `(("doas.conf" ,doas-config))) + + #|Special file services|# + (service special-files-service-type + `(("/bin/sh" ,(file-append bash "/bin/bash")) + ("/usr/bin/env" ,(file-append coreutils "/bin/env")))) + + #|Miscellaneous services|# + (service urandom-seed-service-type) + (service nscd-service-type) + (service sysctl-service-type + (sysctl-configuration + (sysctl (file-append procps "/sbin/sysctl")) + (settings '(("fs.protected_hardlinks" . "1") + ("fs.protected_symlinks" . "1")))))))) + diff --git a/home/services.scm b/modules/radix/home/services.scm similarity index 100% rename from home/services.scm rename to modules/radix/home/services.scm diff --git a/packages/fonts.scm b/modules/radix/packages/fonts.scm similarity index 100% rename from packages/fonts.scm rename to modules/radix/packages/fonts.scm diff --git a/packages/linux.scm b/modules/radix/packages/linux.scm similarity index 100% rename from packages/linux.scm rename to modules/radix/packages/linux.scm diff --git a/packages/wm.scm b/modules/radix/packages/wm.scm similarity index 100% rename from packages/wm.scm rename to modules/radix/packages/wm.scm diff --git a/services/linux.scm b/modules/radix/services/linux.scm similarity index 100% rename from services/linux.scm rename to modules/radix/services/linux.scm diff --git a/system/setuid.scm b/modules/radix/system/setuid.scm similarity index 100% rename from system/setuid.scm rename to modules/radix/system/setuid.scm diff --git a/utils.scm b/modules/radix/utils.scm similarity index 100% rename from utils.scm rename to modules/radix/utils.scm diff --git a/radio.scm b/radio.scm new file mode 100644 index 0000000..48f15d4 --- /dev/null +++ b/radio.scm @@ -0,0 +1,413 @@ +#|Modules|# +(use-modules + #|GNU |# (gnu) (gnu home) (gnu home services) + #|Guix |# (guix colors) + #|Radix|# (radix packages fonts) (radix packages wm) (radix home services) + (radix utils) + #|SRFI |# (srfi srfi-13) (srfi srfi-26)) + +(use-package-modules + #|A|# admin + #|B|# base bash bittorrent browser-extensions + #|C|# c calendar + #|D|# disk + #|E|# emacs emacs-xyz + #|F|# freedesktop fonts + #|G|# games gnome gnu-doc gnupg gnuzilla gtk guile-xyz + #|I|# image-viewers + #|L|# linux + #|M|# mail maths mes messaging minetest + #|P|# package-management password-utils pdf plotutils pulseaudio python-xyz + #|S|# scheme ssh suckless + #|T|# telegram tex text-editors tor toys + #|V|# version-control video + #|W|# web-browsers wm + #|X|# xdisorg xorg) + +(use-home-service-modules + #|D|# desktop + #|M|# mcron + #|S|# shells ssh shepherd + #|X|# xdg) + +#|Mcron jobs|# +(define alarm-clock-job + #~(job "30 6 * * *" "mpv --shuffle $XDG_MUSIC_DIR")) + +#|Dotfiles|# +(define bash-functions + (plain-file "bash_functions" + (format #f "~@{~a~%~}" + #|Spawn terminal independent applications from the terminal|# + "tf() { setsid -f \"$@\" >/dev/null 2>&1 & disown; }" + + #|Make doas work as doas su when runned without arguments alone |# + "doas() { [ $# -eq 0 ] && $(which doas) -s || $(which doas) \"$@\"; }" + + #|Use kakoune as manpage reader|# + "man() { kak -e \"evaluate-commands man $1\"; }" + + #|Easily send files to the 0x0 pastebin|# + "zxz(){ printf \"$1\\n$(curl -F file=@$1 http://0x0.st)\\n\"; }"))) + +(define bashrc + (plain-file "bashrc" + (format #f "~@{~a~%~}" + #|Source system-wide file|# + "[ -f /etc/bashrc ] && source /etc/bashrc" + + #|Adds `~/.local/bin/ to $PATH|# + "export PATH=\"$PATH:$(du $HOME/.local/bin/ \\" + " | cut -f2 \\" + " | tr '\\n' ':' \\" + " | sed 's/:*$//')\"" + + "export SHELL" + + #|If not running interactively, source /etc/profile if + we are in a ssh session otherwise, don't do anything|# + "if [[ $- != *i* ]]; then" + " [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile" + " return" + "fi" + + #|PS1 definition|# + (let* ((blue (cut colorize-string <> (color BLUE))) + (reset (cut colorize-string <> (color RESET)))) + (string-append "PS1=" + "'${GUIX_ENVIRONMENT:+[" (blue "env") " ${GUIX_ENVIRONMENT}]\\n}" + (blue "\\u") " at " (blue "\\W") " " + "$(git branch &>/dev/null && git branch 2>/dev/null | " + "sed -n \"s/* \\(.*\\)/on " (blue "\\1") (reset " /p\")> ") "'")) + + #|Colors for TTY|# + (format #f "[ \"$TERM\" = \"linux\" ] && {\\~%~ + ~:{ echo -en \"\\e]P~@(~x~)\"'~a'~%~}~ + }" + (map list (iota 16) + `(#|black |# "070707" + #|darkred |# "df6760" + #|darkgreen |# "8be760" + #|brown |# "ffd17a" + #|darkblue |# "9688d9" + #|darkmagenta|# "86adff" + #|darkcyan |# "86adff" + #|darkgrey |# "f1f1f1" + + #|lightgrey |# "070707" + #|red |# "df6760" + #|green |# "8be760" + #|brown |# "ffd17a" + #|blue |# "9688d9" + #|magenta |# "86adff" + #|cyan |# "86adff" + #|white |# "f1f1f1"))) + + #|st window title|# + "trap 'printf \"\\033]0;%s\\007\" \"${BASH_COMMAND//[^[:print:]]/}\"' DEBUG"))) + +(define bash-profile + (plain-file "bash_profile" + (format #f "~@{~a~%~}" + ". \"$GUIX_PROFILE/etc/profile\"" + "[ \"$(tty)\" = \"/dev/tty1\" ] && sx 1>/dev/null 2>&1"))) + +(home-environment + (packages + (list #|admin |# neofetch + #|bash |# bash bash-completion + #|bittorrent |# aria2 qbittorrent + #|c |# c-intro-and-ref + #|calendar |# remind + #|disk |# lf ;Remove if I get used to dirvish + #|emacs |# emacs-next + #|emacs-xyz |# + #| • completion |# emacs-cape emacs-corfu emacs-corfu-doc + emacs-consult-lsp emacs-vertico + #| • centering |# emacs-olivetti + #| • file manager |# emacs-dirvish + #| • fuzzy-finder |# emacs-orderless + #| • guile |# emacs-geiser emacs-geiser-guile + emacs-macrostep-geiser emacs-geiser-eros + #| • guix |# emacs-guix emacs-direnv + #| • haunt |# emacs-ox-haunt + #| • icons |# emacs-all-the-icons + #| • irc |# emacs-circe + #| • kakoune |# emacs-kakoune emacs-phi-search-mc emacs-ryo-modal + #| • latex |# emacs-auctex emacs-latex-preview-pane + #| • linter |# emacs-flycheck emacs-flycheck-guile + #| • maps |# emacs-osm + #| • music player |# emacs-emms + #| • org |# emacs-org-bullets emacs-org-fragtog + emacs-org-present emacs-org-roam emacs-org-modern + #| • pulsar |# emacs-pulsar + #| • rss |# emacs-elfeed emacs-elfeed-org + #| • s-expressions |# emacs-lispy emacs-rainbow-delimiters + #| • ease config |# emacs-setup + #| • typing |# emacs-typing + #| • terminal |# emacs-eat + #| • maybe sometime |# ;emacs-shroud + ;emacs-eradio + ;emacs-scratch-el + ;emacs-mastodon + #|fonts |# font-arabic-misc font-liberation font-meslo-lg-dz + font-misc-misc font-un font-wqy-zenhei + #|freedesktop |# xdg-utils + #|games |# minetest supertuxkart xonotic + #|gnome |# adwaita-icon-theme + #|gnu-doc |# gnu-standards + #|gnupg |# gnupg pinentry + #|gnuzilla |# icecat + #|gtk |# guile-cairo + #|guile-xyz |# guile-irregex guile-machine-code guile-ncurses + guile-pipe guile-pfds guile-quickcheck guile-smc + guile-srfi-159 guile-srfi-189 haunt + #|image-viewers |# nsxiv + #|maths |# libqalculate + #|messaging |# toxic + #|package-management|# gwl + #|password-utils |# keepassxc + #|pdf |# zathura zathura-pdf-mupdf zathura-pdf-poppler + zathura-djvu + #|plotutils |# guile-charting + #|pulseaudio |# pulseaudio pamixer pavucontrol + #|python-xyz |# python-ueberzug + #|scheme |# sicp slib + #|ssh |# openssh + #|suckless |# lukesmithxyz-st + #|telegram |# telegram-desktop + #|tex |# texlive-amsfonts texlive-scheme-basic + texlive-beamer texlive-bibtex texlive-ec + texlive-latex-fonts texlive-graphics + texlive-float texlive-geometry texlive-minted + texlive-pdfx texlive-texinfo texlive-tools + texlive-unicode-math + #|tor |# tor + #|toys |# oneko + #|vesion-control |# git + #|video |# ffmpeg mpv yt-dlp + #|web-browsers |# nyxt + #|wm |# awesome-next + #|xdisorg |# maim redshift xbanish xclip xdotool xinit xsel + #|xorg |# setxkbmap xinput xf86-input-libinput + xf86-video-vesa xf86-video-fbdev xf86-video-intel + xkill xmodmap xorg-server xrdb xset)) + + (services + (list #|XDG services|# + (simple-service 'xdg-base-directories-service + home-xdg-base-directories-service-type + (home-xdg-base-directories-configuration + (cache-home "$HOME/.cache") + (config-home "$HOME/.config") + (data-home "$HOME/.local/share") + (runtime-dir "/run/user/1000") + (log-home "$HOME/.local/var/log") + (state-home "$HOME/.local/state"))) + + (simple-service 'xdg-user-directories-service + home-xdg-user-directories-service-type + (home-xdg-user-directories-configuration + (desktop "$HOME/desktop") + (documents "$HOME/documents") + (download "$HOME/.local/share/downloads") + (music "$HOME/music") + (pictures "$HOME/pictures") + (videos "$HOME/videos") + (publicshare "") + (templates ""))) + + (simple-service 'xdg-mime-applications-service + home-xdg-mime-applications-service-type + (home-xdg-mime-applications-configuration + (default (associate-right + ('icecat.desktop + `("text/html" + "application/xhtml+xml" + "application/x-extension-htm" + "application/x-extension-xhtml" + "application/x-extension-xht" + "x-scheme-handler/http" + "x-scheme-handler/https")) + ('kak.desktop + `("text/plain" + "text/troff" + "text/xml" + "text/x-c" + "text/x-c++" + "text/x-diff" + "text/x-lisp" + "text/x-scheme" + "text/x-shellscript" + "text/x-tex")) + ('lf.desktop + `("inode/directory" + "x-scheme-handler/ftp" + "x-scheme-handler/nfs" + "x-scheme-handler/smb" + "x-scheme-handler/ssh" + "application/x-directory")) + ('mpv.desktop + `("image/gif" + "audio/mpeg" + "audio/ogg" + "audio/opus" + "audio/x-opus+ogg" + "video/mp4" + "video/x-matroska" + "video/webm")) + ('nsxiv.desktop + `("image/avif" + "image/bmp" + "image/jpeg" + "image/png" + "image/svg+xml" + "image/webp")) + ('org.pwmt.zathura.desktop + `("image/vnd.djvu" + "application/pdf" + "application/epub+zip")))))) + + #|Shepherd service|# + (service home-shepherd-service-type) + + #|Shell services|# + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #f) + (bashrc (list bash-functions bashrc)) + (bash-profile (list bash-profile)) + (aliases + `(#|Common aliases|# + ("df" . "df -h") + ("diff" . "diff --color=auto") + ("grep" . "grep --color=auto") + ("ip" . "ip --color=auto") + ("ls" . ,(format #f "ls --color=auto ~ + --group-directories-first ~ + --classify ~ + -hlv")) + + #|Make ln idempotent|# + ("ln" . "ln -sfn") + + #|Kakoune bindings for info|# + ("info" . "info --init-file $XDG_CONFIG_HOME/infokeys") + + #|Download music and videos with based formats|# + ("m" . "yt-dlp --prefer-free-formats --extract-audio") + ("v" . "yt-dlp --prefer-free-formats") + + #|Easy presentation setup with xrandr|# + ("present" . ,(format #f "xrandr --output LVDS-1 ~ + --mode 1366x768 ~ + --scale 1x1 ~ + --output VGA-1 ~ + --same-as LVDS-1 ~ + --mode 1920x1080 ~ + --scale 0.711x0.711")) + + #|Display images in lf using ueberzug|# + ("lf" . "$XDG_CONFIG_HOME/lf/lfrun") + + #|Make GPG xdg compliant|# + ("gpg" . "gpg --homedir $XDG_DATA_HOME/gnupg") + + #|Listen to libre music on vern's radio|# + ("radio" . "https://radio.vern.cc") + + #|Kakoune aliases for the shell|# + ("':e'" . "kak") + ("':q'" . "exit"))))) + + (simple-service 'environment-variables-service + home-environment-variables-service-type + `(#|Bash|# + ("HISTFILE" . "$XDG_CACHE_HOME/bash/history") + ("HISTSIZE" . "-1") + ("HISTFILESIZE" . "-1") + + #|Language|# + ("LANG" . "en_US.UTF-8") + ("LANGUAGE" . "en_US.UTF-8") + ("LC_COLLATE" . "C") + + #|Default applications|# + ("EDITOR" . "kak") + ("READER" . "zathura") + ("VISUAL" . "kak") + ("TERMINAL" . "st") + ("BROWSER" . "icecat") + ("PAGER" . "less") + ("WM" . "awesome") + ("FCEDIT" . "kak") + + #|Xorg|# + ("XINITRC" . "$XDG_CONFIG_HOME/X11/xinitrc") + + #|Readline|# + ("INPUTRC" . "$XDG_CONFIG_HOME/readline/inputrc") + + #|GTK|# + ("GTK_RC_FILES" . "$XDG_CONFIG_HOME/gtk-2.0/gtkrc") + + #|Guile|# + ;("GUILE_WARN_DEPRECATED" . "detailed") + ("GUILE_HISTORY" . "$XDG_CACHE_HOME/guile/history") + ("GUILE_LOAD_PATH" . ,(string-join + (cons "$HOME/projects/guile" + (map (cut string-append <> "/share/guile/site/3.0") + '("/run/current-system/profile" + "$XDG_CONFIG_HOME/guix/current" + "$HOME/.guix-home/profile"))) + ":" 'infix)) + + #|GUIX|# + ("GUIX_PROFILE" . "$XDG_CONFIG_HOME/guix/current") + + #|Other program settings|# + ("RUNLEVEL" . "3") + ("TERMINFO" . "$XDG_DATA_HOME/terminfo") + ("GRADLE_USER_HOME" . "$XDG_DATA_HOME/gradle") + ("RUSTUP_HOME" . "$XDG_DATA_HOME/rustup") + ("CARGO_HOME" . "$XDG_DATA_HOME/cargo") + ("GNUPGHOME" . "$XDG_DATA_HOME/gnupg") + ("DOTREMINDERS" . "$XDG_DATA_HOME/reminders"))) + + (service home-openssh-service-type + (home-openssh-configuration + (hosts (list (openssh-host + (name "codeberg.org") + (host-name "codeberg.org") + (user "git") + (identity-file "~/.ssh/codeberg")))) + (authorized-keys #f))) + + #|The following two services are currently not working since they depend + on a xsession to running to start. The possible solution is to launch + X on the home-run-on-first-login-service, but I do not know how to + extend such service yet|# + + #|Redshift service|# + ; (service home-redshift-service-type + ; (home-redshift-configuration + ; (location-provider 'manual) + ; (latitude (- 21.1)) + ; (longitude (- 47.8)) + ; (daytime-brightness 1.0) + ; (nighttime-brightness 0.6) + ; (daytime-temperature 4500) + ; (nighttime-temperature 4000) + ; (extra-content "fade=1"))) + + #|Xmodmap service|# + ; (service home-xmodmap-service-type + ; (home-xmodmap-configuration + ; (key-map + ; `(("keycode 47" . "colon semicolon ccedilla Ccedilla"))))) + + #|Mcron service|# + (service home-mcron-service-type + (home-mcron-configuration + (jobs (list alarm-clock-job))))))) +