;;; 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 ;;; . ;;; BNW as a SELF-CONTAINED VM (alternative to bnw-container.scm). ;;; ;;; The container shares the host's whole /gnu/store read-only; a ;;; qcow2 disk image contains only this system's closure, so a VM is ;;; the right shape for a PUBLIC deployment: nothing of the host is ;;; mounted, the disk is writable (state survives reboots), and RAM ;;; is bounded explicitly -- this VM is sized for 2 GiB: ;;; ;;; qemu-system-x86_64 -m 2048 \ ;;; -drive file=/gnu/store/...-image.qcow2,format=qcow2 \ ;;; -netdev user,id=n0,hostfwd=tcp:127.0.0.1:8881-:8881,hostfwd=tcp:127.0.0.1:2222-:22 \ ;;; -device virtio-net-pci,netdev=n0 \ ;;; -nographic ;;; ;;; (use -enable-kvm on the host for usable speed; TCG works but is ;;; slow. Peak memory during an 8-node structure-learning run is ;;; ~210 MiB, so 2 GiB leaves ample headroom for larger datasets.) ;;; ;;; The BNW services (bnw-service-type, bnw-nginx-service-type with ;;; the foreground-nginx fix) are imported from ;;; (genenetwork containers bnw-container) -- build with both channels ;;; on the load path: ;;; ;;; ($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 \ ;;; $base/gn-machines/vms/bnw-vm.scm ;;; ;;; ssh: guest port 22 (forward to a host port with hostfwd), root ;;; login with etc/hello-container-key. Host keys are generated at ;;; first boot and persist in the writable image. (define-module (genenetwork services bnw-vm) #:use-module (gnu) #:use-module (genenetwork services bnw) #:use-module (gnu services base) #:use-module (gnu services ssh) #:use-module (gnu services networking)) (use-service-modules ssh) (use-package-modules base bash admin linux) (operating-system (host-name "bnw-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, php-fpm and bnw come in through the ;; bnw/bnw-nginx services, ssh tools through the openssh service, ;; 'herd' through the essential shepherd service. (packages (list bash coreutils shadow grep procps)) (services (append (list (service bnw-service-type) (service bnw-nginx-service-type) ;; 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 -- no pinning needed. (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)))))