This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| manuals:distributions:guix [2023/12/20 12:18] – tomas.volf | manuals:distributions:guix [2026/08/19 14:43] (current) – Update Guix platform inheritance and deployment examples aither | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | < | ||
| + | |||
| + | < | ||
| + | source=" | ||
| + | test=" | ||
| + | /> | ||
| + | |||
| ====== GNU Guix System ====== | ====== GNU Guix System ====== | ||
| - | [[https:// | ||
| - | manager. It allows one to declaratively configure the system and its services, | ||
| - | a concept shared with [[manuals: | ||
| - | language, Guix is built with Guile Scheme. This page describes Guix specifics on vpsFree.cz' | ||
| - | VPS. | ||
| - | ===== Configuration ===== | + | [[https:// |
| - | The VPS is created from a template which contains a minimal | + | services, and packages are described declaratively |
| - | You can log in with a generated password or deploy your public key using vpsAdmin. | + | [[manuals: |
| - | The system | + | configuration changes and lets you return to an earlier generation. |
| - | System configuration is stored in directory ''/ | + | ===== How the template works ===== |
| - | * '' | + | The vpsFree template |
| - | * '' | + | |
| - | < | + | * '' |
| - | # . /etc/profile | + | * '' |
| - | # guix pull | + | |
| - | # hash guix | + | |
| - | # guix system reconfigure | + | |
| - | </ | + | |
| - | Networking is handled by /ifcfg.add script, which is generated by vpsadminos | + | '' |
| + | module and inherits it. Keep the module lookup and inheritance: | ||
| + | base provides the container bootloader, file systems, kernel placeholder, | ||
| + | packages, services, and network integration. The current versions of both files | ||
| + | are available in the | ||
| + | [[https:// | ||
| - | ===== Known issues ===== | + | The kernel is managed by vpsAdminOS. Do not add your own Linux kernel or a |
| + | bootloader intended for a physical machine to the configuration. | ||
| - | * halt (graceful shutdown) has been observed to sometimes hang, please report in case it's still a problem. | + | ===== Editing |
| - | * cgroups v1 are not mounted. cgroups do not seem to be needed by the base system, contact us in case it's a problem for some service or submit a patch to the [[https:// | + | |
| - | * Hostname cannot be set using the vpsAdmin. | + | |
| - | * /gnu/store is not mounted with noatime flag. This could lead to reproducibility issues. | + | |
| - | ===== Alternative configuration for guix deploy ===== | + | Start by editing ''/ |
| + | are visible there as defaults that you can change. You can also add fields such | ||
| + | as '' | ||
| + | lookup and '' | ||
| + | remain active. | ||
| - | Slightly adjusted, single file, alternative configuration can be found below to be used as a starting point for your '' | + | When changing services, first derive and bind the service list outside the |
| + | '' | ||
| + | The deployment example below follows this pattern. Guix evaluates service | ||
| + | fields after loading | ||
| + | from its temporary configuration module. | ||
| - | * No dhcp-client-service-type, | + | Activate the configuration as '' |
| - | * No password authentication is allowed for ssh. | + | |
| - | * In a single file. | + | |
| - | * Added parts for guix deploy | + | |
| - | < | + | < |
| - | (use-modules (gnu) | + | # |
| - | (gnu machine) | + | set -eo pipefail |
| - | (gnu machine ssh) | + | |
| - | (gnu packages | + | |
| - | (gnu packages certs) | + | |
| - | (gnu packages ssh) | + | |
| - | (gnu services networking) | + | |
| - | (gnu services shepherd) | + | |
| - | (gnu services ssh) | + | |
| - | (guix build-system trivial) | + | |
| - | (guix packages) | + | |
| - | (srfi srfi-1)) | + | |
| - | ;;; The bootloader is not required. This is running inside a container, and the | + | # Use the Guix revision that built the active system generation. |
| - | ;;; start menu is populated by parsing | + | export GUIX_PROFILE=/run/current-system/profile |
| - | ;;; is a mandatory field, and the typical grub-bootloader requires users to | + | # shellcheck disable=SC1091 |
| - | ;;; always pass the --no-bootloader flag. By providing this bootloader | + | . "$GUIX_PROFILE/etc/profile" |
| - | ;;; configuration (it does not do anything, but installs fine), we remove the | + | hash guix |
| - | ;;; need to remember to pass the flag. At the cost of ~8MB in /boot. | + | |
| - | (define %ct-bootloader | + | |
| - | (bootloader-configuration | + | |
| - | ;; This one can be installed without efivars and without block device. | + | |
| - | | + | |
| - | | + | |
| - | ;;; It seems any package can be passed as an kernel, so create empty one for | + | test -r / |
| - | ;;; that purpose. | + | test -r / |
| - | (define %ct-dummy-kernel | + | test -r / |
| - | (package | + | guix time-machine -C / |
| - | (name "dummy-kernel" | + | |
| - | (version " | + | </ |
| - | (source #f) | + | |
| - | (build-system | + | |
| - | | + | |
| - | | + | |
| - | #:builder #~(mkdir # | + | |
| - | (synopsis "Dummy kernel" | + | |
| - | (description | + | |
| - | " | + | |
| - | still need to specify a kernel in the operating-system | + | |
| - | package.") | + | |
| - | (home-page #f) | + | |
| - | | + | |
| - | (define %ct-file-systems | + | '' |
| - | | + | reconfiguration does not depend on later channel-history changes. The |
| - | | + | '' |
| - | | + | builds and immediately activates a new generation. Before logging out, verify |
| - | (type " | + | that SSH and the services you need are running. See the manuals for |
| - | ;; Used by vpsadminos scripting. Can go away once /run as a whole is | + | [[https:// |
| - | ;; on tmpfs. | + | and [[https:// |
| - | (file-system | + | for details. |
| - | | + | |
| - | | + | |
| - | (type " | + | |
| - | | + | |
| - | | + | |
| - | (options " | + | |
| - | | + | |
| - | (map (λ (fs) | + | |
| - | (cond | + | |
| - | ;; %immutable-store is usually mounted with no-atime. That | + | |
| - | ;; does not work in the vpsFree (causing | + | |
| - | ;; we need to delete the flag. | + | |
| - | ((eq? fs %immutable-store) | + | |
| - | (file-system | + | |
| - | (inherit fs) | + | |
| - | (flags (delete 'no-atime (file-system-flags fs))))) | + | |
| - | (else | + | |
| - | fs))) | + | |
| - | (fold delete | + | |
| - | %base-file-systems | + | |
| - | (list | + | |
| - | ;; Already mounted by vpsadminos | + | |
| - | | + | |
| - | ;; Cannot be mounted due to the permissions | + | |
| - | | + | |
| - | %efivars-file-system))))) | + | |
| - | (define vpsadminos-networking | + | ===== Updating Guix ===== |
| - | (shepherd-service | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | " | + | |
| - | [ -f / | + | |
| - | touch / | + | |
| - | \" | + | |
| - | "))))) | + | |
| - | (define %ct-services | + | The example above selects the Guix revision and channels that built the active |
| - | | + | system generation. Reconfiguration therefore does not require '' |
| - | (mingetty-configuration | + | before every configuration change, keeping repeated deployments predictable. |
| - | (tty " | + | |
| - | | + | |
| - | shepherd-root-service-type (list vpsadminos-networking)) | + | |
| - | | + | When you intentionally update Guix, first record the current channels with |
| - | (delete console-font-service-type) | + | '' |
| - | | + | by the command, and reconfigure again. Read the news before changing revisions, |
| - | (delete mingetty-service-type) | + | and allow extra time, memory, and disk space for the build. The |
| - | | + | [[https:// |
| - | ;; loopback is configured | + | explains channels and pinned revisions. |
| - | (delete static-networking-service-type) | + | |
| - | ;; We need no rules. | + | |
| - | (udev-service-type config => | + | |
| - | (udev-configuration | + | |
| - | | + | |
| - | | + | |
| - | (define %signing-key | + | ===== Network and SSH ===== |
| - | ;; Fill this with your local signing key (/ | + | |
| - | " | + | |
| - | (define %system | + | Do not configure the primary network with '' |
| - | (operating-system | + | At every boot, vpsAdminOS creates '' |
| - | (host-name " | + | the '' |
| - | ;; Servers usually use UTC regardless of the location. | + | services on top of this layer. |
| - | | + | |
| - | | + | |
| - | (kernel %ct-dummy-kernel) | + | For convenient first access, the default template permits SSH login as |
| - | | + | '' |
| + | [[manuals: | ||
| - | (firmware '()) | + | ===== Deploying with guix deploy ===== |
| - | (initrd-modules '()) | + | |
| - | (packages (cons* nss-certs | + | If you manage several Guix VPSes, you can keep their configurations on one |
| - | %base-packages)) | + | coordinator Guix system and deploy them with |
| + | [[https:// | ||
| + | The complete configuration below is a starting point for one VPS. You maintain | ||
| + | only '' | ||
| + | ''/ | ||
| - | (essential-services | + | The coordinator needs the SSH key ''/ |
| - | (modify-services | + | its public part to '' |
| - | (operating-system-default-essential-services this-operating-system) | + | key-only login first. Run '' |
| - | (delete firmware-service-type) | + | VPS and verify the resulting key fingerprint by following the |
| - | (delete (service-kind %linux-bare-metal-service)))) | + | [[manuals: |
| + | beginning with '' | ||
| - | (file-systems %ct-file-systems) | + | Save this configuration as ''/ |
| + | replace the target VPS address and host key: | ||
| - | (services | + | <code scheme> |
| - | | + | ;; Load the maintained vpsAdminOS container integration. |
| - | | + | (add-to-load-path "/ |
| - | (openssh openssh-sans-x) | + | (use-modules (gnu) |
| - | (permit-root-login #t) | + | |
| - | ;; Only keys are allowed. | + | |
| - | | + | |
| - | (simple-service | + | (use-service-modules ssh) |
| - | (guix-extension | + | |
| - | | + | |
| - | (list (plain-file " | + | |
| - | %ct-services)))) | + | |
| - | ;;; Set this to the SSH key of the machine. | + | (let* ((platform-system |
| - | (define %host-key | + | (module-ref (resolve-interface ' |
| - | "ssh-ed25519 | + | ' |
| + | ;; These files belong | ||
| + | | ||
| + | (local-file "/ | ||
| + | | ||
| + | (local-file "/ | ||
| + | ;; Build the service list before assigning the delayed services field. | ||
| + | | ||
| + | (cons | ||
| + | | ||
| + | guix-service-type | ||
| + | | ||
| + | (authorized-keys | ||
| + | (list controller-signing-key)))) | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | (inherit config) | ||
| + | (permit-root-login ' | ||
| + | (password-authentication? | ||
| + | (authorized-keys | ||
| + | `(("root" ,root-ssh-key)))))))) | ||
| + | | ||
| + | (operating-system | ||
| + | (inherit platform-system) | ||
| + | (host-name " | ||
| + | (timezone " | ||
| + | (locale "en_US.utf8" | ||
| + | (services user-services))) | ||
| + | | ||
| + | (machine | ||
| + | (operating-system system) | ||
| + | (environment managed-host-environment-type) | ||
| + | (configuration | ||
| + | | ||
| + | ;; Replace the address and host key with those of your target VPS. | ||
| + | (host-name "192.0.2.3") | ||
| + | (system " | ||
| + | (user " | ||
| + | (identity "/ | ||
| + | (host-key " | ||
| + | (authorize? #t) | ||
| + | (allow-downgrades? | ||
| + | ;; vpsAdminOS supplies the kernel and exposes a dummy /dev/null root. | ||
| + | ;; Guix's bare-metal file-system/ | ||
| + | (safety-checks? | ||
| + | (list target-machine)) | ||
| + | </ | ||
| - | (define %machine | + | First load the configuration without deploying it with '' |
| - | (machine | + | / |
| - | (operating-system | + | / |
| - | | + | '' |
| - | (configuration (machine-ssh-configuration | + | signing |
| - | ;; Put the IP or host name here. | + | generation. |
| - | (host-name "...") | + | |
| - | (system " | + | |
| - | (host-key %host-key) | + | |
| - | (allow-downgrades? | + | |
| - | | + | |
| - | (list %machine) | + | The configuration deliberately allows only key-based '' |
| + | verifies the target host key. The container-specific '' | ||
| + | disables Guix checks for physical file systems and initrd modules: vpsAdminOS | ||
| + | supplies the kernel and its integration module exposes a dummy ''/ | ||
| + | root which current Guix cannot inspect. Downgrade protection stays enabled. | ||
| + | If deployment fails, fix its cause instead of enabling | ||
| + | '' | ||
| - | </code> | + | ===== Generations and recovery ===== |
| + | |||
| + | List generations with '' | ||
| + | before deleting older generations. The | ||
| + | [[https:// | ||
| + | describes rollback and generation management. | ||
| + | |||
| + | If a new configuration does not boot or you lose SSH access, follow the | ||
| + | [[manuals: | ||
| + | [[manuals: | ||
| + | an older Guix generation. Fix the configuration and reconfigure again. | ||
| - | If you will go via the guix deploy route, you should likely delete the /etc/config directory to prevent any confusion. | ||