From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8O9iHOIKZmW1cgAA9RJhRA:P1 (envelope-from ) for ; Tue, 28 Nov 2023 16:44:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8O9iHOIKZmW1cgAA9RJhRA (envelope-from ) for ; Tue, 28 Nov 2023 16:44:34 +0100 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 47AC644567 for ; Tue, 28 Nov 2023 16:44:34 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=TrhTusqZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701186274; a=rsa-sha256; cv=none; b=et2+RNDZ0OAKoTvcqe3CBnP7sfyvxorH0OsT52ktasVwCb15bGIrx38O8k3EcYYHYthQBj wwEnRv7Cv2H1A+DInw0CyvhCAK/DU3dKXfqD82oCGC8kObn0Ls7DNl2zdSQGgJievnY9BK uvLxZzshipOMxEmO+VZB5/i/PZoco9H0gNSGc7zHiBwqMDAQuW0QTkmSpdSlHEavjLLXZQ TlWBsQIdWPsLrRNhTymmzuwzMr7Sh5EbYNUz/QHZOQGWdFkpYR69p9WDMtHHmSHjJi4nRn MslOaLm2s6D8QYkFDQcEIu7vzPFViPOBcWPDN4bMIjZNrIEf4wPxmxQ+jogVYQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=TrhTusqZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701186274; 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=saJE5VVliHJ1hPtIIx8r3WsNRttuKDFvbUq2AsI8d3I=; b=iGwvSBiunsYIxxFwJ5U0U/ulgr64kTQCJLI2ikh8D96r+TISd7OcFwrAGLqq8SbU5T+cos mtUbH9ECMVXHWs3rsub6B5LiaddjwAydAg7KwfbB4um4W+bRTRVqdZaouOonxRgPAHOPGk pZsW51l9ESsQLcw7U+y58rwRjI+E2J6Lj5+XFChWGyer4kB3N2CLpSIsSfwYNokv5jAlCH XKFFfTPhSTQJ9mIFU4Teo8U/z/FN+YZaU80h47nh3CWL2VrMY6QoEvy6HtYfKOIT1udn1I S0N8i7pTv4x3faxrfz3H1Noo39gNhgycYrHnhwV767C8SsFncJOSEXF1fPufiQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r80Fk-0003E6-Dx; Tue, 28 Nov 2023 10:44:00 -0500 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 1r80Fj-00038Z-1u for guix-patches@gnu.org; Tue, 28 Nov 2023 10:43:59 -0500 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 1r80Fi-0006IW-Oc for guix-patches@gnu.org; Tue, 28 Nov 2023 10:43:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r80Fp-0001dF-LH for guix-patches@gnu.org; Tue, 28 Nov 2023 10:44:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Nov 2023 15:44:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67489 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 67489@debbugs.gnu.org Cc: Josselin Poiret , Mathieu Othacehe , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Tobias Geerinckx-Rice , Ricardo Wurmus , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines Received: via spool by 67489-submit@debbugs.gnu.org id=B67489.17011861896079 (code B ref 67489); Tue, 28 Nov 2023 15:44:05 +0000 Received: (at 67489) by debbugs.gnu.org; 28 Nov 2023 15:43:09 +0000 Received: from localhost ([127.0.0.1]:47450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80Ev-0001Zx-8K for submit@debbugs.gnu.org; Tue, 28 Nov 2023 10:43:09 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:38255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80Ep-0001Yx-SL for 67489@debbugs.gnu.org; Tue, 28 Nov 2023 10:43:07 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b3febbce3so4031825e9.1 for <67489@debbugs.gnu.org>; Tue, 28 Nov 2023 07:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701186171; x=1701790971; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=saJE5VVliHJ1hPtIIx8r3WsNRttuKDFvbUq2AsI8d3I=; b=TrhTusqZPr6OtcOKklm8StqDRk3+4C6L59iukpMmmUjX/TIo1vg16urazAHRWNJr35 aSwEVwPydLdzMYgSfb7fQJW8LS3qy/KWAwpNX7NUuO6OHmBzv5Szoj+7Bn8hiI1bDN27 412cyVod8CuEgMfqE1QXD0Tly2BQb4pyPJ9BLjaXsy3rtujpRV7muFg7nxM8QlvFoYi6 sVURALLDfq/6tx4SRvdPZ1cSay/0b8vwvfvyxp+N539rssOeEz2PYKIaArhJeAagisJt 24T3VhX4LbPTZp4Vn3b6abhFvXhyR8C9bc75sUU8xI+6/jTlLXGlYfcPHOiZxGol4NJA 35Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701186171; x=1701790971; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=saJE5VVliHJ1hPtIIx8r3WsNRttuKDFvbUq2AsI8d3I=; b=LPMT8quz7C9YfEtNe8dvjrqJwwU3/goQ9KCm5Ker+ppgxsPrnDawIt55sPv4nhrDhn KnRftB808IlJ/Q0sTNrUJqXn33a67GmQh+p0xFHW6QARNdGyL3SyfGAEMI0KXInrQ7D4 b+2AR2P0Xa111XNHCcYppiJhauvk7X4bZei3GPc29KffcmnBw9KTAbndiUoVO2YCkQ+q 59y0KeGdWY/9O6nm5DVimVdoZG2qFoAr+4Yfd2fTQObvVCWlDFptQAPq+DPEbQ8GcJcL GQ52in19T2vFdncpiyH1YnzKH9y8eCJglurv4+/kl3LlJFsYTy9Q760BLQfU1No9qs7A YXvw== X-Gm-Message-State: AOJu0YyMvpC2SN8sPLmY8sKJKYB9aJFX0Y8DyyT5poZJh4ihoBWkFrkw 2Ns7pCE2u328l+fCnEiiOz8= X-Google-Smtp-Source: AGHT+IFvAAZS9zl93DEILSgvtTz8NxM8TJeVoZg9XRDI1RINHoJYHPORhbMNjg1iPnxwZpTQXenAUg== X-Received: by 2002:adf:fccb:0:b0:332:fb6a:6206 with SMTP id f11-20020adffccb000000b00332fb6a6206mr5204300wrs.2.1701186170618; Tue, 28 Nov 2023 07:42:50 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id v5-20020a5d6105000000b0032f7fab0712sm15245883wrt.52.2023.11.28.07.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:42:50 -0800 (PST) From: Simon Tournier In-Reply-To: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> References: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> Date: Tue, 28 Nov 2023 11:49:39 +0100 Message-ID: <87a5qycfuk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 2.86 X-Spam-Score: 2.86 X-Migadu-Queue-Id: 47AC644567 X-TUID: dfzK4zfgl3aD Hi, TLDR: All LGTM. :-) Minor comments. On Mon, 27 Nov 2023 at 18:19, Ludovic Court=C3=A8s wrote: > Someone recently suggested we should have better debugging facilities > for packagers, in particular when dealing with package variants, > inheritance, and so on, which make it harder to understand what=E2=80=99s > going on. >From a quick test: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,phases cava $1 =3D (modify-phases %standard-phases (replace 'bootstrap (lambda _ (setenv "HOME" (getcwd)) (invoke "sh" "autogen.sh"))) (add-before 'build 'make-cava-ldflags (lambda _ (mkdir-p (string-append ((@ (guile) getenv) "out") "/lib")))) (add-after 'install 'data (lambda _ (for-each (lambda (file) (install-file file (string-append ((@ (guile) getenv) "out") "/share/doc/examples"))) (find-files "example_files"))))) scheme@(guix-user)> ,configure-flags cava $2 =3D (list (string-append "PREFIX=3D" ((@ (guile) getenv) "out")) (string-append "FONT_DIR=3D" ((@ (guile) getenv) "out") "/share/consolefonts")) --8<---------------cut here---------------end--------------->8--- Cool! Very helpful. Much better than, something like: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,pp (cdr (memq #:phases (package-arguments cava))) $3 =3D (# "/lib")))) (add-after (quote install) (quote data) (lambd= a _ (for-each (lambda (file) (install-file file (string-append # "/share/doc/examples"))) (find-files "example_files"))))) gnu/packag= es/audio.scm:5161:11 7f7258403a50>) --8<---------------cut here---------------end--------------->8--- Without drifting, why not the meta-command ,arguments? For example, the package could also have other specific keywords that maybe I would like to inspect from the REPL. For example, some packages have their own keywords as #:julia-package-name. Well, package-arguments partially does the job: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,pp (package-arguments julia-uris) $5 =3D (#:julia-package-name "URIs" #:julia-package-uuid "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" #:phases #) --8<---------------cut here---------------end--------------->8--- Other said, it could be nice to: 1. pretty-print package-arguments by default, 2. and compile the G-expressions. Hence ,arguments. :-) > +As a packager, you may be willing to inspect the build phases or flags > +of a given package; this is particularly useful when relying a lot on > +inheritance to define package variants (@pxref{Defining Package > +Variants}) or when package arguments are a result of some computation, > +both of which can make it harder to foresee what ends up in the package > +arguments. Additional commands let you inspect those package arguments: > + > +@example > +scheme@@(guix-user)> ,phases grep > +$1 =3D (modify-phases %standard-phases > + (add-after 'install 'fix-egrep-and-fgrep > + (lambda* (#:key outputs #:allow-other-keys) > + (let* ((out (assoc-ref outputs "out")) > + (bin (string-append out "/bin"))) > + (substitute* (list (string-append bin "/egrep") > + (string-append bin "/fgrep")) > + (("^exec grep") > + (string-append "exec " bin "/grep"))))))) > +scheme@@(guix-user)> ,configure-flags findutils > +$2 =3D (list "--localstatedir=3D/var") > +scheme@@(guix-user)> ,make-flags binutils > +$3 =3D '("MAKEINFO=3Dtrue") > +@end example > + Here all is clear. What can be confusing is the expansion of #$output as ((@ (guile) getenv) "out"). Maybe it could be worth to document this under G-expression section. Or provide a similar example using G-expression under the section G-expression. Well, that=E2=80=99s unrelated to this patch and could be done separately. = :-) > ;;; GNU Guix --- Functional package management for GNU > -;;; Copyright =C2=A9 2014, 2015, 2016, 2022 Ludovic Court=C3=A8s > +;;; Copyright =C2=A9 2014-2016, 2022-2023 Ludovic Court=C3=A8s > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -21,13 +21,15 @@ (define-module (guix monad-repl) > #:use-module (guix monads) > #:use-module (guix utils) > #:use-module (guix packages) > + #:autoload (guix build-system) (bag) > #:use-module (guix status) > - #:autoload (guix gexp) (lower-object) > + #:autoload (guix gexp) (gexp gexp? lower-gexp lowered-gexp-sexp lowe= r-object) > #:use-module ((guix derivations) > #:select (derivation? > derivation->output-paths built-derivations)) > + #:autoload (guix read-print) (pretty-print-with-comments) > #:use-module (ice-9 match) > - #:use-module (ice-9 pretty-print) > + #:autoload (ice-9 pretty-print) (pretty-print) Out of curiosity, what is the advantage for #:autoload versus #:use-module + #:select? > +(define (keyword-argument-value args keyword default) > + "Return the value associated with KEYWORD in ARGS, a keyword/value seq= uence, > +or DEFAULT if KEYWORD is missing from ARGS." > + (let loop ((args args)) > + (match args > + (() > + default) > + ((kw value rest ...) > + (if (eq? kw keyword) > + value > + (loop rest)))))) ( Aside. Each time, I am surprised that common helpers are not Guile builtins, here for extracting keyword value. It would help Guile to provide such builtin, by default or via some ice-9 module. My 2 cents. ;-) ) Cheers, simon