From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH 6/7] guix build: Add 'build-package'. Date: Sun, 06 Sep 2015 12:03:38 +0300 Message-ID: <87bndfx6l1.fsf@gmail.com> References: <1437814197-6321-1-git-send-email-alezost@gmail.com> <1437814197-6321-7-git-send-email-alezost@gmail.com> <87zj1ou1i0.fsf@gnu.org> <878u972ea9.fsf@gmail.com> <87mvxe8frd.fsf@gnu.org> <87oahuvtah.fsf@gmail.com> <87si73u5no.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYVrH-0002xZ-Sw for guix-devel@gnu.org; Sun, 06 Sep 2015 05:03:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYVrG-0005ep-In for guix-devel@gnu.org; Sun, 06 Sep 2015 05:03:31 -0400 In-Reply-To: <87si73u5no.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 28 Aug 2015 11:24:43 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2015-08-28 12:24 +0300) wrote: > Alex Kost skribis: > >> Ludovic Court=C3=A8s (2015-08-26 14:12 +0300) wrote: >> >>> Alex Kost skribis: >>> >>>> Ludovic Court=C3=A8s (2015-08-18 17:15 +0300) wrote: >>>> >>>>> Alex Kost skribis: >>>>> >>>>>> * guix/scripts/build.scm (build-package): New procedure. >>>>> >>>>> [...] >>>>> >>>>>> +(define (build-package package . build-options) >>>>>> + "Build PACKAGE using BUILD-OPTIONS." >>>>>> + (with-store store >>>>>> + (let* ((drv (run-with-store store >>>>>> + (package->derivation package))) >>>>>> + (drvs (list drv))) >>>>>> + (apply set-build-options store build-options) >>>>>> + (show-what-to-build store drvs) >>>>>> + (build-derivations store drvs) >>>>>> + (show-derivation-outputs drv)))) >>>>> >>>>> I think this doesn=E2=80=99t fit here because it isn=E2=80=99t actual= ly used by =E2=80=98guix >>>>> build=E2=80=99. Maybe keep it in emacs/ for now? >>>> >>>> If you mean "guix-main.scm", I don't think it's the right place either, >>>> as all this guix-devel stuff does not depend on Guix REPL (or on any >>>> code from "guix-main.scm" in general). Besides, "guix-main.scm" doesn= 't >>>> provide a module. >>>> >>>> What about making some additional module?: (guix devel) or something. >>>> Other similar code may be put there in future. For example, you are >>>> editing a package definition and you may want to download the current >>>> origin source. It will probably also require some specific scheme cod= e, >>>> which may be added to that module. >>> >>> Maybe =E2=80=98build-package=E2=80=99 could go to (guix packages)? >> >> =E2=80=98build-package=E2=80=99 uses =E2=80=98show-=E2=80=A6=E2=80=99 pr= ocedures from (guix ui) module. I >> thought that adding this module to (guix packages) was not desired, or >> is it OK? > > Right, sorry. So maybe leave in (guix build scripts) with a comment > explaining that it doesn=E2=80=99t have a better place and is for use by = the > Emacs UI. (Make sure to use the monadic style as suggested in a > previous message.) > > Could you send an updated patch? Yes, sorry for the delay. At some point I noticed that =E2=80=98build-pack= age=E2=80=99 doesn't show any build output, and I had a hard time trying to find out what's wrong. Eventually it appeared to be totally unrelated to the code itself. I think it's a Geiser bug, but I don't know how to make a guix independent recipe =E2=80=94 I have sent a message describing it in de= tails to guix-devel =E2=80=94 I hope you could help with it :-) So I am attaching 2 patches here: for adding =E2=80=98set-build-options*=E2= =80=99 and for adding =E2=80=98build-package=E2=80=99. Now about the second patch. At first, I don't agree with it :-). I added #:dry-run? to =E2=80=98build-package=E2=80=99 procedure as I think it= may be useful, then I found a nice =E2=80=98maybe-build=E2=80=99 procedure in (gui= x scripts system), and I just moved it to (guix scripts build) which doesn't seem right. We have some code in (guix scripts =E2=80=A6) that is rather common (I mean= not specific to the current module), but there is no better place for it, usually because it uses (guix ui). So what about making (guix scripts) module for such general stuff? I think we can move there =E2=80=98maybe-build=E2=80=99, =E2=80=98%standard= -build-options=E2=80=99, =E2=80=98set-build-options-from-command-line(*)=E2=80=99, =E2=80=98show-bui= ld-options-help=E2=80=99, perhaps exported procedures from (guix scripts package). And =E2=80=98build-package=E2=80=99 may also go there, WDYT? Or maybe just put those things into (guix ui)? --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-store-Add-set-build-options.patch Content-Transfer-Encoding: quoted-printable >From fd38fdae6e66effeba346e7bc863fc5348ec9b9a Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 3 Sep 2015 18:33:51 +0300 Subject: [PATCH 1/2] store: Add 'set-build-options*'. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Suggested by: Ludovic Court=C3=A8s * guix/store.scm (set-build-options*): New procedure. --- guix/store.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guix/store.scm b/guix/store.scm index 132b8a3..93f2c77 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -58,6 +58,7 @@ close-connection with-store set-build-options + set-build-options* valid-path? query-path-hash hash-part->path @@ -535,6 +536,9 @@ encoding conversion errors." (let loop ((done? (process-stderr server))) (or done? (process-stderr server))))) =20 +(define set-build-options* + (store-lift set-build-options)) + (define-syntax operation (syntax-rules () "Define a client-side RPC stub for the given operation." --=20 2.5.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0002-guix-build-Add-build-package.patch Content-Transfer-Encoding: quoted-printable >From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 23 Jul 2015 16:16:41 +0300 Subject: [PATCH 2/2] guix build: Add 'build-package'. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/system.scm (maybe-build): Move to ... * guix/scripts/build.scm: ...here. (build-package): New procedure. Co-authored-by: Ludovic Court=C3=A8s --- guix/scripts/build.scm | 41 ++++++++++++++++++++++++++++++++++++++++- guix/scripts/system.scm | 13 ------------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index f169853..ee4a3d6 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2012, 2013, 2014, 2015 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2013 Mark H Weaver +;;; Copyright =C2=A9 2015 Alex Kost ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,9 +40,47 @@ set-build-options-from-command-line set-build-options-from-command-line* show-build-options-help - + maybe-build + build-package guix-build)) =20 +;; XXX This procedure does not belong this module: it is used by +;; 'build-package' and (guix scripts system). +(define* (maybe-build drvs + #:key dry-run? use-substitutes?) + "Show what will/would be built, and actually build DRVS, unless DRY-RUN?= is +true." + (with-monad %store-monad + (>>=3D (show-what-to-build* drvs + #:dry-run? dry-run? + #:use-substitutes? use-substitutes?) + (lambda (_) + (if dry-run? + (return #f) + (built-derivations drvs)))))) + +;; XXX This procedure does not belong this module, but currently there +;; is no better place for it. It is used by Emacs development tools +;; ("emacs/guix-devel.el"). +(define* (build-package package + #:key (use-substitutes? #t) (dry-run? #f) + #:allow-other-keys + #:rest build-options) + "Build PACKAGE using BUILD-OPTIONS. +Show what and how will/would be built." + (with-store store + (run-with-store store + (mbegin %store-monad + (apply set-build-options* + #:use-substitutes? use-substitutes? + (strip-keyword-arguments '(#:dry-run?) build-options)) + (mlet %store-monad ((derivation (package->derivation package))) + (mbegin %store-monad + (maybe-build (list derivation) + #:use-substitutes? use-substitutes? + #:dry-run? dry-run?) + (return (show-derivation-outputs derivation)))))))) + (define (register-root store paths root) "Register ROOT as an indirect GC root for all of PATHS." (let* ((root (string-append (canonicalize-path (dirname root)) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 45f5982..0db4953 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -298,19 +298,6 @@ it atomically, and then run OS's activation script." ((disk-image) (system-disk-image os #:disk-image-size image-size)))) =20 -(define* (maybe-build drvs - #:key dry-run? use-substitutes?) - "Show what will/would be built, and actually build DRVS, unless DRY-RUN?= is -true." - (with-monad %store-monad - (>>=3D (show-what-to-build* drvs - #:dry-run? dry-run? - #:use-substitutes? use-substitutes?) - (lambda (_) - (if dry-run? - (return #f) - (built-derivations drvs)))))) - (define* (perform-action action os #:key grub? dry-run? use-substitutes? device target --=20 2.5.0 --=-=-=--