From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id mK++JvSODWVWUAAA9RJhRA:P1 (envelope-from ) for ; Fri, 22 Sep 2023 14:56:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id mK++JvSODWVWUAAA9RJhRA (envelope-from ) for ; Fri, 22 Sep 2023 14:56:20 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 630E35E4C6 for ; Fri, 22 Sep 2023 14:56:20 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=aJaobxCT; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1695387380; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=IUpl87JnzSpapiHtxjjagb3VgMXMf/2W4r89ek4yA/k=; b=Evbr66uWcv7dJ1TDThcRE2XU4m70KoyvM3M7z0KUkfNaDHpyFG+0TAUdATbIC4zYo4wcFl kQTBPYmxxDFp+ASBp9zLROxjxmM2asDD8SZUAbQm4fJB94pL6OuU9Q3GeVyl3tmB1flWHS oq85BqM0hswpHwQqp4UxZaHmVA4APQhlJt9p0J8S8t4VJ6jsRRznZE7XmI1KgsVWK/FuW7 qkz4d7FfngPuirUJg5oX3dYx3MV4et8QZs3ONIP8Qx8vn3nqS8KBK5E/Q+JSzPS3TrdIG5 P3y7yLDhROOEgnypRWhcAwXPYuD210AlujP+UuB/g+sF275HZJj7+Z0DHu3O/A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1695387380; a=rsa-sha256; cv=none; b=jdwyYk8kz3wssXZdbXWFQboUYmoMSN9G2SG54VDCkULtcWoRy7x6hXQju8cZgOSPt1mDDg uXqIgTrpc0HWuTqyBqH+/q6t21Midz1Otr7eVn15yZ1Sv63vzysCbLzRwSLc1xr5oDp1ch 0rqJbt+S76gRrspXGmOYLKHM5cLwYvChCQ8t1Atz2U7Ueh6DUy5x0/7H/7wRQ3Xi+MCtRa gXJrhdIM3MaiXLonVu6u+YzDLb91elMh+8bwE0bplK0YTm6pGaFMlcrB+B/hw2ghgmL39e p8JAYtXff1c7c2X11rcdJlDxyVFQ5ALOdLSGbJg33BNqkLvsLB4vnI0Q2mDWrQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=aJaobxCT; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjfhJ-0001Nv-Aj; Fri, 22 Sep 2023 08:55:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjfhH-0001NP-TN for guix-patches@gnu.org; Fri, 22 Sep 2023 08:55:51 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjfhH-0008At-Kg for guix-patches@gnu.org; Fri, 22 Sep 2023 08:55:51 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjfhS-0005is-5S for guix-patches@gnu.org; Fri, 22 Sep 2023 08:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66156] [PATCH 06/12] services: guix: Support declarative offloading setup. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Sep 2023 12:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66156 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66156@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 66156-submit@debbugs.gnu.org id=B66156.169538731121892 (code B ref 66156); Fri, 22 Sep 2023 12:56:02 +0000 Received: (at 66156) by debbugs.gnu.org; 22 Sep 2023 12:55:11 +0000 Received: from localhost ([127.0.0.1]:35589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjfgc-0005h0-Ig for submit@debbugs.gnu.org; Fri, 22 Sep 2023 08:55:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjfgL-0005e7-9K for 66156@debbugs.gnu.org; Fri, 22 Sep 2023 08:54:53 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjfg5-0007mD-CX; Fri, 22 Sep 2023 08:54:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=IUpl87JnzSpapiHtxjjagb3VgMXMf/2W4r89ek4yA/k=; b=aJaobxCTTJwJS07gfDsB VR5wZc9PSNk+2LmyGwGEwBG3sTRZQi7AT2JxjNhgrDKtVEmZzjPShk/vYdWZuN26DumfIZibBCjNO tGEkCiVlLlfl+KKo70AXNkKGYsFpcD7nPiXUHwQVYgVotjz18tw3rD1niGnMps5ypBBQd4V+Y4Js+ KBl5VW4z/fgmoNg4lK1f/fj7/aDVkBAHSTtZVN7THBBSXDpSveJf6s39rrRaHCWEOAyjN+iLWHFqa vjNRaaM2Qz+/nvfBwQSUBQai35hMauEEqsuME9z7lGkMKGGBq6e1QXfZeSNJkSeKCQJfJ+iUu3a+z MCj/ef8SXCz1KQ==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 22 Sep 2023 14:54:07 +0200 Message-ID: <733d12daff33a35bceaf6d36346a5a3ddd8faa0d.1695386493.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -2.98 X-Migadu-Spam-Score: -2.98 X-Migadu-Scanner: mx1.migadu.com X-Migadu-Queue-Id: 630E35E4C6 X-TUID: 8iTMoLqvnxjQ * gnu/services/base.scm (guix-machines-files-installation): New procedure. ()[build-machines]: New field. (guix-activation): Call ‘ guix-machines-files-installation’. ()[build-machines]: New field. (guix-extension-merge): Handle it. (guix-service-type)[extend]: Likewise. * doc/guix.texi (Daemon Offload Setup): Add note linking to ‘guix-configuration’. (Base Services): Document ‘build-machines’ field of and of . (Virtualization Services): Add ‘hurd-vm’ anchor. --- doc/guix.texi | 42 +++++++++++++++++++++++++++++++++++++++++- gnu/services/base.scm | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 50c4984d71..ca48d6c404 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1484,6 +1484,14 @@ Daemon Offload Setup @end table @end deftp +@quotation Note +On Guix System, instead of managing @file{/etc/guix/machines.scm} +independently, you can choose to specify build machines directly in the +@code{operating-system} declaration, in the @code{build-machines} field +of @code{guix-configuration}. @xref{guix-configuration-build-machines, +@code{build-machines} field of @code{guix-configuration}}. +@end quotation + The @command{guix} command must be in the search path on the build machines. You can check whether this is the case by running: @@ -19259,6 +19267,28 @@ Base Services Whether to discover substitute servers on the local network using mDNS and DNS-SD. +@anchor{guix-configuration-build-machines} +@item @code{build-machines} (default: @code{#f}) +This field must be either @code{#f} or a list of gexps evaluating to a +@code{build-machine} record (@pxref{Daemon Offload Setup}). + +When it is @code{#f}, the @file{/etc/guix/machines.scm} file is left +untouched. Otherwise, the list of of gexps is written to +@file{/etc/guix/machines.scm}; if a previously-existing file is found, +it is backed up as @file{/etc/guix/machines.scm.bak}. This allows you +to declare build machines for offloading directly in the operating +system declaration, like so: + +@lisp +(guix-configuration + (build-machines + (list #~(build-machine (name "foo.example.org") @dots{}) + #~(build-machine (name "bar.example.org") @dots{})))) +@end lisp + +Additional build machines may be added @i{via} the @code{guix-extension} +mechanism (see below). + @item @code{extra-options} (default: @code{'()}) List of extra command-line options for @command{guix-daemon}. @@ -19296,7 +19326,6 @@ Base Services @end deftp @deftp {Data Type} guix-extension - This data type represents the parameters of the Guix build daemon that are extendable. This is the type of the object that must be used within a guix service extension. @@ -19309,6 +19338,16 @@ Base Services @item @code{substitute-urls} (default: @code{'()}) A list of strings where each element is a substitute URL. +@item @code{build-machines} (default: @code{'()}) +A list of gexps that evaluate to @code{build-machine} records +(@pxref{Daemon Offload Setup}). + +Using this field, a service may add new build machines to receive builds +offloaded by the daemon. This is useful for a service such as +@code{hurd-vm-service-type}, which can make a GNU/Hurd virtual machine +directly usable for offloading (@pxref{hurd-vm, +@code{hurd-vm-service-type}}). + @item @code{chroot-directories} (default: @code{'()}) A list of file-like objects or strings pointing to additional directories the build daemon can use. @end table @@ -35650,6 +35689,7 @@ Virtualization Services @end deftp +@anchor{hurd-vm} @subsubheading The Hurd in a Virtual Machine @cindex @code{hurd} diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 10e0d4cf9d..98d59fd36d 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1743,6 +1743,31 @@ (define %default-authorized-guix-keys (list (file-append guix "/share/guix/berlin.guix.gnu.org.pub") (file-append guix "/share/guix/bordeaux.guix.gnu.org.pub"))) +(define (guix-machines-files-installation machines) + "Return a gexp to install MACHINES, a list of gexps, as +/etc/guix/machines.scm, which is used for offloading." + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (define machines-file + "/etc/guix/machines.scm") + + ;; If MACHINES-FILE already exists, move it out of the way. + ;; Create a backup if it's a regular file: it's likely that the + ;; user manually updated it. + (if (file-exists? machines-file) + (if (and (symbolic-link? machines-file) + (store-file-name? (readlink machines-file))) + (delete-file machines-file) + (rename-file machines-file + (string-append machines-file ".bak"))) + (mkdir-p (dirname machines-file))) + + ;; Installed the declared machines file. + (symlink #+(scheme-file "machines.scm" machines) + machines-file)))) + (define-record-type* guix-configuration make-guix-configuration guix-configuration? @@ -1780,6 +1805,8 @@ (define-record-type* (default #f)) (tmpdir guix-tmpdir ;string | #f (default #f)) + (build-machines guix-build-machines ;list of gexps | #f + (default #f)) (environment guix-configuration-environment ;list of strings (default '()))) @@ -1965,8 +1992,15 @@ (define (guix-activation config) (system* #$(file-append guix "/bin/guix") "archive" "--generate-key")) + ;; Optionally install /etc/guix/acl... #$(if authorize-key? (substitute-key-authorization authorized-keys guix) + #~#f) + + ;; ... and /etc/guix/machines.scm. + #$(if (guix-build-machines config) + (guix-machines-files-installation + #~(list #$@(guix-build-machines config))) #~#f)))) (define-record-type* @@ -1976,6 +2010,8 @@ (define-record-type* (default '())) (substitute-urls guix-extension-substitute-urls ;list of strings (default '())) + (build-machines guix-extension-build-machines ;list of gexps + (default '())) (chroot-directories guix-extension-chroot-directories ;list of file-like/strings (default '()))) @@ -1985,6 +2021,8 @@ (define (guix-extension-merge a b) (guix-extension-authorized-keys b))) (substitute-urls (append (guix-extension-substitute-urls a) (guix-extension-substitute-urls b))) + (build-machines (append (guix-extension-build-machines a) + (guix-extension-build-machines b))) (chroot-directories (append (guix-extension-chroot-directories a) (guix-extension-chroot-directories b))))) @@ -2008,6 +2046,11 @@ (define guix-service-type (guix-configuration-authorized-keys config))) (substitute-urls (append (guix-extension-substitute-urls extension) (guix-configuration-substitute-urls config))) + (build-machines + (and (or (guix-build-machines config) + (pair? (guix-extension-build-machines extension))) + (append (or (guix-build-machines config) '()) + (guix-extension-build-machines extension)))) (chroot-directories (append (guix-extension-chroot-directories extension) (guix-configuration-chroot-directories config)))))) -- 2.41.0