Define FreeBSD Fruix operating-system model

This commit is contained in:
2026-04-01 18:29:15 +02:00
parent 6e01eb9fc8
commit 13963e7f62
7 changed files with 1159 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
(use-modules (fruix system freebsd)
(fruix packages freebsd))
(define phase7-operating-system
(operating-system
#:host-name "fruix-freebsd"
#:kernel freebsd-kernel
#:bootloader freebsd-bootloader
#:base-packages (list freebsd-runtime
freebsd-userland
freebsd-libc
freebsd-rc-scripts
freebsd-bash)
#:groups (list (user-group #:name "wheel" #:gid 0 #:system? #t)
(user-group #:name "operator" #:gid 1000 #:system? #f))
#:users (list (user-account #:name "root"
#:uid 0
#:group "wheel"
#:comment "Charlie &"
#:home "/root"
#:shell "/bin/sh"
#:system? #t)
(user-account #:name "operator"
#:uid 1000
#:group "operator"
#:supplementary-groups '("wheel")
#:comment "Fruix Operator"
#:home "/home/operator"
#:shell "/bin/sh"
#:system? #f))
#:file-systems (list (file-system #:device "/dev/ufs/fruix-root"
#:mount-point "/"
#:type "ufs"
#:options "rw"
#:needed-for-boot? #t)
(file-system #:device "devfs"
#:mount-point "/dev"
#:type "devfs"
#:options "rw"
#:needed-for-boot? #t)
(file-system #:device "tmpfs"
#:mount-point "/tmp"
#:type "tmpfs"
#:options "rw,size=64m"))
#:services '(shepherd ready-marker)
#:loader-entries '(("autoboot_delay" . "1")
("console" . "comconsole"))
#:rc-conf-entries '(("clear_tmp_enable" . "YES")
("sendmail_enable" . "NONE")
("sshd_enable" . "NO"))
#:ready-marker "/var/lib/fruix/ready"))

View File

@@ -0,0 +1,69 @@
#!/bin/sh
set -eu
project_root=${PROJECT_ROOT:-$(pwd)}
guix_source_dir=${GUIX_SOURCE_DIR:-"$HOME/repos/guix"}
script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
runner_scm=$script_dir/validate-phase7-operating-system.scm
os_file=$script_dir/phase7-minimal-operating-system.scm
if [ -n "${GUILE_BIN:-}" ]; then
guile_bin=$GUILE_BIN
elif [ -x /tmp/guile-freebsd-validate-install/bin/guile ]; then
guile_bin=/tmp/guile-freebsd-validate-install/bin/guile
else
cat >&2 <<'EOF'
A fixed local Guile build is required for this harness.
Set GUILE_BIN to a locally built fixed Guile, for example:
GUILE_BIN=/tmp/guile-freebsd-validate-install/bin/guile
EOF
exit 1
fi
if [ ! -x "$guile_bin" ]; then
echo "Guile binary is not executable: $guile_bin" >&2
exit 1
fi
guile_prefix=$(CDPATH= cd -- "$(dirname "$guile_bin")/.." && pwd)
guile_lib_dir=$guile_prefix/lib
if [ -e "$guile_lib_dir/libguile-3.0.so.1" ]; then
if [ -n "${LD_LIBRARY_PATH:-}" ]; then
export LD_LIBRARY_PATH="$guile_lib_dir:$LD_LIBRARY_PATH"
else
export LD_LIBRARY_PATH="$guile_lib_dir"
fi
fi
cleanup=0
if [ -n "${WORKDIR:-}" ]; then
workdir=$WORKDIR
mkdir -p "$workdir"
else
workdir=$(mktemp -d /tmp/fruix-phase7-os-model.XXXXXX)
cleanup=1
fi
if [ "${KEEP_WORKDIR:-0}" -eq 1 ]; then
cleanup=0
fi
cleanup_workdir() {
if [ "$cleanup" -eq 1 ]; then
rm -rf "$workdir"
fi
}
trap cleanup_workdir EXIT INT TERM
export GUILE_AUTO_COMPILE=0
export WORKDIR="$workdir"
export OS_FILE="$os_file"
if [ -n "${GUILE_LOAD_PATH:-}" ]; then
export GUILE_LOAD_PATH="$project_root/modules:$guix_source_dir:$GUILE_LOAD_PATH"
else
export GUILE_LOAD_PATH="$project_root/modules:$guix_source_dir"
fi
printf 'Using Guile: %s\n' "$guile_bin"
printf 'Working directory: %s\n' "$workdir"
"$guile_bin" -s "$runner_scm"

View File

@@ -0,0 +1,53 @@
(use-modules (fruix system freebsd)
(ice-9 format)
(ice-9 pretty-print)
(srfi srfi-1)
(srfi srfi-13)
(rnrs io ports))
(define workdir
(or (getenv "WORKDIR")
(error "WORKDIR environment variable is required")))
(define os-file
(or (getenv "OS_FILE")
(error "OS_FILE environment variable is required")))
(define metadata-file
(string-append workdir "/phase7-operating-system-metadata.txt"))
(primitive-load os-file)
(validate-operating-system phase7-operating-system)
(let* ((spec (operating-system-closure-spec phase7-operating-system))
(generated-files (assoc-ref spec 'generated-files))
(base-packages (assoc-ref spec 'base-packages)))
(call-with-output-file metadata-file
(lambda (port)
(format port "host_name=~a~%" (assoc-ref spec 'host-name))
(format port "kernel_package=~a~%" (assoc-ref spec 'kernel-package))
(format port "bootloader_package=~a~%" (assoc-ref spec 'bootloader-package))
(format port "base_package_count=~a~%" (assoc-ref spec 'base-package-count))
(format port "base_packages=~a~%" (string-join base-packages ","))
(format port "user_count=~a~%" (assoc-ref spec 'user-count))
(format port "users=~a~%" (string-join (assoc-ref spec 'users) ","))
(format port "group_count=~a~%" (assoc-ref spec 'group-count))
(format port "groups=~a~%" (string-join (assoc-ref spec 'groups) ","))
(format port "file_system_count=~a~%" (assoc-ref spec 'file-system-count))
(format port "services=~a~%" (string-join (map symbol->string (assoc-ref spec 'services)) ","))
(format port "generated_files=~a~%" (string-join generated-files ","))
(format port "init_mode=~a~%" (assoc-ref spec 'init-mode))
(format port "ready_marker=~a~%" (assoc-ref spec 'ready-marker))
(format port "spec_pretty=~a~%"
(string-map (lambda (ch) (if (char=? ch #\newline) #\space ch))
(with-output-to-string
(lambda ()
(pretty-print spec)))))))
(when (getenv "METADATA_OUT")
(copy-file metadata-file (getenv "METADATA_OUT")))
(format #t "PASS phase7-operating-system-model~%")
(format #t "Metadata file: ~a~%" metadata-file)
(when (getenv "METADATA_OUT")
(format #t "Copied metadata to: ~a~%" (getenv "METADATA_OUT")))
(display "--- metadata ---\n")
(display (call-with-input-file metadata-file get-string-all)))