From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH 6/7] guix build: Add 'build-package'. Date: Fri, 18 Sep 2015 21:51:36 +0300 Message-ID: <87fv2bh87b.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> <87bndfx6l1.fsf@gmail.com> <87io7ku0ys.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd0l3-0000NE-H8 for guix-devel@gnu.org; Fri, 18 Sep 2015 14:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zd0ky-0002AT-0s for guix-devel@gnu.org; Fri, 18 Sep 2015 14:51:41 -0400 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-09-08 23:10 +0300) wrote: > Alex Kost skribis: [...] >> 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. > > [...] > >> +(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* > > Please remove =E2=80=98with-store=E2=80=99 and =E2=80=98run-with-store=E2= =80=99. This should be done on > the Emacs side (maybe via the ,run-in-store meta-command?). Sure, ",run-in-store" sounds great. I have pushed the patches for adding (guix scripts), 'set-build-options*' and 'show-derivation-outputs', so the attached patch (for adding 'build-package') is applied cleanly to master. 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: >> >>> 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.) So I suppose this comment is not needed anymore (right?) as 'build-package' will beplaced in (guix scripts), and it looks like a rather general procedure. For example, it may be used for something like =E2=80=98guix build --package-from-file=E2=80=99 suggested by David: . --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-scripts-Add-build-package.patch Content-Transfer-Encoding: quoted-printable >From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 23 Jul 2015 16:16:41 +0300 Subject: [PATCH] scripts: 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.scm: ...here. (build-package): New procedure. Co-authored-by: Ludovic Court=C3=A8s --- guix/scripts.scm | 39 ++++++++++++++++++++++++++++++++++++++- guix/scripts/system.scm | 13 ------------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/guix/scripts.scm b/guix/scripts.scm index 6bb3e21..e34d389 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2013, 2014, 2015 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014 Deck Pickard +;;; Copyright =C2=A9 2015 Alex Kost ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,11 +21,17 @@ (define-module (guix scripts) #:use-module (guix utils) #:use-module (guix ui) + #:use-module (guix store) + #:use-module (guix monads) + #:use-module (guix packages) + #:use-module (guix derivations) #:use-module (srfi srfi-1) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:export (args-fold* - parse-command-line)) + parse-command-line + maybe-build + build-package)) =20 ;;; Commentary: ;;; @@ -78,4 +85,34 @@ parameter of 'args-fold'." ;; ARGS take precedence over what the environment variable specifies. (parse-options-from args seeds)))) =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* (build-package package + #:key dry-run? (use-substitutes? #t) + #:allow-other-keys + #:rest build-options) + "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'. +Show what and how will/would be built." + (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)))))) + ;;; scripts.scm ends here diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 32d4057..5e2d226 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -299,19 +299,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 --=-=-=--