;;; genenetwork-machines --- Guix configuration for genenetwork machines ;;; Copyright © 2024 Pjotr Prins ;;; ;;; This file is part of genenetwork-machines. ;;; ;;; genenetwork-machines 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. ;;; ;;; genenetwork-machines 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 genenetwork-machines. If not, see ;;; . ;;; CGIT as a SELF-CONTAINED VM. ;;; ;;; Unlike the full guix-forge stack (which brings acme, webhook, ;;; laminar and Anubis along), this VM only runs the slim cgit ;;; services from (genenetwork services cgit) -- cgit-pink behind ;;; fcgiwrap on a unix socket, foreground nginx, and the ;;; git-http-backend location for the smart HTTP protocol. Those ;;; services are derived from guix-forge's (forge cgit)/(forge ;;; fcgiwrap)/(forge anubis), but avoid the stock nginx shepherd ;;; services that wedge system containers. ;;; ;;; A VM (unlike a system container) has its own writable disk, so ;;; state survives reboots and SSH host keys are generated at first ;;; boot. Run it with: ;;; ;;; qemu-system-x86_64 -m 1024 \ ;;; -drive file=/gnu/store/...-image.qcow2,format=qcow2 \ ;;; -netdev user,id=n0,hostfwd=tcp:127.0.0.1:8883-:8883,hostfwd=tcp:127.0.0.1:2224-:22 \ ;;; -device virtio-net-pci,netdev=n0 \ ;;; -nographic ;;; ;;; (-enable-kvm on the host for usable speed.) Build the image with: ;;; ;;; ($base = a directory holding the checkouts side by side; adapt to ;;; your layout.) ;;; ;;; guix system image -t qcow2 \ ;;; -L $base/guix-bioinformatics \ ;;; -L $base/gn-machines \ ;;; -L $base/contrib/guix-forge/guix \ ;;; $base/gn-machines/vms/cgit-vm.scm (define-module (genenetwork services cgit-vm) #:use-module (gnu) #:use-module (genenetwork services cgit) #:use-module (gnu services base) #:use-module (gnu services networking) #:use-module (gnu services ssh) #:use-module (gnu packages version-control)) (use-service-modules ssh) (use-package-modules base bash admin compression python version-control linux) (define %cgit-web-config (cgit-web-configuration (root-title "GeneNetwork cgit") (root-desc "Git repositories for the GeneNetwork project") (repository-directory "/srv/git"))) (operating-system (host-name "cgit-vm") (timezone "Etc/UTC") (locale "en_US.utf8") (kernel-arguments '("console=ttyS0,115200")) (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets '("/dev/vda")))) ;; The qcow2 image type creates a root partition labelled ;; "Guix_image" (hardcoded in gnu/system/image.scm). (file-systems (cons (file-system (device (file-system-label "Guix_image")) (mount-point "/") (type "ext4")) %base-file-systems)) (users (cons (user-account (name "root") (uid 0) (group "root") (password (crypt "hello" "$6$abc$0123456789abcdef$"))) %base-user-accounts)) ;; Minimal packages: nginx, fcgiwrap and cgit come in through the ;; cgit services, ssh tools through the openssh service, 'herd' ;; through the essential shepherd service. git seeds the demo ;; repository, gzip would serve cgit snapshots, python is needed by ;; cgit's md2html about-filter. (packages (list bash coreutils shadow grep procps git gzip python)) (services (append (list ;; One shared configuration for both services (the nginx ;; front-end needs the same record to generate the cgitrc for ;; fcgiwrap's CGIT_CONFIG environment). (service cgit-web-service-type %cgit-web-config) (service cgit-nginx-service-type %cgit-web-config) ;; Seed the demo repository (shared with the cgit container). cgit-demo-repository-service ;; QEMU user-mode network stack (10.0.2.15, gateway 10.0.2.2). (service static-networking-service-type (list %qemu-static-networking)) ;; Password-less root login with etc/hello-container-key on the ;; guest's port 22; the VM runner forwards a host port to it. ;; Host keys are generated at first boot and persist in the ;; (writable) image. (service openssh-service-type (openssh-configuration (permit-root-login #t) (password-authentication? #f) (authorized-keys `(("root" ,(local-file "../../run-guix-container/etc/hello-container-key.pub" "authorized_keys")))))) ;; Serial console login, for debugging when ssh does not work. (service agetty-service-type (agetty-configuration (extra-options '("-L")) (baud-rate "115200") (term "vt100") (tty "ttyS0")))) (modify-services %base-services ;; No guix-daemon in the VM: images are built on the host. (delete guix-service-type)))))