Skip to content

Latest commit

 

History

History
2844 lines (2474 loc) · 94.8 KB

systems.org

File metadata and controls

2844 lines (2474 loc) · 94.8 KB

system configuration

My system configurations for GNU Guix, compiled by GNU Emacs, deployed by GNU Stow.

involves some system administration, programming, and rice.

inspired by System Configuration with Guix - config.daviwil.com

=get-headline-path= headline parsing function

~/dotfiles/.doom.d/config.org::*globals

housekeeping

:: .local/bin/housekeeping.sh

description

echo -e "number of files: $(find . | wc -l)\n"

$HOME/.config

tree -a -L 2 $HOME/git $1 && echo -e "\n\n"

$HOME/.config/guix

tree -a $HOME/dotfiles/.config/guix $1 && echo -e "\n\n"

5 directories, 14 files

$HOME/.local/bin

tree -a $HOME/dotfiles/.local/bin $1 && echo -e "\n\n"

$HOME/git

keep it as category/{repo, repo, repo} for sanity

tree -a -L 2 $HOME/git $1  && echo -e "\n\n"

init

cd $HOME
mkdir -p git


for $d in build sys ns qzdl ; do
    echo "$HOME/git/$d"
    mkdir -p $HOME/git/$d

configuration

docs, testing

helpers

headline() {
  echo "============================"
  echo $@
  echo "============================"
}

block() {
    echo "===$@"
}

delim() { echo && echo; }

dotfiles-test.sh

source helpers.sh
source $HOME/.config/shell/profile

MY_BASEPATH=$HOME/dotfiles
GUIX_LOADPATH_MY="$MY_BASEPATH/.config/guix"
GUIX_LOADPATH_QZDL="$GUIX_LOADPATH_MY/qzdl"
res=($(headline "Testing Results") )

cd $MY_BASEPATH

while getopts ":h" option; do
    case $option in #(((
        h)
            help
            exit;;
        l)
            LINT=1 run_test
            exit;;
        \?) # unknown opt
            echo "ERROR: unknown option"
            exit 1;;
    esac
done
help() {
    echo "Test guix config"
    echo
    echo "usage: 'bash test-system.sh'"
    echo "options: -[h|l]"
    echo "h     print this help"
    echo "l     lint $GUIX_LOADPATH_QZDL"

}

test-load-file() {
    FILE=$1
    (
      echo "...TESTING $FILE"
      echo ".....LOADING 'GUIX REPL -L $GUIX_LOADPATH_MY $FILE'"
      guix repl -L $GUIX_LOADPATH_MY $FILE \
          && qz_color $qz_greener ".....PASSED: $FILE"
      guild compile -L $GUIX_LOADPATH_MY $FILE
    )
}

run_test() {
  headline "TESTING SYSTEM CONFIGURATION"

  block "BEGIN: GUIX SYSTEM DESCRIBE"
  guix system describe
  block "END: GUIX SYSTEM DESCRIBE"
  delim

  if [ $LINT ]; then
    block "BEGIN: GUIX LINT"
    echo "...LINTING $GUIX_LOADPATH_QZDL"
    guix lint -L $GUIX_LOADPATH_QZDL
    block "END: GUIX LINT"
    delim
  fi
}

run_test

dotfiles-tangle.el

:: .doom.d/scripts/dotfiles-tangle.el

