unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 36578@debbugs.gnu.org
Subject: [bug#36578] [PATCH 7/9] derivations: Deprecate the previous calling convention.
Date: Wed, 10 Jul 2019 19:11:26 +0200	[thread overview]
Message-ID: <20190710171128.21568-7-ludo@gnu.org> (raw)
In-Reply-To: <20190710171128.21568-1-ludo@gnu.org>

We will eventually require #:inputs to be a list of <derivation-input>;
store items will have to be passed as #:sources, already interned.

* guix/derivations.scm (warn-about-derivation-deprecation): New procedure.
(derivation): Add #:%deprecation-warning? parameter.
[warn-deprecation]: New macro.
[input->derivation-input, input->source]: Use it.
(build-expression->derivation): Pass #:%deprecation-warning?.
* po/guix/POTFILES.in: Add guix/derivations.scm.
---
 guix/derivations.scm | 27 +++++++++++++++++++++++++--
 po/guix/POTFILES.in  |  1 +
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index a18478502d..23d058e832 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -36,6 +36,8 @@
   #:use-module (guix memoization)
   #:use-module (guix combinators)
   #:use-module (guix deprecation)
+  #:use-module (guix diagnostics)
+  #:use-module (guix i18n)
   #:use-module (guix monads)
   #:use-module (gcrypt hash)
   #:use-module (guix base32)
@@ -705,6 +707,13 @@ name of each input with that input's hash."
        ;; character.
        (sha256 (derivation->bytevector (derivation/masked-inputs drv)))))))
 
+
+(define (warn-about-derivation-deprecation name)
+  ;; TRANSLATORS: 'derivation' must not be translated; it refers to the
+  ;; 'derivation' procedure.
+  (warning (G_ "in '~a': deprecated 'derivation' calling convention used~%")
+           name))
+
 (define* (derivation store name builder args
                      #:key
                      (system (%current-system)) (env-vars '())
@@ -715,7 +724,8 @@ name of each input with that input's hash."
                      allowed-references disallowed-references
                      leaked-env-vars local-build?
                      (substitutable? #t)
-                     (properties '()))
+                     (properties '())
+                     (%deprecation-warning? #t))
   "Build a derivation with the given arguments, and return the resulting
 <derivation> object.  When HASH and HASH-ALGO are given, a
 fixed-output derivation is created---i.e., one whose result is known in
@@ -832,19 +842,28 @@ derivation.  It is kept as-is, uninterpreted, in the derivation."
             e
             outputs)))
 
+  (define-syntax-rule (warn-deprecation name)
+    (when %deprecation-warning?
+      (warn-about-derivation-deprecation name)))
+
   (define input->derivation-input
     (match-lambda
       ((? derivation-input? input)
        input)
       (((? derivation? drv))
+       (warn-deprecation name)
        (make-derivation-input drv '("out")))
       (((? derivation? drv) sub-drvs ...)
+       (warn-deprecation name)
        (make-derivation-input drv sub-drvs))
-      (_ #f)))
+      (_
+       (warn-deprecation name)
+       #f)))
 
   (define input->source
     (match-lambda
       (((? string? input) . _)
+       (warn-deprecation name)
        (if (direct-store-path? input)
            input
            (add-to-store store (basename input)
@@ -1320,6 +1339,10 @@ and PROPERTIES."
                   ,@(if mod-dir `("-L" ,mod-dir) '())
                   ,builder)
 
+                ;; 'build-expression->derivation' is somewhat deprecated so
+                ;; don't bother warning here.
+                #:%deprecation-warning? #f
+
                 #:system system
 
                 #:inputs `((,(or guile-for-build (%guile-for-build)))
diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in
index f5fc4956b4..ad06ebce95 100644
--- a/po/guix/POTFILES.in
+++ b/po/guix/POTFILES.in
@@ -80,6 +80,7 @@ guix/channels.scm
 guix/profiles.scm
 guix/git.scm
 guix/deprecation.scm
+guix/derivations.scm
 gnu/build/bootloader.scm
 nix/nix-daemon/guix-daemon.cc
 
-- 
2.22.0

  parent reply	other threads:[~2019-07-10 17:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10 17:04 [bug#36578] [PATCH 0/9] Modernize the API of the 'derivation' primitive Ludovic Courtès
2019-07-10 17:11 ` [bug#36578] [PATCH 1/9] derivations: 'derivation' primitive accepts <derivation> and #:sources Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 2/9] gexp: <lowered-gexp> separates sources from derivation inputs Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 3/9] gnu: guile-bootstrap: Use the new 'derivation' calling convention Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 4/9] download: " Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 5/9] derivations: 'map-derivation' uses " Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 6/9] derivations: Update tests to use new " Ludovic Courtès
2019-07-10 17:11   ` Ludovic Courtès [this message]
2019-07-10 17:11   ` [bug#36578] [PATCH 8/9] gexp: 'lowered-gexp-guile' now returns a <derivation-input> Ludovic Courtès
2019-07-10 17:11   ` [bug#36578] [PATCH 9/9] channels: Avoid use of 'derivation-input-path' Ludovic Courtès
2019-07-15  8:46 ` bug#36578: [PATCH 0/9] Modernize the API of the 'derivation' primitive Ludovic Courtès

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=20190710171128.21568-7-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=36578@debbugs.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).