unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Sarah Morgensen <iskarian@mgsn.dev>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 49531@debbugs.gnu.org, Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
Date: Wed, 21 Jul 2021 00:50:53 -0700	[thread overview]
Message-ID: <864kcot89u.fsf_-_@mgsn.dev> (raw)
In-Reply-To: <87lf60isie.fsf_-_@gnu.org> ("Ludovic Courtès"'s message of "Tue, 20 Jul 2021 23:29:13 +0200")

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

Hi all,

Ludovic Courtès <ludo@gnu.org> writes:

> And then, how do we handle the transition?  I’m not enthusiastic about
> customizing ‘guix style’ for Rust packages; should we embark on manual
> changes of the 2.4K Rust packages?

I've attached a patch below that's a first pass at handling
#:cargo-inputs in `guix style`. I didn't handle any input modification
shenanigans, but I don't think any packages do that with #:cargo-inputs
& co., or if so it's just a few which can be manually updated.

The result of running it on #:cargo-inputs/#:cargo-development-inputs
packages:

14 files changed, 9424 insertions(+), 12009 deletions(-)
gnu/packages/crates-graphics.scm |  1006 +--
gnu/packages/crates-gtk.scm      |   658 +-
gnu/packages/crates-io.scm       | 17471 ++++++++++++++++---------------------
gnu/packages/crypto.scm          |     4 +-
gnu/packages/gnome.scm           |    90 +-
gnu/packages/rust-apps.scm       |   672 +-
gnu/packages/security-token.scm  |    30 +-
gnu/packages/sequoia.scm         |   124 +-
gnu/packages/shells.scm          |  1088 ++-
gnu/packages/syndication.scm     |    38 +-
gnu/packages/terminals.scm       |    50 +-
gnu/packages/text-editors.scm    |    60 +-
gnu/packages/video.scm           |   100 +-
gnu/packages/web.scm             |    42 +-

--
Sarah


[-- Attachment #2: handle-cargo-inputs.patch --]
[-- Type: text/x-patch, Size: 5400 bytes --]

diff --git a/guix/packages.scm b/guix/packages.scm
index d3fa72fd09..26e82050f8 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,7 @@
             package-superseded
             deprecated-package
             package-field-location
+            package-argument-location
 
             this-package-input
             this-package-native-input
@@ -515,9 +516,9 @@ object."
     (name old-name)
     (properties `((superseded . ,p)))))
 
-(define (package-field-location package field)
-  "Return the source code location of the definition of FIELD for PACKAGE, or
-#f if it could not be determined."
+(define (package-part-location package proc)
+  "Return the source code location of the part of PACKAGE returned by (PROC
+PACKAGE), or #f if it could not be determined."
   (match (package-location package)
     (($ <location> file line column)
      (match (search-path %load-path file)
@@ -530,17 +531,16 @@ object."
                 (go-to-location port line column)
                 (match (read port)
                   (('package inits ...)
-                   (let ((field (assoc field inits)))
-                     (match field
-                       ((_ value)
-                        (let ((loc (and=> (source-properties value)
-                                          source-properties->location)))
-                          (and loc
-                               ;; Preserve the original file name, which may be a
-                               ;; relative file name.
-                               (set-field loc (location-file) file))))
-                       (_
-                        #f))))
+                   (match (proc inits)
+                     (#f
+                      #f)
+                     (value
+                      (let ((loc (and=> (source-properties value)
+                                        source-properties->location)))
+                        (and loc
+                             ;; Preserve the original file name, which may be a
+                             ;; relative file name.
+                             (set-field loc (location-file) file))))))
                   (_
                    #f)))))
           (lambda _
@@ -550,6 +550,29 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-field-location package field)
+  "Return the source code location of the definition of FIELD for PACKAGE, or
+#f if it could not be determined."
+  (package-part-location
+   package
+   (lambda (p)
+     (match (assoc field p)
+       ((_ value) value)
+       (_ #f)))))
+
+(define (package-argument-location package argument)
+  "Return the source code location of the definition of keyword ARGUMENT for
+PACKAGE, or #f if it could not be determined."
+  (package-part-location
+   package
+   (lambda (p)
+     (match (assoc 'arguments p)
+       ((_ ('quasiquote (arguments ..1)))
+        (match (member argument arguments eq?)
+          ((_ value . _) value)
+          (_ #f)))
+       (_ #f)))))
+
 (define (package-input package name)
   "Return the package input NAME of PACKAGE--i.e., an input
 from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 3c100197a7..19185d924e 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -371,7 +371,7 @@ bailing out~%")
                           (delete ,@to-delete)
                           (prepend ,@things)))
         (location-column location))))
-    (('quasiquote (exp ...))
+    ((or ('quasiquote (exp ...)) ((or (exp ...) (? comment? exp)) ...))
      (let/ec return
        (object->string*
         `(list ,@(simplify-expressions exp inputs return))
@@ -389,6 +389,33 @@ POLICY is a symbol that defines whether to simplify inputs; it can one of
 'silent (change only if the resulting derivation is the same), 'safe (change
 only if semantics are known to be unaffected), and 'always (fearlessly
 simplify inputs!)."
+  (define (package-argument package argument)
+    (match (member argument (package-arguments package) eq?)
+      ((_ value . _) value)
+      (_ #f)))
+
+  ;; We know that the cargo build system does not use its special input labels,
+  ;; so it is always safe to simplify, but it will change the derivation. Only
+  ;; proceed if POLICY is 'safe or 'always.
+  (when (member policy '(safe always))
+    (for-each (lambda (argument)
+                (match (package-argument package argument)
+                  (#f
+                   #f)
+                  (inputs
+                   (match (package-argument-location package argument)
+                     (#f
+                      #f)
+                     (location
+                      (edit-expression
+                       (location->source-properties location)
+                       (lambda (str)
+                         (simplify-inputs location
+                                          (package-name package)
+                                          str inputs
+                                          #:label-matches? (const #t)))))))))
+              (list #:cargo-inputs #:cargo-development-inputs)))
+
   (for-each (lambda (field-name field)
               (match (field package)
                 (()

  reply	other threads:[~2021-07-21  8:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
2021-07-20 21:22   ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: " Ludovic Courtès
2021-07-20 21:36     ` Ludovic Courtès
2021-07-21  3:03       ` Sarah Morgensen
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 2/4] import: go: " Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 3/4] import: crate: " Sarah Morgensen via Guix-patches via
2021-07-12 14:41   ` [bug#49531] [PATCH core-updates v2 " Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept " Sarah Morgensen via Guix-patches via
2021-07-20 21:29   ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Ludovic Courtès
2021-07-21  7:50     ` Sarah Morgensen [this message]
2021-07-22  6:44     ` Efraim Flashner
2024-01-20 21:06       ` bug#49531: " Maxim Cournoyer
2021-07-21  2:59 ` [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs Sarah Morgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=864kcot89u.fsf_-_@mgsn.dev \
    --to=iskarian@mgsn.dev \
    --cc=49531@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).