From patchwork Sun May 12 00:50:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 13954 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8D08216FC5; Sun, 12 May 2019 01:55:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 9C13816F88 for ; Sun, 12 May 2019 01:55:12 +0100 (BST) Received: from localhost ([127.0.0.1]:37078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPclf-0002Ro-6R for patchwork@mira.cbaines.net; Sat, 11 May 2019 20:55:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPclc-0002Rj-3U for guix-patches@gnu.org; Sat, 11 May 2019 20:55:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPcla-0005A0-M3 for guix-patches@gnu.org; Sat, 11 May 2019 20:55:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56173) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPcla-00059p-IG for guix-patches@gnu.org; Sat, 11 May 2019 20:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hPcla-0004tO-91 for guix-patches@gnu.org; Sat, 11 May 2019 20:55:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35692] [PATCH] system: vm: Auto-detect if inputs should be registered. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 12 May 2019 00:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35692 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35692@debbugs.gnu.org X-Debbugs-Original-To: guix-patches Received: via spool by submit@debbugs.gnu.org id=B.155762246818762 (code B ref -1); Sun, 12 May 2019 00:55:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 May 2019 00:54:28 +0000 Received: from localhost ([127.0.0.1]:41484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPcl2-0004sY-0H for submit@debbugs.gnu.org; Sat, 11 May 2019 20:54:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPckz-0004sJ-Be for submit@debbugs.gnu.org; Sat, 11 May 2019 20:54:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:44806) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hPcku-0004xb-1s for submit@debbugs.gnu.org; Sat, 11 May 2019 20:54:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPcks-00025B-Rj for guix-patches@gnu.org; Sat, 11 May 2019 20:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPche-00042Y-7c for guix-patches@gnu.org; Sat, 11 May 2019 20:50:59 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:36442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPche-000423-0C for guix-patches@gnu.org; Sat, 11 May 2019 20:50:58 -0400 Received: by mail-qk1-x729.google.com with SMTP id c14so6026668qke.3 for ; Sat, 11 May 2019 17:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=yScEgxdnmchJm0G3mLtaMyalt7MTGfJMfNQi32L77BE=; b=ZaBoSCHpzWU1M7IIiksMGHKRu4oJtR5CHBusyW3TxMxwRBQUURhS2QlbT+gluNAYPR CqFrqgKNMYJzNShhx3IVZWTKmIMtxo1VhOUEgGKqZ1pkcG4ckOdiaTzQGnd+FoOPv3hb 21bU64moOeRUWk2cJy43uFKgaeFK5v+7vuRE5wJlmJS5e35F47Hov8LQS3Yo02cx9znX NXuf1Gf5HtYkiSfHDjKr7qD+krRPRfVNP0ULqRjUgZx67RZUOFVJW5n0bQaiAs8Dbi4S dwDifrvJA6xYSMxi5Uk3cX2aD5zotusDOx9EMUfnKLUoFLRhQ3P6CsV1ANQIba7YXIU/ xUMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=yScEgxdnmchJm0G3mLtaMyalt7MTGfJMfNQi32L77BE=; b=CqtAYFomZiWX6ctNFF6iE0Fp11aPNsZcPkOrB1gSOMkqo2AxuSttLWxB2NaZAyu229 proVhTRTCPY5Xne9CSTMptj3gkRGWnCAGyph5Iledvh25cVmHtmTsCyD4DHZg2/3/uB1 PJ86PQinuHTILUtHxFHofDo9mF+w3QzVIAl8RzvlOU4B8Ft5DI8ZNQhzrPuBss1RF76h C6S/UtqW43MNaQz2I1c+dRAdKTvnFTE0scWooQMYl4jxeOuTFAlonrg/iisWAXFW1Z7/ 7BXQ9Bjeh+2OpI4Y4gTqcfxiXNaavdUKSnsnk0o/x/PW7mrk6X8WB3dXkvVWJZphq1qG 9Whw== X-Gm-Message-State: APjAAAWlA4uvwHXhcVG6qJL5RtV2aIzyWj7IKNMF/EGbutrO09YOBrZQ pge4N7kRiP+Hte0A8ZGIA6RkwZsY X-Google-Smtp-Source: APXvYqw1bDeBSRokTjZlxhgC6/756IBdW2pnzeYg70bXlmvftw1jWYgvdd/Mwkrn9MH7LTlYs3xHPQ== X-Received: by 2002:a37:6410:: with SMTP id y16mr16207007qkb.47.1557622256542; Sat, 11 May 2019 17:50:56 -0700 (PDT) Received: from kwak (dsl-10-149-109.b2b2c.ca. [72.10.149.109]) by smtp.gmail.com with ESMTPSA id d8sm4629993qtr.64.2019.05.11.17.50.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 11 May 2019 17:50:55 -0700 (PDT) From: Maxim Cournoyer Date: Sat, 11 May 2019 20:50:54 -0400 Message-ID: <87d0kov6kx.fsf@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hello! The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be removed and its value computed automatically, since the operating-system definition is available in its context. When the operating-system definition does not contain the GUIX-SERVICE-TYPE, do not register the closure in the database of Guix, as it takes time and doesn't serve a purpose. The time saving is close to 2 minutes on my machine for every test using a very minimal OS configuration and building it with `guix system docker-image my-config.scm'. Thank you, Maxim From 59d78c066727d5c3df22a6e269025ae7e058b45c Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 16 Apr 2019 17:15:02 -0400 Subject: [PATCH] system: vm: Auto-detect if inputs should be registered. The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be removed and its value computed automatically, since the operating-system definition is available in its context. When the operating-system definition does not contain the GUIX-SERVICE-TYPE, do not register the closure in the database of Guix, as it takes time and doesn't serve a purpose. * gnu/system/vm.scm (use-modules): Add (gnu services base). (system-docker-image): Remove the REGISTER-CLOSURES? argument, as well as its associate documentation in the docstring. [has-guix-service-type?] Add predicate and use it to compute the value of the REGISTER-CLOSURE? argument of the INITIALIZE procedure. --- gnu/system/vm.scm | 24 +++++++++++++----------- guix/scripts/system.scm | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 124abd0fc9..c57b8bf35f 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -64,6 +64,7 @@ #:use-module (gnu system file-systems) #:use-module (gnu system) #:use-module (gnu services) + #:use-module (gnu services base) #:use-module (gnu system uuid) #:use-module (srfi srfi-1) @@ -249,6 +250,11 @@ made available under the /xchg CIFS share." #:guile-for-build guile-for-build #:references-graphs references-graphs))) +(define (has-guix-service-type? os) + (find (lambda (service) + (eq? (service-kind service) guix-service-type)) + (operating-system-services os))) + (define* (iso9660-image #:key (name "iso9660-image") file-system-label @@ -258,7 +264,7 @@ made available under the /xchg CIFS share." os bootcfg-drv bootloader - register-closures? + (register-closures? (has-guix-service-type? os)) (inputs '())) "Return a bootable, stand-alone iso9660 image. @@ -343,7 +349,7 @@ INPUTS is a list of inputs (as for packages)." os bootcfg-drv bootloader - (register-closures? #t) + (register-closures? (has-guix-service-type? os)) (inputs '()) copy-inputs?) "Return a bootable, stand-alone QEMU image of type DISK-IMAGE-FORMAT (e.g., @@ -474,14 +480,12 @@ the image." (define* (system-docker-image os #:key (name "guixsd-docker-image") - register-closures?) + (register-closures? (has-guix-service-type? os))) "Build a docker image. OS is the desired . NAME is the -base name to use for the output file. When REGISTER-CLOSURES? is not #f, -register the closure of OS with Guix in the resulting Docker image. This only -makes sense when you want to build a Guix System Docker image that has Guix -installed inside of it. If you don't need Guix (e.g., your Docker -image just contains a web server that is started by the Shepherd), then you -should set REGISTER-CLOSURES? to #f." +base name to use for the output file. When REGISTER-CLOSURES? is #t, register +the closure of OS with Guix in the resulting Docker image. By default, +REGISTER-CLOSURES? is set to #t only if a service of type GUIX-SERVICE-TYPE +is present in the services definition of teh operating system." (define schema (and register-closures? (local-file (search-path %load-path @@ -678,7 +682,6 @@ to USB sticks meant to be read-only." #:file-system-label root-label #:file-system-uuid uuid #:os os - #:register-closures? #t #:bootcfg-drv bootcfg #:bootloader (bootloader-configuration-bootloader (operating-system-bootloader os)) @@ -695,7 +698,6 @@ to USB sticks meant to be read-only." #:file-system-label root-label #:file-system-uuid uuid #:copy-inputs? #t - #:register-closures? #t #:inputs `(("system" ,os) ("bootcfg" ,bootcfg)))))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 3c3d6cbd5f..3fb504bced 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -781,7 +781,7 @@ checking this by themselves in their 'check' procedure." #:disk-image-size image-size #:file-system-type file-system-type)) ((docker-image) - (system-docker-image os #:register-closures? #t)))) + (system-docker-image os)))) (define (maybe-suggest-running-guix-pull) "Suggest running 'guix pull' if this has never been done before." -- 2.21.0