From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d60kp-0006jg-K1 for guix-patches@gnu.org; Wed, 03 May 2017 16:20:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d60kk-0002cy-K1 for guix-patches@gnu.org; Wed, 03 May 2017 16:20:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:55030) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d60kk-0002cr-H8 for guix-patches@gnu.org; Wed, 03 May 2017 16:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d60kk-0004G8-8r for guix-patches@gnu.org; Wed, 03 May 2017 16:20:02 -0400 Subject: bug#26645: [PATCH 1/9] guix: Add "potluck" packages. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87y3upttm7.fsf@pobox.com> <20170424205923.27726-1-wingo@igalia.com> Date: Wed, 03 May 2017 22:19:34 +0200 In-Reply-To: <20170424205923.27726-1-wingo@igalia.com> (Andy Wingo's message of "Mon, 24 Apr 2017 22:59:15 +0200") Message-ID: <87efw5r8vd.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Andy Wingo Cc: 26645@debbugs.gnu.org Hi! Finally some review for all these exciting bits! :-) Andy Wingo skribis: > * guix/potluck/build-systems.scm: > * guix/potluck/licenses.scm: > * guix/potluck/packages.scm: New files. > * guix/scripts/build.scm (load-package-or-derivation-from-file): > (options->things-to-build, options->derivations): Add "potluck-package" a= nd > "potluck-source" to environment of file. Lower potluck packages to Guix > packages. [...] > +(define-module (guix potluck build-systems) > + #:use-module ((guix build-system) #:select (build-system?)) > + #:use-module ((gnu packages) #:select (scheme-modules)) > + #:use-module (ice-9 match) > + #:export (build-system-by-name all-potluck-build-system-names)) > + > +(define all-build-systems > + (delay > + (let* ((gbs (or (search-path %load-path "guix/build-system.scm") > + (error "can't find (guix build-system)"))) > + (root (dirname (dirname gbs))) > + (by-name (make-hash-table))) > + (for-each (lambda (iface) > + (module-for-each > + (lambda (k var) > + (let* ((str (symbol->string k)) > + (pos (string-contains str "-build-system")) > + (val (variable-ref var))) > + (when (and pos (build-system? val)) > + (let* ((head (substring str 0 pos)) > + (tail (substring str > + (+ pos (string-length > + "-build-system"= )))) > + (name (string->symbol > + (string-append head tail)))) > + (hashq-set! by-name name val))))) > + iface)) > + (scheme-modules root "guix/build-system")) > + by-name))) What about adding a =E2=80=98lookup-build-system=E2=80=99 procedure in (guix build-systems) directly that would reuse the logic from =E2=80=98fold-packa= ges=E2=80=99 and co.? That would avoid repetition. I can move the relevant bits to (guix plugins) or (guix discovery), which should help, WDYT? > +(define-module (guix potluck licenses) > + #:use-module ((guix licenses) #:select (license?)) > + #:use-module (ice-9 match) > + #:export (license-by-name all-potluck-license-names)) > + > +(define all-licenses > + (delay > + (let ((iface (resolve-interface '(guix licenses))) > + (by-name (make-hash-table))) > + (module-for-each (lambda (k var) > + (let ((val (variable-ref var))) > + (when (license? val) > + (hashq-set! by-name k val)))) > + (resolve-interface '(guix licenses))) > + by-name))) Likewise here. > +(define-module (guix potluck packages) Nice! > +(define (potluck-package-field-location package field) > + "Return the source code location of the definition of FIELD for PACKAG= E, or > +#f if it could not be determined." > + (define (goto port line column) > + (unless (and (=3D (port-column port) (- column 1)) > + (=3D (port-line port) (- line 1))) > + (unless (eof-object? (read-char port)) > + (goto port line column)))) > + > + (match (potluck-package-location package) > + (($ file line column) > + (catch 'system > + (lambda () > + ;; In general we want to keep relative file names for modules. > + (with-fluids ((%file-port-name-canonicalization 'relative)) > + (call-with-input-file (search-path %load-path file) > + (lambda (port) > + (goto port line column) > + (match (read port) > + (('potluck-package inits ...) Can we factorize it with =E2=80=98package-field-location=E2=80=99? In fact= , it looks like we could extract: (define (sexp-location start-location car) "Return the location of the sexp with the given CAR, starting from START-LOCATION." =E2=80=A6) and define both =E2=80=98package-field-location=E2=80=99 and =E2=80=98potluck-package-field-location=E2=80=99 in terms of it. Thoughts? > +(define (lower-potluck-package pkg) > + (validate-potluck-package pkg) > + (let ((name (potluck-package-name pkg)) > + (version (potluck-package-version pkg)) > + (source (potluck-package-source pkg)) > + (build-system (potluck-package-build-system pkg)) > + (inputs (potluck-package-inputs pkg)) > + (native-inputs (potluck-package-native-inputs pkg)) > + (propagated-inputs (potluck-package-propagated-inputs pkg)) > + (arguments (potluck-package-arguments pkg)) > + (home-page (potluck-package-home-page pkg)) > + (synopsis (potluck-package-synopsis pkg)) > + (description (potluck-package-description pkg)) > + (license (potluck-package-license pkg))) > + (package > + (name name) > + (version version) > + (source (lower-potluck-source source)) > + (build-system (build-system-by-name build-system)) > + (inputs (lower-inputs inputs)) > + (native-inputs (lower-inputs native-inputs)) > + (propagated-inputs (lower-inputs propagated-inputs)) > + (arguments arguments) > + (home-page home-page) > + (synopsis synopsis) > + (description description) > + (license (license-by-name license))))) Could you add a couple of tests for this? > diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm > index 6bb1f72eb..be26f63c9 100644 > --- a/guix/scripts/build.scm > +++ b/guix/scripts/build.scm I=E2=80=99d move this part to a separate patch. As discussed on IRC I think, I was wondering whether it would make sense to have a =E2=80=98guix potluck build=E2=80=99 command instead. Normally, = use =E2=80=98%standard-build-options=E2=80=99 and =E2=80=98set-build-options-fr= om-command-line=E2=80=99 from (guix scripts build), there should be little duplication, I think. That would avoid entangling potluck and =E2=80=98guix build=E2=80=99 too much. Could you check if that=E2=80=99s doable? If it turns out it=E2=80=99s too inconvenient, then we can take the approach here. Thank you! Ludo=E2=80=99.