(require 'org)

(defun qz/tangle-sys ()
  (interactive)
;; Don't ask when evaluating code blocks
(setq-local org-confirm-babel-evaluate nil)

(let* ((dotfiles-path (expand-file-name "~/dotfiles/"))
       (org-files (directory-files dotfiles-path nil "\\.org$")))

  (defun dw/tangle-org-file (org-file)
    (message "\n\033[1;32m...Updating %s\033[0m\n" org-file)
    (org-babel-tangle-file (expand-file-name org-file dotfiles-path)))

  ;; Tangle Systems.org first
  (dw/tangle-org-file "systems.org")

  (dolist (org-file org-files)
    (unless (member org-file '("README.org" "systems.org"))
      (dw/tangle-org-file org-file)))))

(qz/tangle-sys)

dotfiles-update.sh

source helpers.sh
cd $HOME/dotfiles

headline "UPDATING DOTFILES"
delim

block "BEGIN: COMPILE DOTFILES"
emacs -Q --batch --script $HOME/dotfiles/.doom.d/scripts/dotfiles-tangle.el
block "END: COMPILE DOTFILES"
delim

block "BEGIN: STOW DOTFILES"
dotfiles-nonstow.sh
stow .
block "END: STOW DOTFILES"
delim

block "BEGIN: UPDATE EMACS INSTANCE"
emacsclient \
    -e '(load-file "~/dotfiles/.doom.d/per-system-settings.el")' \
    -a "No emacs server running"
block "END: UPDATE EMACS INSTANCE"
delim

dotfiles-nonstow.sh

for f in .profile .bash_profile .zsh_profile; do
    [ -f $HOME/$f ] && echo "$HOME/$f already exists!" && continue
    ln -s $HOME/dotfiles/.config/shell/profile $HOME/$f
done;

dotfiles-get-guix-deps.sh

:: .local/bin/dotfiles-get-guix-deps.sh

make some pretty graphs from the dependency graph. thanks guild developers

cd $HOME/dotfiles
mkdir -p docs
cd docs
#drivers=(dot neato twopi circo fdp sfdp patchwork)
driver=neato

for file in $(find $HOME/.config/guix/) ; do
    [ ! -f $file ] && continue
    df="$(basename $file)"
    [ $VERBOSE ] && echo "deps: running guild for deps of $file, to $df"
    guild use2dot $file > $df

    dp="$df.png"
    qz_color $qz_greener "✔:$driver:$dp"
    $driver $df -Tpng -o $dp -Goverlap=false -Gsplines=true
done

precommit

to run before committing, compile docs, test etc

dotfiles-update.sh
dotfiles-test.sh
dotfiles-get-guix-deps.sh

debug

tree

tangled files

( for f in $(cat systems.org | grep ":tangle" | cut -d' ' -f4); do [ -f $f ] && echo $f; done; ) | sort | uniq

channels

:: Channels (GNU Guix Reference Manual)

.config/guix/channels.scm

;; GENERATED BY ~/dotfiles/system.org
(list
 (channel
  (name 'guix)
  (url "https://git.savannah.gnu.org/git/guix.git"))
 ;; for the kernel + firmware
 (channel
  (name 'nonguix)
  (url "https://gitlab.com/nonguix/nonguix"))
 ;; for emacs-libgccjit
 (channel
  (name 'flat)
  (url "https://github.com/flatwhatson/guix-channel.git")
  (commit
   "86fb7253a4384b70c77739a0e03115be75d60ad1")
  (introduction
   (make-channel-introduction
    "33f86a4b48205c0dc19d7c036c85393f0766f806"
    (openpgp-fingerprint
     "736A C00E 1254 378B A982  7AF6 9DBE 8265 81B6 4490"))))
 ;; a great effort from infra hpc
 ;;(channel
 ;; (name 'guix-past)

 ;; (url "https://gitlab.inria.fr/guix-hpc/guix-past")
 ;; (introduction
 ;;  (make-channel-introduction
 ;;   "0c119db2ea86a389769f4d2b9c6f5c41c027e336"
 ;;   (openpgp-fingerprint
 ;;    "3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5"))))
)

HACK inferiors for python

this does not work how I want; it will not install python from the revision of guix specified by the given commit sha

(use-modules (guix inferior)
             (guix)
             (srfi srfi-1))

(define pychannel
  (list (channel
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
         (commit "5c798ca71dcd009896654da7d6a1f8942c6f3c50"))))

(define inferior
  (inferior-for-channels pychannel))

(packages->manifest
 (list (first (lookup-inferior-packages inferior "python"))))

(qzdl cosas)

:: .config/guix/qzdl/cosas.scm ::

./docs/cosas.scm.png

define

(define-module (qzdl cosas)
  #:use-module (gnu system keyboard)
  #:export (my-name
            my-keyboard-layout))

(define my-name "Samuel Culpepper")

(define my-keyboard-layout
  (keyboard-layout "us" "altgr-intl" #:model "thinkpad"))

test

test-load-file $HOME/dotfiles/.config/guix/qzdl/cosas.scm

(qzdl rules)

:: .config/guix/qzdl/rules.scm ::

./docs/rules.scm.png

test

test-load-file .config/guix/qzdl/rules.scm

define

(define-module (qzdl rules)
  #:use-module (gnu services base)
  #:use-module (gnu services desktop)
  #:export (%udev-rule-backlight
            %xorg-libinput-config
            %xorg-intel-antitearing-i915))

udev-rule-backlight

:: Base Services (GNU Guix Reference Manual) allow members of the “video” group to change the screen brightness.

(define %udev-rule-backlight
  (udev-rule
   "90-backlight.rules"
   (string-append "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
                  "RUN+=\"/run/current-system/profile/bin/chgrp video /sys/class/backlight/%k/brightness\""
                  "\n"
                  "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
                  "RUN+=\"/run/current-system/profile/bin/chmod g+w /sys/class/backlight/%k/brightness\"")))

libinput-gestures

# previously ~/.config/libinput-gestures.conf

gesture: swipe right 3 xdotool key Alt+Left
gesture: swipe left 3 xdotool key Alt+Right

# Zoom in / Zoom out
gesture: pinch out xdotool key Ctrl+plus
gesture: pinch in xdotool key Ctrl+minus

xorg screentearing-rule

:: https://www.dedoimedo.com/computers/linux-intel-graphics-video-tearing.html

replace i915 with your video driver, as decribed below

this stops tears, but probably wrecks some other thing about frame buffering.

IMO, on my hardware, it’s better than without

(define %xorg-intel-antitearing-base
  "Section \"Device\"
  Identifier \"Intel Graphics\"
  Driver \"%s\"
  Option \"TearFree\"    \"true\"
EndSection")

(define %xorg-intel-antitearing-i915
 (format #f %xorg-intel-antitearing-base "i915"))
find video driver
sudo lspci -k | grep -EA3 'VGA|3D|Display'

(qzdl jobs)

:: .config/guix/qzdl/jobs.scm :: Mcron User Requirements :: Mcron User Requirements :: ./docs/jobs.scm.png

https://www.gnu.org/software/mcron/manual/html_node/Introduction.html#Introduction

test

test-load-file .config/guix/qzdl/jobs.scm

define

(define-module (qzdl jobs)
  #:use-module (gnu)
  #:use-module (guix)
  #:use-module (gnu services mcron)
  #:export (updatedb-job))

updatedb

;;(define updatedb-job
;;  ;; Run 'updatedb' at 3AM every day.  Here we write the
;;  ;; job's action as a Scheme procedure.
;;  #~(job '(next-hour '(3))
;;         (lambda ()
;;           (execl (string-append #$findutils "/bin/updatedb")
;;                  "updatedb"
;;                  "--prunepaths=/tmp /var/tmp /gnu/store"))))

life auto-commit

;; (define autocommit-job
;;   #~(job )
;;    )

guix pull at night

(qzdl services)

:: .config/guix/qzdl/services.scm ::

./docs/services.scm.png

test

test-load-file $HOME/dotfiles/.config/guix/qzdl/services.scm

define

(define-module (qzdl services)
  #:use-module (qzdl cosas)
  #:use-module (qzdl rules)
  #:use-module (srfi srfi-1)            ;; provides remove, member
  #:use-module (gnu packages gnome)     ;; for network-manager-openvpn
  #:use-module (gnu packages suckless)  ;; for slock
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services desktop)   ;; for udev, x11 socket
  #:use-module (gnu services databases) ;; for postgres
  #:use-module (gnu services dbus)
  #:use-module (gnu services desktop)   ;; FIXME %desktop-services is blote
  #:use-module (gnu services docker)
  #:use-module (gnu services networking)
  #:use-module (gnu services sound)
  #:use-module (gnu services ssh)
  #:use-module (gnu services virtualization)
  #:use-module (gnu services xorg)      ;; FIXME to remove gdm-service-type
  #:export (my-libvirt-service
            my-docker-service
            my-dbus-service
            my-bluetooth-service

            my-wpa-supplicant-service
            my-network-manager-service
            my-ssh-service

            my-postgresql-service
            my-postgresql-role-service

            my-xorg-service
            my-x11-socket-directory-service

            my-udev-service
            my-dbus-service
            my-ntp-service
            my-elogind-service

            %my-desktop-services))

services

bluetooth-service

users must be in the lp group

(define my-bluetooth-service
  (bluetooth-service #:auto-enable? #t))
postgresql-service

:: https://guix.gnu.org/manual/en/html_node/Database-Services.html

(define my-postgresql-role-service
  (service postgresql-role-service-type
   (postgresql-role-configuration
    (roles
     (list (postgresql-role
            (name "postgres")
            (create-database? #t))
           (postgresql-role
            (name "samuel")
            (create-database? #t)))))))

(define my-postgresql-service
  (service postgresql-service-type))
network-manager-service w/ openvpn

:: (gnu services networking) :: Networking Services (GNU Guix Reference Manual)

(define my-network-manager-service
  (service network-manager-service-type
   (network-manager-configuration
    (vpn-plugins (list network-manager-openvpn)))))
wpa-supplicant
(define my-wpa-supplicant-service
  (service wpa-supplicant-service-type))
sshd service
(define my-ssh-service
  (service openssh-service-type
           (openssh-configuration
            (x11-forwarding? #t))))
virtualisation; libvirt
(define my-libvirt-service
  (service libvirt-service-type
           (libvirt-configuration
            (unix-sock-group "libvirt")
            (tls-port "16555"))))
(slim)login & xorg

:: X Window (GNU Guix Reference Manual) :: /run/current-system/profile/share :: /run/current-system/profile/share/xsessions

in GNU Guix, the xorg service is coupled to a login manager, such as GDM, or SLiM.

a window manager must be specified in the system-packages

(define my-xorg-service
  (service slim-service-type
           (slim-configuration
            (xorg-configuration
             (xorg-configuration
              (keyboard-layout my-keyboard-layout)
              (extra-config
               (list %xorg-libinput-config
                     %xorg-intel-antitearing-i915)))))))

elogind

:: (gnu services desktop)

(define my-elogind-service
  (service elogind-service-type
           (elogind-configuration
            (handle-lid-switch-external-power 'suspend))))
dbus

:: gnu/services/dbus

(define my-dbus-service
    (dbus-service))
udev

:: (gnu services base)

(define my-udev-service
  (simple-service 'udev-rules udev-service-type
                  (udev-configuration
                   (rules %udev-rule-backlight))))
ntp; network time

:: (gnu services networking)

(define my-ntp-service
  (service ntp-service-type))
x11 socket

:: UNIX domain sockets - IBM :: Unix domain socket - Wikipedia :: https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html

(define my-x11-socket-directory-service
  x11-socket-directory-service)
pulse/alsa
(define my-pulseaudio-service
 (service pulseaudio-service-type))

(define my-alsa-service
  (service alsa-service-type))
docker

requires user & group

(define my-docker-service
  (service docker-service-type))

composition

homelab services

grafana, prometheus, …

development services
desktop services
(define %my-desktop-services
  (list my-xorg-service
        my-x11-socket-directory-service
        my-pulseaudio-service
        my-alsa-service
        my-screen-locker-service
        my-network-manager-service
        my-wpa-supplicant-service
        my-elogind-service))

(qzdl package)

:: .config/guix/qzdl/package

manifest

(specifications->manifest
  (list "figlet"
        "nyxt"
        "lm-sensors"
        "password-store"
        "parallel"
        "gnuplot"
        "r"
        "csvkit"
        "jq"
        "maim"
        "scrot"
        "awscli"
        "libnotify"
        "font-fira-code"
        "font-google-roboto"
        "guile-git"
        "emacs-forge"
        "guile-readline"
        "guile-colorized"
        "texlive-base"
        "xss-lock"
        "xset"
        "xsettingsd"
        "xhost"
        "sxiv"
        "graphviz"
        "emacs-native-comp"
        "mpv"
        "ffmpeg"
        "python-virtualenv"
        "libgccjit"
        "postgresql"
        "docker-compose"
        "docker"
        "python-alembic"
        "bluez-alsa"
        "bluez"
        "emacs-jedi"
        "imagemagick"
        "python-pywal"
        "dunst"
        "gnupg"
        "curl"
        "cmake"
        "emacs-elpy"
        "python-flake8"
        "python-pip"
        "python"
        "python-pyzstd"
        "recutils"
        "ripgrep"
        "gcc-toolchain"
        "openssh"
        "pulsemixer"
        "emacs-guix"
        "firefox"
        "arandr"
        "xrandr"
        "cairo"
        "pango"
        "compton"
        "icecat"
        "feh"
        "xf86-input-libinput"
        "xorg-server"
        "xinit"
        "xterm"
        "xdg-utils"
        "emacs-exwm"
        "htop"
        "noisetorch"
        "emacs-prettier"
        "tigervnc-client"
        "xclip"
        "dmenu"
        "emacs-git-link"
        "emacs-alert"
        "filters"
        "autoconf"
        "rlwrap"
        "readline"
        "guile"
        "setxkbmap"
        "tar"
        "xz"
        "zlib"
        "bzip2"
        "glibc"
        "emacs-vterm"
        "emacs-emacsql"
        "make"
        "sqlite"
        "emacs-sqlite"
        "font-dejavu"
        "tree"
        "font-gnu-unifont"
        "xf86-video-fbdev"
        "emacs-desktop-environment"))

v4l2loopback-linux-module

virtual video devices; hijack the webcam feed, or stream an application though loopback

mtools

:: Mtools - GNU Project - Free Software Foundation

dunst

:: https://dunst-project.org/ :: https://dunst-project.org/documentation

notify-emacs.sh

a script from u/deaddyfreddy, from https://reddit.com/r/emacs/comments/klsxwv/enabling_desktop_notifications_with_dunst_emacs/ghb17s2

#!/bin/sh

APPNAME="$1"
SUMMARY="$2"
BODY="$3"
ICON="$4"
URGENCY="$5"
emacsclient -n --eval "(message \"${APPNAME}/${SUMMARY}: $BODY\")"

gnuzilla

firefox

emacs-native-comp

for development machines, gotta go fast

emacs

python-3.6.4

(define-public python-3.6
  (package (inherit python-2)
    (version "3.6.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://www.python.org/ftp/python/"
                                  version "/Python-" version ".tar.xz"))
              (patches (search-patches
                        "python-fix-tests.patch"
                        "python-3-fix-tests.patch"
                        "python-3-deterministic-build-info.patch"
                        "python-3-search-paths.patch"))
              (patch-flags '("-p0"))
              (sha256
               (base32
                "1fna7g8jxzl4kd2pqmmqhva5724c5m920x3fsrpsgskaylmr76qm"))
              (snippet
               '(begin
                  (for-each delete-file
                            '("Lib/ctypes/test/test_structures.py" ; fails on aarch64
                              "Lib/ctypes/test/test_win32.py" ; fails on aarch64
                              "Lib/test/test_fcntl.py")) ; fails on aarch64
                  #t))))
    ;; (arguments
    ;;  (substitute-keyword-arguments (package-arguments python-2)
    ;;    ((#:tests? _) #t)
    ;;    ((#:phases phases)
    ;;     `(modify-phases ,phases
    ;;        (add-after 'unpack 'patch-timestamp-for-pyc-files
    ;;          (lambda (_)
    ;;            ;; We set DETERMINISTIC_BUILD to only override the mtime when
    ;;            ;; building with Guix, lest we break auto-compilation in
    ;;            ;; environments.
    ;;            (setenv "DETERMINISTIC_BUILD" "1")
    ;;            (substitute* "Lib/py_compile.py"
    ;;              (("source_stats\\['mtime'\\]")
    ;;               "(1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime'])"))

    ;;            ;; Use deterministic hashes for strings, bytes, and datetime
    ;;            ;; objects.
    ;;            (setenv "PYTHONHASHSEED" "0")

    ;;            ;; Reset mtime when validating bytecode header.
    ;;            (substitute* "Lib/importlib/_bootstrap_external.py"
    ;;              (("source_mtime = int\\(source_stats\\['mtime'\\]\\)")
    ;;               "source_mtime = 1"))
    ;;            #t))
    ;;        ;; These tests fail because of our change to the bytecode
    ;;        ;; validation.  They fail because expected exceptions do not get
    ;;        ;; thrown.  This seems to be no problem.
    ;;        (add-after 'unpack 'disable-broken-bytecode-tests
    ;;          (lambda
    ;;            (substitute* "Lib/test/test_importlib/source/test_file_loader.py"
    ;;              (("test_bad_marshal")
    ;;               "disable_test_bad_marshal")
    ;;              (("test_no_marshal")
    ;;               "disable_test_no_marshal")
    ;;              (("test_non_code_marshal")
    ;;               "disable_test_non_code_marshal"))
    ;;            #t))
    ;;        ;; Unset DETERMINISTIC_BUILD to allow for tests that check that
    ;;        ;; stale pyc files are rebuilt.
    ;;        (add-before 'check 'allow-non-deterministic-compilation
    ;;          (lambda _ (unsetenv "DETERMINISTIC_BUILD") #t))
    ;;        ;; We need to rebuild all pyc files for three different
    ;;        ;; optimization levels to replace all files that were not built
    ;;        ;; deterministically.

    ;;        ;; FIXME: Without this phase we have close to 2000 files that
    ;;        ;; differ across different builds of this package.  With this phase
    ;;        ;; there are about 500 files left that differ.
    ;;        (add-after 'install 'rebuild-bytecode
    ;;          (lambda* (#:key outputs #:allow-other-keys)
    ;;            (setenv "DETERMINISTIC_BUILD" "1")
    ;;            (let ((out (assoc-ref outputs "out")))
    ;;              (for-each
    ;;               (lambda (opt)
    ;;                 (format #t "Compiling with optimization level: ~a\n"
    ;;                         (if (null? opt) "none" (car opt)))
    ;;                 (for-each (lambda (file)
    ;;                             (apply invoke
    ;;                                    `(,(string-append out "/bin/python3")
    ;;                                      ,@opt
    ;;                                      "-m" "compileall"
    ;;                                      "-f" ; force rebuild
    ;;                                      ;; Don't build lib2to3, because it's Python 2 code.
    ;;                                      ;; Also don't build obviously broken test code.
    ;;                                      "-x" "(lib2to3|test/bad.*)"
    ;;                                      ,file)))
    ;;                           (find-files out "\\.py$")))
    ;;               (list '() '("-O") '("-OO"))))))))))

    ;; (native-search-paths
    ;;  (list (search-path-specification
    ;;         (variable "PYTHONPATH")
    ;;         (files (list (string-append "lib/python"
    ;;                                     (version-major+minor version)
    ;;                                     "/site-packages"))))))
))

mvdan.cc/sh

:: Invoking guix import (GNU Guix Reference Manual) :: GitHub: mvdan/sh :: sh · pkg.go.dev

echo -e "(use-modules (guix packages)
             (guix git-download)
             (guix build-system go)
             ((guix licenses) #:prefix license:))\n" >  /tmp/shfmt

guix import go -r  mvdan.cc/sh/v3  >>/tmp/shfmt


echo "'(" >> /tmp/shfmt
for line in $(grep define-public /tmp/shfmt | cut -d' ' -f2) ; do
    echo $line >> tmp/shfmt
done
echo ")" >> /tmp/shfmt

cat /tmp/shfmt
# guix package --install-from-file=/tmp/shfmt

(define-public go-github-com-creack-pty (package (name “go-github-com-creack-pty”) (version “1.1.15”) (source (origin (method git-fetch) (uri (git-reference (url “https://github.com/creack/pty”) (commit (string-append “v” version)))) (file-name (git-file-name name version)) (sha256 (base32 “1j5w51ammp5rp90bhdwqi216dxmndpmf4gf3gim75qls52qj8j2r”)))) (build-system go-build-system) (arguments ‘(#:import-path “github.com/creack/pty”)) (home-page “https://github.com/creack/pty”) (synopsis “pty”) (description “Package pty provides functions for working with Unix terminals. “) (license license:expat)))

(define-public go-mvdan-cc-editorconfig (package (name “go-mvdan-cc-editorconfig”) (version “0.2.0”) (source (origin (method git-fetch) (uri (git-reference (url “https://github.com/mvdan/editorconfig”) (commit (string-append “v” version)))) (file-name (git-file-name name version)) (sha256 (base32 “1rav1rp8pi921gsffqr2wjdhbr12w81g31yv6iw4yb1zyh726qqg”)))) (build-system go-build-system) (arguments ‘(#:import-path “mvdan.cc/editorconfig”)) (home-page “https://mvdan.cc/editorconfig”) (synopsis “editorconfig”) (description “Package editorconfig allows parsing and using EditorConfig files, as defined in @url{https://editorconfig.org/,https://editorconfig.org/}. “) (license license:bsd-3)))

(define-public go-mvdan-cc-sh-v3 (package (name “go-mvdan-cc-sh-v3”) (version “3.3.1”) (source (origin (method git-fetch) (uri (git-reference (url “https://github.com/mvdan/sh”) (commit (string-append “v” version)))) (file-name (git-file-name name version)) (sha256 (base32 “09kfy1xjns4mgm0f4iq92vpyfkapw0j8swnsadk1mmqj6khzlyz3”)))) (build-system go-build-system) (arguments ‘(#:import-path “mvdan.cc/sh/v3”)) (propagated-inputs `((“go-mvdan-cc-editorconfig” ,go-mvdan-cc-editorconfig) (“go-golang-org-x-term” ,go-golang-org-x-term) (“go-golang-org-x-sys” ,go-golang-org-x-sys) (“go-golang-org-x-sync” ,go-golang-org-x-sync) (“go-github-com-rogpeppe-go-internal” ,go-github-com-rogpeppe-go-internal) (“go-github-com-pkg-diff” ,go-github-com-pkg-diff) (“go-github-com-kr-text” ,go-github-com-kr-text) (“go-github-com-kr-pretty” ,go-github-com-kr-pretty) (“go-github-com-google-renameio” ,go-github-com-google-renameio) (“go-github-com-creack-pty” ,go-github-com-creack-pty))) (home-page “https://mvdan.cc/sh/v3”) (synopsis “sh”) (description “This package provides a shell parser, formatter, and interpreter. Supports @url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html,POSIX Shell}, @url{https://www.gnu.org/software/bash/,Bash}, and @url{http://www.mirbsd.org/mksh.htm,mksh}. Requires Go 1.15 or later.”) (license license:bsd-3)))

’( )

;; <2021-08-11 Wed 13:33> `guix import go mvdan.cc/sh'
(use-modules (guix packages)
             (guix git-download)
             (guix build-system go)
             (guix licenses))

(package
    (name "go-mvdan-cc-sh")
    (version "2.6.4")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "https://github.com/mvdan/sh")
               (commit (go-version->git-ref version))))
        (file-name (git-file-name name version))
        (sha256
          (base32
            "1jifac0fi0sz6wzdgvk6s9xwpkdng2hj63ldbaral8n2j9km17hh"))))
    (build-system go-build-system)
    (arguments '(#:import-path "mvdan.cc/sh"))
    (home-page "https://mvdan.cc/sh")
    (synopsis "sh")
    (description
      "This package provides a shell parser, formatter and interpreter.  Supports @url{http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html,POSIX Shell}, @url{https://www.gnu.org/software/bash/,Bash} and
@url{https://www.mirbsd.org/mksh.htm,mksh}.  Requires Go 1.10 or later.")
    (license bsd-3))

;;go-mvdan-cc-sh

dirty path; get github binary

CURRENT_VERSION=$(curl -Ls https://api.github.com/repos/Versent/saml2aws/releases/latest | grep 'tag_name' | cut -d'v' -f2 | cut -d'"' -f1)
wget -c https://github.com/Versent/saml2aws/releases/download/v${CURRENT_VERSION}/saml2aws_${CURRENT_VERSION}_linux_amd64.tar.gz -O - | tar -xzv -C ~/.local/bin
chmod u+x ~/.local/bin/saml2aws
hash -r
saml2aws --version

kubernetes

date
guix import go github.com/kubernetes/kubernetes

(package (name “go-github-com-kubernetes-kubernetes”) (version “1.22.1”) (source (origin (method git-fetch) (uri (git-reference (url “https://github.com/kubernetes/kubernetes”) (commit (string-append “v” version)))) (file-name (git-file-name name version)) (sha256 (base32 “07b1sg2s4zlpma8g062l29sm761q98cp6jfl8wsz990c2vw16l6a”)))) (build-system go-build-system) (arguments ‘(#:import-path “github.com/kubernetes/kubernetes”)) (propagated-inputs `((“go-sigs-k8s-io-yaml” ,go-sigs-k8s-io-yaml) (“go-sigs-k8s-io-structured-merge-diff-v4” ,go-sigs-k8s-io-structured-merge-diff-v4) (“go-k8s-io-utils” ,go-k8s-io-utils) (“go-k8s-io-system-validators” ,go-k8s-io-system-validators) (“go-k8s-io-kube-openapi” ,go-k8s-io-kube-openapi) (“go-k8s-io-klog-v2” ,go-k8s-io-klog-v2) (“go-k8s-io-gengo” ,go-k8s-io-gengo) (“go-gopkg-in-yaml-v2” ,go-gopkg-in-yaml-v2) (“go-gopkg-in-square-go-jose-v2” ,go-gopkg-in-square-go-jose-v2) (“go-gopkg-in-gcfg-v1” ,go-gopkg-in-gcfg-v1) (“go-google-golang-org-protobuf” ,go-google-golang-org-protobuf) (“go-google-golang-org-grpc” ,go-google-golang-org-grpc) (“go-google-golang-org-genproto” ,go-google-golang-org-genproto) (“go-google-golang-org-appengine” ,go-google-golang-org-appengine) (“go-google-golang-org-api” ,go-google-golang-org-api) (“go-gonum-org-v1-netlib” ,go-gonum-org-v1-netlib) (“go-gonum-org-v1-gonum” ,go-gonum-org-v1-gonum) (“go-golang-org-x-tools” ,go-golang-org-x-tools) (“go-golang-org-x-time” ,go-golang-org-x-time) (“go-golang-org-x-term” ,go-golang-org-x-term) (“go-golang-org-x-sys” ,go-golang-org-x-sys) (“go-golang-org-x-sync” ,go-golang-org-x-sync) (“go-golang-org-x-oauth2” ,go-golang-org-x-oauth2) (“go-golang-org-x-net” ,go-golang-org-x-net) (“go-golang-org-x-exp” ,go-golang-org-x-exp) (“go-golang-org-x-crypto” ,go-golang-org-x-crypto) (“go-go-opentelemetry-io-proto-otlp” ,go-go-opentelemetry-io-proto-otlp) (“go-go-opentelemetry-io-otel-trace” ,go-go-opentelemetry-io-otel-trace) (“go-go-opentelemetry-io-otel-sdk” ,go-go-opentelemetry-io-otel-sdk) (“go-go-etcd-io-etcd-client-v3” ,go-go-etcd-io-etcd-client-v3) (“go-go-etcd-io-etcd-client-pkg-v3” ,go-go-etcd-io-etcd-client-pkg-v3) (“go-github-com-vmware-govmomi” ,go-github-com-vmware-govmomi) (“go-github-com-vishvananda-netlink” ,go-github-com-vishvananda-netlink) (“go-github-com-stretchr-testify” ,go-github-com-stretchr-testify) (“go-github-com-storageos-go-api” ,go-github-com-storageos-go-api) (“go-github-com-spf13-pflag” ,go-github-com-spf13-pflag) (“go-github-com-spf13-cobra” ,go-github-com-spf13-cobra) (“go-github-com-robfig-cron-v3” ,go-github-com-robfig-cron-v3) (“go-github-com-quobyte-api” ,go-github-com-quobyte-api) (“go-github-com-prometheus-common” ,go-github-com-prometheus-common) (“go-github-com-prometheus-client-model” ,go-github-com-prometheus-client-model) (“go-github-com-prometheus-client-golang” ,go-github-com-prometheus-client-golang) (“go-github-com-pmezard-go-difflib” ,go-github-com-pmezard-go-difflib) (“go-github-com-pkg-errors” ,go-github-com-pkg-errors) (“go-github-com-opencontainers-selinux” ,go-github-com-opencontainers-selinux) (“go-github-com-opencontainers-runc” ,go-github-com-opencontainers-runc) (“go-github-com-opencontainers-go-digest” ,go-github-com-opencontainers-go-digest) (“go-github-com-onsi-gomega” ,go-github-com-onsi-gomega) (“go-github-com-onsi-ginkgo” ,go-github-com-onsi-ginkgo) (“go-github-com-mvdan-xurls” ,go-github-com-mvdan-xurls) (“go-github-com-munnerz-goautoneg” ,go-github-com-munnerz-goautoneg) (“go-github-com-mrunalp-fileutils” ,go-github-com-mrunalp-fileutils) (“go-github-com-mohae-deepcopy” ,go-github-com-mohae-deepcopy) (“go-github-com-moby-ipvs” ,go-github-com-moby-ipvs) (“go-github-com-lpabon-godbc” ,go-github-com-lpabon-godbc) (“go-github-com-lithammer-dedent” ,go-github-com-lithammer-dedent) (“go-github-com-libopenstorage-openstorage” ,go-github-com-libopenstorage-openstorage) (“go-github-com-json-iterator-go” ,go-github-com-json-iterator-go) (“go-github-com-ishidawataru-sctp” ,go-github-com-ishidawataru-sctp) (“go-github-com-heketi-tests” ,go-github-com-heketi-tests) (“go-github-com-heketi-heketi” ,go-github-com-heketi-heketi) (“go-github-com-googleapis-gnostic” ,go-github-com-googleapis-gnostic) (“go-github-com-google-uuid” ,go-github-com-google-uuid) (“go-github-com-google-gofuzz” ,go-github-com-google-gofuzz) (“go-github-com-google-go-cmp” ,go-github-com-google-go-cmp) (“go-github-com-google-cadvisor” ,go-github-com-google-cadvisor) (“go-github-com-golang-protobuf” ,go-github-com-golang-protobuf) (“go-github-com-golang-mock” ,go-github-com-golang-mock) (“go-github-com-golang-groupcache” ,go-github-com-golang-groupcache) (“go-github-com-gogo-protobuf” ,go-github-com-gogo-protobuf) (“go-github-com-godbus-dbus-v5” ,go-github-com-godbus-dbus-v5) (“go-github-com-go-ozzo-ozzo-validation” ,go-github-com-go-ozzo-ozzo-validation) (“go-github-com-fsnotify-fsnotify” ,go-github-com-fsnotify-fsnotify) (“go-github-com-evanphx-json-patch” ,go-github-com-evanphx-json-patch) (“go-github-com-emicklei-go-restful” ,go-github-com-emicklei-go-restful) (“go-github-com-elazarl-goproxy” ,go-github-com-elazarl-goproxy) (“go-github-com-docker-go-units” ,go-github-com-docker-go-units) (“go-github-com-docker-go-connections” ,go-github-com-docker-go-connections) (“go-github-com-docker-docker” ,go-github-com-docker-docker) (“go-github-com-docker-distribution” ,go-github-com-docker-distribution) (“go-github-com-davecgh-go-spew” ,go-github-com-davecgh-go-spew) (“go-github-com-cpuguy83-go-md2man-v2” ,go-github-com-cpuguy83-go-md2man-v2) (“go-github-com-coreos-go-systemd-v22” ,go-github-com-coreos-go-systemd-v22) (“go-github-com-coreos-go-oidc” ,go-github-com-coreos-go-oidc) (“go-github-com-coredns-corefile-migration” ,go-github-com-coredns-corefile-migration) (“go-github-com-containernetworking-cni” ,go-github-com-containernetworking-cni) (“go-github-com-container-storage-interface-spec” ,go-github-com-container-storage-interface-spec) (“go-github-com-clusterhq-flocker-go” ,go-github-com-clusterhq-flocker-go) (“go-github-com-boltdb-bolt” ,go-github-com-boltdb-bolt) (“go-github-com-blang-semver” ,go-github-com-blang-semver) (“go-github-com-aws-aws-sdk-go” ,go-github-com-aws-aws-sdk-go) (“go-github-com-auth0-go-jwt-middleware” ,go-github-com-auth0-go-jwt-middleware) (“go-github-com-armon-circbuf” ,go-github-com-armon-circbuf) (“go-github-com-puerkitobio-purell” ,go-github-com-puerkitobio-purell) (“go-github-com-microsoft-hcsshim” ,go-github-com-microsoft-hcsshim) (“go-github-com-microsoft-go-winio” ,go-github-com-microsoft-go-winio) (“go-github-com-jeffashton-win-pdh” ,go-github-com-jeffashton-win-pdh) (“go-github-com-googlecloudplatform-k8s-cloud-provider” ,go-github-com-googlecloudplatform-k8s-cloud-provider) (“go-github-com-azure-go-autorest-autorest-to” ,go-github-com-azure-go-autorest-autorest-to) (“go-github-com-azure-go-autorest-autorest-adal” ,go-github-com-azure-go-autorest-autorest-adal) (“go-github-com-azure-go-autorest-autorest” ,go-github-com-azure-go-autorest-autorest) (“go-github-com-azure-azure-sdk-for-go” ,go-github-com-azure-azure-sdk-for-go) (“go-bitbucket-org-bertimus9-systemstat” ,go-bitbucket-org-bertimus9-systemstat))) (home-page “https://github.com/kubernetes/kubernetes”) (synopsis “Kubernetes”) (description “Kubernetes is an open source system for managing @url{https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/,containerized applications} across multiple hosts; providing basic mechanisms for deployment, maintenance, and scaling of applications.”) (license license:asl2.0)))

kubectl

ew hacky binary

cd /tmp/ && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl ~/.local/bin/kubectl
kubectl version --client

python-pywal

imagemagick

recoll

:: Jean-Francois Dockes / recoll · GitLab

(qzdl systems)

explanation

with a simple separation of concerns, in attempts to eliminate redundancy:

  • base; minimum common denominators (vc, emacs, networking, vpn, ssh, …)
  • minimal; for a small board (pi, …) (base, specific things, …)
  • clean; for regular use (base, X11, web browser, …)

created using modules, as described:

debugging

excpecting struct in whatever

,use (gnu system)
,use (qzdl system minimal)
,use (ice-9 pprint)

(handler #t
         (pprint (operating-system-services minimal-operating-system)))

(qzdl system base)

:: .config/guix/qzdl/system/base.scm ::

./docs/base.scm.png

define
(define-module (qzdl system base)
  #:use-module (qzdl cosas)
  #:use-module (qzdl services)
  #:use-module (gnu)
  #:use-module (srfi srfi-1) ; scheme extensions per https://srfi.schemers.org/srfi-159/srfi-159.html
  #:use-module (gnu system nss) ;; network security service; appdev ssl,tls, etc
  #:use-module (gnu services docker)
  #:use-module (gnu services networking)
  #:use-module (gnu packages vim)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages package-management)
  #:use-module (nongnu packages linux)
  #:use-module (nongnu system linux-initrd)
  #:export (base-operating-system))
test
test-load-file .config/guix/qzdl/system/base.scm
package modules
(use-package-modules certs)
(use-package-modules shells)
operating-system

:: operating-system Reference (GNU Guix Reference Manual) :: Using the Configuration System (GNU Guix Reference Manual)

timezone[fn:1], locale[fn:2], default hostname etc

initrd[fn:3] ‘inital ram disk’; for the bootloader to invoke ram :: Initial RAM Disk (GNU Guix Reference Manual)

  • the kernel loads ‘compiled-in’ drivers
  • temporary filesystem
  • init script
    • to load ‘additional modules’ (for the kernel)
      • operating-system -> initrd-modules in guix

based on our initrd config, we can even ‘boot-to-Guile’ with the --repl flag, to land in a repl in the initial ram disk. wild. [fn:5]

we are instructing initrd to populate with proprietary microcode[fn:4] (“ucode”) for processors.

I’m not happy about this blob usage AT ALL, but it’s the cost of using non-free hardware. exercise limited trust in these machines.

if running on a removable drive, it may be worth adding both amd and intel ucode images to the bootloader config in initrd.

:: Keyboard Layout (GNU Guix Reference Manual)

  • ‘model’ comes from share/X11/xkb of package xkeyboard-config
(define base-operating-system
  (operating-system
   (host-name "unconf")
   (timezone "Europe/Berlin")
   (locale "en_US.UTF-8")

   ;; nonfree kernel :(
   (kernel linux)
   (firmware (list linux-firmware))
   (initrd microcode-initrd)

   ;; disable ipv6 for safe vpn usage; we just aren't there yet :/
   (kernel-arguments '("quiet" "ipv6.disable=1" "net.ifnames=0"))

   ;; kernel layout, not necessarily X layout
   (keyboard-layout my-keyboard-layout)

   ;; UEFI+GRUB
   (bootloader
    (bootloader-configuration
     (bootloader grub-efi-bootloader)
     (targets '("/boot/efi"))
     (keyboard-layout keyboard-layout)))

   (users
    (cons (user-account
           (name "samuel")
           (comment "it me")
           (group "users")
           (home-directory "/home/samuel/")
           (supplementary-groups '("wheel"     ;; sudo
                                   "netdev"    ;; network devices
                                   "kvm"       ;; virtualisation
                                   "tty"
                                   "input"
                                   "lp"        ;; control bluetooth devices
                                   "audio"     ;; control audio devices
                                   "video"     ;; control video devices
                                   "docker")))
          %base-user-accounts))

   (groups
    (cons (user-group (name "docker"))
          %base-groups))

   ;; OVERWRITE THIS WHEN INHERITING
   ;;   AN ARTIFACT OF INCIDENTAL COMPLEXITY IN GUIX
   (file-systems (cons*
                  (file-system
                   (mount-point "/")
                   (device "none")
                   (type "tmpfs")
                   (check? #f))
                  %base-file-systems))

   (services
    (cons* my-docker-service
           my-udev-service
           (extra-special-file
            "/usr/bin/env"
            (file-append coreutils "/bin/env"))
           %base-services))

   (packages
    (cons* git
           stow
           emacs
           vim
           nss-certs
           %base-packages))))
inspect %base-* stuff and chuck out

(qzdl system tiny)

:: .config/guix/qzdl/system/tiny.scm ::

./docs/tiny.scm.png

consumes guix base system

(qzdl system minimal)

:: .config/guix/qzdl/system/minimal.scm ::

./docs/minimal.scm.png

things for ‘full systems’ -> consumes guix base system

test
test-load-file .config/guix/qzdl/system/minimal.scm
define
(define-module (qzdl system minimal)
  #:use-module (qzdl system base)
  #:use-module (qzdl services)
  #:use-module (gnu)
  #:use-module (gnu system)
  #:use-module (srfi srfi-1)
  #:use-module (gnu packages gnuzilla)       ;; GNU mozilla suite
  #:use-module (gnu packages audio)          ;;
  #:use-module (gnu packages emacs)          ;;
  #:use-module (gnu packages emacs-xyz)
  #:use-module (gnu packages pulseaudio)     ;; audio daemon
  #:use-module (gnu packages wm)             ;; lots of wm options (blote)
  #:use-module (gnu packages linux)          ;; for bluez
  #:use-module (gnu packages xorg)           ;; xf86-input-libinput
  #:export (%minimal-services
            minimal-operating-system))
minimal-services
(use-service-modules desktop xorg)

(define %minimal-services
  (append
   (list my-libvirt-service
         my-bluetooth-service
         my-postgresql-service
         my-postgresql-role-service)
   %my-desktop-services))
operating-system
(define minimal-operating-system
  (operating-system
   (inherit base-operating-system)

   (services
    (append %minimal-services
            (operating-system-user-services base-operating-system)))

   ;; suggested operating-system-user-services
   ;; https://issues.guix.gnu.org/37083
   (packages
    (cons* pulseaudio
           bluez
           bluez-alsa
           tlp                  ;; laptop power management
           xf86-input-libinput

           xmonad emacs emacs-exwm emacs-desktop-environment

           (operating-system-packages base-operating-system)))))
debug
systems
;;.config/guix/qzdl/system/minimal.scm
(use-modules (ice-9 pretty-print))
(pretty-print
  (map (lambda (s) (service-kind s))
       (operating-system-services minimal-operating-system)))

(qzdl system install)

:: .config/guix/qzdl/system/install.scm :: https://gitlab.com/nonguix/nonguix/blob/master/nongnu/system/install.scm :: ./docs/install.scm.png

;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
;;;
;;; This program is free software: you can redistribute it and/or modify

;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;; Generate a bootable image (e.g. for USB sticks, etc.) with:
;; <exec-shell-cmd "guix system disk-image nongnu/system/install.scm">

(define-module (nongnu system install)
  #:use-module (gnu system)
  #:use-module (gnu system install)
  #:use-module (nongnu packages linux)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages vim)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages package-management)
  #:export (installation-os-nonfree))

(define installation-os-nonfree
  (operating-system
    (inherit installation-os)
    (kernel linux)
    (firmware (list linux-firmware))
    (kernel-arguments '("net.ifnames=0"))

    (packages (append (list git curl stow vim emacs-no-x-toolkit)
                      ;; (operating-system-packages base-operating-system)
                      (operating-system-packages installation-os)))))

installation-os-nonfree

(qzdl devices)

(qzdl devices xps)

:: .config/guix/qzdl/device/xps.scm :: ./docs/xps.scm.png

consuming guix minimal system

test

test-load-file .config/guix/qzdl/device/xps.scm

define

(define-module (qzdl device xps))

(qzdl devices cleanpi)

:: .config/guix/qzdl/device/cleanpi.scm :: ./docs/cleanpi.scm.png

test

test-load-file .config/guix/qzdl/device/cleanpi.scm

define

(define-module (qzdl device cleanpi))

(qzdl devices donutrust)

:: .config/guix/qzdl/device/donutrust.scm ::

./docs/donutrust.scm.png

my thinkpad x1 carbon; a work machine. consumes guix minimal system

test

test-load-file .config/guix/qzdl/device/donutrust.scm

define

(define-module (qzdl device donutrust)
  #:use-module (srfi srfi-1)
  #:use-module (gnu)
  #:use-module (gnu services databases)
  #:use-module (nongnu packages linux)
  #:use-module (qzdl services)
  #:use-module (qzdl system minimal)
  #:export (%donutrust-services
            donutrust-operating-system))

services

postgres-role-service

extend my-postgresql-role-service with another role

(define pg-role-service
  (simple-service
   'adhoc-extension postgresql-role-service-type
   (list (postgresql-role
          (name "newstore")
          (create-database? #t)))))
donutrust-services
(define %donutrust-services
  (list pg-role-service))

operating system

(define donutrust-operating-system
  (operating-system
    (inherit minimal-operating-system)

    (host-name "donutrust")

    (firmware
     (list linux-firmware sof-firmware))

    (services
      (append %donutrust-services
              %minimal-services
              %base-services))

    (mapped-devices
     (list (mapped-device
            (source (uuid "c9042f21-04bd-48ff-9295-5e314f1d4b37"))
            (target "sys-root")
            (type luks-device-mapping))))

    (file-systems
     (cons* (file-system
              (device (file-system-label "sys-root"))
              (mount-point "/")
              (type "ext4")
              (dependencies mapped-devices))
            (file-system
              (device "/dev/nvme0n1p1")
              (mount-point "/boot/efi")
              (type "vfat"))
            %base-file-systems))))

donutrust-operating-system
problems abounding with understanding serviceextension

struggling to grok extension for postgresql-role-service to add a role -> does anything obvious jump out at you here?

sudo -E reconfigure op.scm

previous broken version
....
    (services
     (cons* (service postgresql-service-type)      ;; where these actually come from
            (service postgresql-role-service-type) ;; the inherited OS
            (simple-service 'adhoc-extension postgresql-role-service-type
                            (list (service-extension
                                   postgresql-role-service-type
                                   (const (postgresql-role
                                           (name "alice")
                                           (create-database? #t))))))
            %desktop-services))
....


previous broken error
....
Backtrace:
In srfi/srfi-1.scm:
   586:29 19 (map1 (#<<service> type: #<service-type agetty 7f5ce…> …))
   586:29 18 (map1 (#<<service> type: #<service-type console-font…> …))
   586:29 17 (map1 (#<<service> type: #<service-type virtual-term…> …))
   586:29 16 (map1 (#<<service> type: #<service-type ntp 7f5ced4a…> …))
   586:29 15 (map1 (#<<service> type: #<service-type dbus 7f5ced9…> …))
   586:29 14 (map1 (#<<service> type: #<service-type elogind 7f5c…> …))
   586:29 13 (map1 (#<<service> type: #<service-type upower 7f5ce…> …))
   586:29 12 (map1 (#<<service> type: #<service-type avahi 7f5cee…> …))
   586:29 11 (map1 (#<<service> type: #<service-type wpa-supplica…> …))
   586:29 10 (map1 (#<<service> type: #<service-type network-mana…> …))
   586:17  9 (map1 (#<<service> type: #<service-type postgresql-r…> …))
In gnu/services/databases.scm:
   420:30  8 (postgresql-role-shepherd-service #<<postgresql-role-co…>)
   387:11  7 (postgresql-create-roles _)
In srfi/srfi-1.scm:
   673:15  6 (append-map #<procedure 7f5ceae91180 at gnu/services/d…> …)
   586:29  5 (map1 (#<<postgresql-role> name: "postgres" permissi…> …))
   586:29  4 (map1 (#<<postgresql-role> name: "samuel" permission…> …))
   586:17  3 (map1 (#<<service-extension> target: #<service-type po…>))
In gnu/services/databases.scm:
   389:14  2 (_ #<<service-extension> target: #<service-type postgre…>)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `wrong-type-arg' with args `(#<<service-extension> target: #<service-type postgresql-role 7f5cee470d40> compute: #<procedure 7f5cf9e56640 at ice-9/boot-9.scm:809:2 _>>)'.
....


working version
....
  (services
     (cons* (service postgresql-service-type)        ;; where these would actually
            (service postgresql-role-service-type)   ;; come from the inherited OS
            (simple-service 'adhoc-extension postgresql-role-service-type
                            (list (postgresql-role   ;; implicitly making an extension,
                                   (name "alice")    ;; so just specify the values required
                                   (create-database? #t))))
            %my-desktop-services))
....



I’m setting up an operating-system, which inherits from another with a service of type postgresql-role-service-type, but I cannot grok the service-extension nor simple-service extension pattern for this service, to basically just cons a new role to the existing config.

specifically, failure when build or reconfigure

  • [Y] postgresql-service-type
  • [Y] postgresql-role-service-type

-

...
(services
   ())
;; => In procedure service-kind: Wrong type argument: #<<service-extension> target: #<service-type postgresql-role
debugging
asking the question “how can i access properties of record ‘config’?”
(use-modules (guix)
             (gnu)
             (gnu services)
             (gnu services databases)
             (qzdl services)
             (ice-9 pretty-print))

(simple-service
 'adhoc-extension postgresql-role-service-type
 (list (service-extension
        postgresql-role-service-type
        (const (postgresql-role
                (name "alice")
                (create-database? #t)))))

(record? (service-kind my-postgresql-role-service))             ;; #t
(record? my-postgresql-role-service)                            ;; #t
(record-type? my-postgresql-service)                            ;; #f
(record-type? (service-kind my-postgresql-service))             ;; #f
(record-type-descriptor my-postgresql-role-service)             ;; #<record-type <service>>
(record-type-descriptor (service-kind my-postgresql-service))   ;; #<record-type <service-type>>

(pretty-print
 (map (lambda (r)
        (let ((rt (record-type-descriptor r)))
          `(:record ,r
            :record-type-descriptor ,rt
            :record-type-uid         ,(record-type-uid         rt)
            :record-type-constructor ,(record-type-constructor rt)
            :record-type-parents     ,(record-type-parents     rt)
            :record-type-properties  ,(record-type-properties  rt)
            :record-type-name        ,(record-type-name        rt)
            :record-type-parent      ,(record-type-parent      rt)
            :record-type-fields      ,(record-type-fields      rt)
            :record-type-extensible? ,(record-type-extensible? rt)
            :record-predicate        ,(record-predicate        rt)
            :record-type-opaque?     ,(record-type-opaque?     rt))))
      `(,my-postgresql-role-service
        ,(service-kind my-postgresql-service))))

;;; checking
;;(record-type-vtable )
;;record-type-descriptor (obj)
;;record?	#<procedure record? (obj)>
;;record-type?	#<procedure record-type? (obj)>

;;; requiring additional props
;;record-modifier	#<procedure record-modifier (rtd field-name-or-idx)>
;;record-accessor (field-name-or-index)
;;record-type-has-parent? (parent)

;;; unsure
;;record-constructor	#<procedure record-constructor (rtd) | (rtd field-names)>
;;record-type-mutable-fields	#<procedure record-type-mutable-fields (rtd)>
interrogate services
;; .config/guix/qzdl/device/donutrust.scm
(use-modules (ice-9 pretty-print))
(pretty-print
  (map (lambda (s) (service-kind s))
       (operating-system-services donutrust-operating-system)))

(pretty-print (length (operating-system-services donutrust-operating-system)))
(pretty-print (length (delete-duplicates (operating-system-services donutrust-operating-system))))

shell

:: .config/shell

test

headline "TESTING SHELL CONFIGS"
delim

block "BEGIN: linting"
echo "...TODO lint shell files @shfmt"
block "END: linting"
delim

block "BEGIN: sourcing"
tmpbase="$HOME/.config/shell"
for f in $(find "$tmpbase/") ; do
    [ -d $f ] && continue;
    echo "...sourcing $f"

    if $(source "$f"); then
        qz_color $qz_greener ".....PASSED: $f"
    else qz_color $qz_red ".....FAILED: $f"
    fi;
done;

block "END: sourcing"

aliases

#!/bin/bash
# system commands
alias \
  ls='ls -p --color=auto' \
  ll='ls -lah' \
  grep='grep --color=auto' \

alias \
  yt="youtube-dl --add-metadata -i -o '%(upload_date)s-%(title)s.%(ext)s'" \
  yta="yt -x -f bestaudio/best" \
  g='guix' \
  gp='echo $GUIX_PROFILE' \
  gg='git' \
  h='sudo herd' \
  xo='xdg-open'

# re-source
alias \
  rrb='source ~/.bashrc' \
  rrp='source $HOME/.config/shell/profile' \
  rra='source $HOME/.config/shell/aliases'

# easy check files
alias \
  aa='qz_get_aliases' \
  af='qz_get_functions'

# my functions
alias \
  gV='qz_guix_vm' \
  gR='qz_guix_reconfigure' \
  gRd='qz_guix_reconfigure_debug' \
  gse='qz_guix_source_extra_profile'
  gsp='qz_guix_source_profile'
  dlsh='qz_download_scihub_doi'

functions

#!/bin/bash
qz_color() {
    echo -e "$1$2${qz_reset}"
}

qz_number_lines() {
    awk '{print NR" "$0}';
}

qz_reverse() {
    qz_number_lines | sort -k1 -n -r | sed 's/^[^ ]* //g';
}

# guix reconfigure, and debug to the repl
qz_guix_reconfigure_debug()  {
    sudo -E guix repl -L "$HOME/.config/guix" $@;
}

qz_guix_reconfigure()  {
    sudo -E guix system \
        -L "$HOME/.config/guix" \
        reconfigure "$HOME/.config/guix/qzdl/device/$(hostname).scm" $@;
}

qz_guix_vm()  {
    sudo -E guix system \
        -L "$HOME/.config/guix" \
        vm "$HOME/.config/guix/qzdl/device/$(hostname).scm" $@;
}

# guix profile commands; make it easy to switch and check
qz_guix_source_extra_profile() {
    qz_guix_source_profile "$GUIX_EXTRA_PROFILES/$@";
}

qz_guix_source_profile() {
    export GUIX_PROFILE="$@"
    . "$GUIX_PROFILE/etc/profile";
}

qz_download_scihub_doi() {
    curl -O \
        $(curl -s http://sci-hub.tw/"$@" \
          | grep location.href \
          | grep -o http.*pdf);
}

qz_get_functions() {
  FILE="$QZ_FUNCTIONS"
  cat $FILE \
    | grep -on '^qz_.*()' \
    | awk -F: '{print file":"$1,$2}' file=$FILE
}

qz_get_aliases() {
  FILE="$QZ_ALIASES"
  cat $FILE \
    | grep -on "\s.*='.*'" \
    | awk -F: '{print file":"$1,$2}' file=$FILE
}

.bashrc

exports

export ‘SHELL’ to child processes

‘screen’ will honor it and otherwise use /bin/sh

export SHELL

sources

references to other files

include env vars in ssh sessions
if [[ $- != *i* ]]
then
    # We are being invoked from a non-interactive shell.  If this
    # is an SSH session (as in "ssh host command"), source
    # /etc/profile so we get PATH and other essential variables.
    [[ -n "$SSH_CLIENT" ]] && source /etc/profile

    # Don't do anything else.
    return
fi
reference other files
# Source the system-wide file.

. /etc/bashrc
. $QZ_ALIASES
. $HOME/ns.sh # pyenv

vterm

:: GitHub - akermu/emacs-libvterm: Emacs libvterm integration a terminal in emacs

filter input for vterm compatibility
# emacs-vterm display helper
vterm_printf(){
    if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then
        # Tell tmux to pass the escape sequences through
        printf "\ePtmux;\e\e]%s\007\e\\" "$1"
    elif [ "${TERM%%-*}" = "screen" ]; then
        # GNU screen (screen, screen-256color, screen-256color-bce)
        printf "\eP\e]%s\007\e\\" "$1"
    else
        printf "\e]%s\e\\" "$1"
    fi
}
clear scrollback

:: https://github.com/akermu/emacs-libvterm#vterm-clear-scrollback

# emacs-vterm: clear scrollback
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
    function clear(){
        vterm_printf "51;Evterm-clear-scrollback";
        tput clear;
    }
fi

colouring

:: ANSI escape code - Wikipedia

PS1

:: ┣ - box drawings heavy vertical and right (u+2523)

pretty funny rice tbh

[18:41] [samuel : donutrust] [/home/samuel/dotfiles]↝
∴
# VTERM PS1
vterm_prompt_end(){
    vterm_printf "51;A$(whoami)@$(hostname):$(pwd)"
}
# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n "$GUIX_ENVIRONMENT" ]
then
    GUIX_ENV_PS1='[env]'
else
    GUIX_ENV_PS1=''
fi

therefore="$(echo -e '\U2234')"
arrow="$(echo -e '\U219D')"
hammer="🔨"
money="💰"
spades="🂡"
king=""
dice="🎲"
end=$money
break=""


    PS1="\n┏━❨\A❩━❨\u@\h❩$break"
PS1="$PS1\n┣━❨\w❩$break"
PS1="$PS1\n┗━$GUIX_ENV_PS1$end "

PS1=$PS1'\[$(vterm_prompt_end)\]'

$HOME/.local/bin/unix

****

ascii

clippy
echo "
░░░░░░▄████▄
░░░░░▐▌░░░░▐▌
░░▄▀▀█▀░░░░▐▌
░░▄░▐▄░░░░░▐▌▀▀▄
▐▀░▄▄░▀▌░▄▀▀░▀▄░▀
▐░▀██▀░▌▐░▄██▄░▌
░▀▄░▄▄▀░▐░░▀▀░░▌
░░░░█░░░░▀▄▄░▄▀
░░░░█░█░░░░█░▐
░░░░█░█░░░▐▌░█
░░░░█░█░░░▐▌░█
░░░░▐▌▐▌░░░█░█
░░░░▐▌░█▄░▐▌░█
░░░░░█░░▀▀▀░░▐▌
░░░░░▐▌░░░░░░█
░░░░░░█▄░░░░▄█
░░░░░░░▀████▀"

.profile

#!/bin/bash
source $HOME/.config/shell/variables

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

for f in functions aliases variables ; do
    . "$CONFIG_DIR_SHELL/$f";
done;

. $GUIX_PROFILE/etc/profile

export $(cat $HOME/.config/shell/variables | grep -v "^#" | cut -d= -f1)
export $(cat $HOME/.config/shell/aliases | grep  -v "#" | grep -v 'alias' | cut -d'=' -f1)
export -f $(cat $HOME/.config/shell/functions | grep  -i "^[a-z]\(\)" | cut -d'(' -f1)
export alias rrp="source $HOME/.profile"

symlink profiles

see .local/bin/dotfiles-nonstow.sh

scripts

screenshot

#!/bin/sh
# creds to baldy luke smith

DIR_SCREENSHOTS="${HOME}/screenshots"

sname="${DIR_SCREENSHOTS}"/pic-selected-"$(date '+%y%m%d-%H%M-%S').png"

(
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\na selected area (copy-path)" | dmenu -l 6 -i -p "Screenshot which area?")" in
    "a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
    "current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
    "full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;
    "a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
    "current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
    "full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
    "a selected area (copy-path)") maim -s $sname && echo $sname | xclip -selection clipboard -t text ;;
esac
) && echo $sname

screenrecord

:: check ~/dotfiles/scripts/.scripts/i3cmds/dmenurecord

gif

recoll index on ac

depends on ‘on_ac_power’

  • defaults to RUN
#!/bin/sh
# This is a shell script that starts and stops the recollindex daemon
# depending on whether or not the power supply is plugged in.  It should be
# called from the file ~/.config/autostart/recollindex.desktop.
#
# That is: make the script executable (chmod +x) and replace in
# recollindex.desk the line:
#   Exec=recollindex -w 60 -m
# With
#   Exec=/path/to/recoll_index_on_ac.sh
#
#
# By: The Doctor (drwho at virtadpt dot net)
# License: GPLv3
#
# Modifications by J.F Dockes
#  - replaced "acpi" usage with "on_ac_power" which seems to be both
#    more common and more universal.
#  - Changed the default to be that we run recollindex if we can't determine
#    power status (ie: on_ac_power not installed or not working: we're most
#    probably not running on a laptop).

INDEXER="recollindex -w 60 -m"
ACPI=`which on_ac_power`

# If the on_ac_power script isn't installed, warn, but run anyway. Maybe
# this is not a laptop or not linux.
if test "x$ACPI" = "x" ; then
    echo "on_ac_power utility not found. Starting recollindex anyway."
fi

while true; do
    # Determine whether or not the power supply is plugged in.
    if test "x$ACPI" != "x" ; then
        on_ac_power
        STATUS=$?
    else
        STATUS=0
    fi

    # Get the PID of the indexing daemon.
    if test -f ~/.recoll/index.pid ; then
       PID=`cat ~/.recoll/index.pid`
       # Make sure that this is recollindex running. pid could have
       # been reallocated
       ps ax | egrep "^[ \t]*$PID " | grep -q recollindex || PID=""
    fi
#    echo "Recollindex pid is $PID"

    if test $STATUS -eq 1 ; then
	# The power supply is not plugged in.  See if the indexing daemon is
	# running, and if it is, kill it.  The indexing daemon will not be
	# started.
        if test x"$PID" != x; then
	    kill $PID
	fi
    else
	# The power supply is plugged in or we just don't know.
        # See if the indexing daemon is running, and if it's not start it.
        if test -z "$PID" ; then
	    $INDEXER
	fi
    fi

    # Go to sleep for a while.
    sleep 120
    continue
done

autocommit

#!/bin/bash

# A small script for committing and pushing a git repository
#
# for ~/.local/bin/
# <exec-shell-cmd "chmod +x ~/dotfiles/cron/.local/bin/auto-commit">

#                      ██                                                           ██   ██
#                     ░██                                                          ░░   ░██
#   ██████   ██   ██ ██████  ██████         █████   ██████  ██████████  ██████████  ██ ██████
#  ░░░░░░██ ░██  ░██░░░██░  ██░░░░██ █████ ██░░░██ ██░░░░██░░██░░██░░██░░██░░██░░██░██░░░██░
#   ███████ ░██  ░██  ░██  ░██   ░██░░░░░ ░██  ░░ ░██   ░██ ░██ ░██ ░██ ░██ ░██ ░██░██  ░██
#  ██░░░░██ ░██  ░██  ░██  ░██   ░██      ░██   ██░██   ░██ ░██ ░██ ░██ ░██ ░██ ░██░██  ░██
# ░░████████░░██████  ░░██ ░░██████       ░░█████ ░░██████  ███ ░██ ░██ ███ ░██ ░██░██  ░░██
#  ░░░░░░░░  ░░░░░░    ░░   ░░░░░░         ░░░░░   ░░░░░░  ░░░  ░░  ░░ ░░░  ░░  ░░ ░░    ░░

git add .
git commit -m "auto-commit | $(date -u)"
git push && notify-send "Successfully pushed $PWD"

work

see Commands @ NewStore to tangle to .local/bin

dotfiles

psql

--                              ██
--     ██████           ████   ░██
--    ░██░░░██  ██████ ██░░██  ░██ ██████  █████
--    ░██  ░██ ██░░░░ ░██ ░██  ░██░░██░░█ ██░░░██
--    ░██████ ░░█████ ░░█████  ░██ ░██ ░ ░██  ░░
--  ██░██░░░   ░░░░░██ ░░░░██  ░██ ░██   ░██   ██
-- ░██░██      ██████     ░███ ███░███   ░░█████
-- ░░ ░░      ░░░░░░      ░░░ ░░░ ░░░     ░░░░░
--
-- <exec-shell-cmd "cd ~/dotfiles && stow psql">

-- signifier for null values
\pset null '(null)'

-- nice glyphs
\pset linestyle unicode

-- upcase completion
\set COMP_KEYWORD_CASE upper

-- just fail by default see <link-to-elisp-doc 'qzdl/psql-toggle-error-rollback>
\set ON_ERROR_ROLLBACK off

sbcl

;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

wget

wgetrc

:: .config/wget/wgetrc

hsts-file=~/.cache/wget-hsts

guile

:: .config/guile

.guile

(cond ((false-if-exception (resolve-interface '(ice-9 readline)))
       =>
       (lambda (module)
         ;; Enable completion and input history at the REPL.
         ((module-ref module 'activate-readline))))
      (else
       (display "Consider installing the 'guile-readline' package for
convenient interactive line editing and input history.\n\n")))

      (unless (getenv "INSIDE_EMACS")
        (cond ((false-if-exception (resolve-interface '(ice-9 colorized)))
               =>
               (lambda (module)
                 ;; Enable completion and input history at the REPL.
                 ((module-ref module 'activate-colorized))))
              (else
               (display "Consider installing the 'guile-colorized' package
for a colorful Guile experience.\n\n"))))

;;; GNU Guix
;(use-modules (guix) (guix hash) (guix build-system))
;; add my custom src dir to loadpath
(add-to-load-path "/home/samuel/.config/guix")

.xsession

#!/bin/sh

# Source .profile for common environment vars
. ~/.profile

# Disable access control for the current user
xhost +SI:localuser:$USER

# Make Java applications aware this is a non-reparenting window manager
export _JAVA_AWT_WM_NONREPARENTING=1

# Start Shepherd to manage user daemons
if [ -z "$(pgrep -u sm shepherd)" ]; then
  shepherd
fi

# Run xsettingsd to progagate font and theme settings
xsettingsd &

# Enable screen compositing
compton &

# Turn off the system bell
xset -b

# Enable screen locking on suspend
xss-lock -- slock &

# Uncomment this to start xterm instead for debugging purposes!
# Then you can manually run the window manager and log output
# > exec dbus-launch emacs -mm --debug-init --use-exwm 2>&1 | tee ~/debug.log
#xterm

# Fire it up
exec dbus-launch --exit-with-session emacs -mm --debug-init --use-exwm

stow

.stowrc

--target /home/samuel/

.stow-ignore

docs/
README.*
.stow-global-ignore

# .gitsubmodules & others
\.git.*

# emacs org files
.*\.org

*.desktop

:: .local/share/applications

org-protocol

[Desktop Entry]
Name=Org-Protocol
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol

recollindex

[Desktop Entry]
Name=Recoll real time indexer
Comment=Runs in background to extract and index text from modified documents
Icon=system-run
Exec=recoll-index-on-ac.sh
Terminal=false
TerminalOptions=
Type=Application
Categories=Utility;Filesystem;Database;
NoDisplay=true
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
X-KDE-UniqueApplet=true

mimeapps


emacs

.eshellrc

alias sudo "eshell/sudo $*"

;; VC
alias vc "vc-dir ." "Get some version control information for ./"
alias g git

GUIX_PROFILE="/home/samuel/.guix-profile"
. "$GUIX_PROFILE/etc/profile"

emacs config as-a-package

basically, to be able to update my emacs config with guix pull

python runtime in docker

docker run -it -v /tmp:/tmp -v $HOME/git ufoym/deepo python3

eva

(package! eva
  :recipe (:host github :repo "meedstrom/eva"
           :files (:defaults "assets"  "renv" "*.R" "*.gnuplot")))

guix

r
gnuplot
xprint

emacs

recommends “Selectrum” Infopage for (eva) Soft requirements

xprintidle

:: https://github.com/g0hl1n/xprintidle :: Build Systems - Meson (GNU Guix Reference Manual)

upstream

makes me think about how the shared proceeds of selfish interests are utility.

says nothing about how it’s maintained in the future

Index

Footnotes

[fn:5] Using Guile Interactively (Guile Reference Manual) [fn:4] Microcode - ArchWiki

[fn:3] Using the initial RAM disk (initrd) — The Linux Kernel documentation [fn:2] How to Change or Set System Locales in Linux

  • get: localectl
  • set: sudo localectl set-blocale LANG=en_US.UTF_8

[fn:1] check the existing timezone with the following (How to Check Timezone in Linux)

  timedatectl | grep -i "time zone"
p#+end_src

#+RESULTS: