unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Leo Famulari <leo@famulari.name>
Cc: 28659@debbugs.gnu.org
Subject: bug#28659: v0.13: guix pull fails; libgit2-0.26.0 and 0.25.1 content hashes fail
Date: Thu, 14 Dec 2017 17:53:37 +0100	[thread overview]
Message-ID: <874lot9rou.fsf@gnu.org> (raw)
In-Reply-To: <87d1421qek.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 28 Nov 2017 14:30:59 +0100")

ludo@gnu.org (Ludovic Courtès) skribis:

> Thinking more about it, why not simply always enable substitutes for
> fixed-output derivations, like this:
>
> diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
> index d68e8b2bc..03a8f5080 100644
> --- a/nix/libstore/build.cc
> +++ b/nix/libstore/build.cc
> @@ -1034,8 +1034,10 @@ void DerivationGoal::haveDerivation()
>  
>      /* We are first going to try to create the invalid output paths
>         through substitutes.  If that doesn't work, we'll build
> -       them. */
> -    if (settings.useSubstitutes && substitutesAllowed(drv))
> +       them.  Always enable substitutes for fixed-output derivations to
> +       protect against disappearing files and in-place modifications on
> +       upstream sites.  */
> +    if ((fixedOutput || settings.useSubstitutes) && substitutesAllowed(drv))
>          foreach (PathSet::iterator, i, invalidOutputs)
>              addWaitee(worker.makeSubstitutionGoal(*i, buildMode == bmRepair));

[...]

> The downside is that it still requires one to authorize the server’s
> key, although it’s in theory unnecessary since it’s content addressed.
> I’m not sure how to solve that because ‘guix substitute’ doesn’t know
> that it’s substituting a fixed-output derivation.  I suppose we’d need
> to modify the “protocol” between guix-daemon and ‘guix substitute’.

I looked at how to address this by having ‘guix substitute’
automatically determine whether it’s being asked for a content-addressed
item or not.  The guts of it is this procedure:

  (define* (content-addressed-item? item hash
                                    #:key (hash-algo 'sha256))
    "Return true if ITEM, a store file name, is definitely a content-addressed
  item (result of a fixed-output derivation) with the given HASH of type
  HASH-ALGO, false otherwise.

  Note: This procedure is useful when the deriver of ITEM is unknown.  In other
  cases, the recommended approach is to check 'fixed-output-derivation?' on the
  deriver."
    ;; XXX: This returns #f for "text" items produced by 'add-text-to-store'.
    ;; There's not much we can do because the file name for these is a function
    ;; of their content.
    (let ((name (store-path-package-name item)))
      (or (string=? item (fixed-output-path name hash #:recursive? #f
                                            #:hash-algo hash-algo))
          (string=? item (fixed-output-path name hash #:recursive? #t
                                            #:hash-algo hash-algo)))))

It works as expected for the result of “recursive fixed-output
derivations”—i.e., fixed-output derivations that produce a directory,
such as VCS checkouts.

However it doesn’t work for fixed-output derivations that produce a flat
file, such as origins with the ‘url-fetch’ method.  The reason is
because in the case of non-recursive derivations, the store file name is
computed as a function of the file hash, not as a function of the nar
hash, whereas narinfos only contains the nar hash (the thing that ‘guix
hash -r’ computes.)

So I think we have to communicate more info from the daemon to ‘guix
substitute’.

Ludo’.

  reply	other threads:[~2017-12-14 16:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-01 10:16 bug#28659: v0.13: guix pull fails; libgit2-0.26.0 and 0.25.1 content hashes fail Jan Nieuwenhuizen
2017-10-01 19:20 ` Jan Nieuwenhuizen
2017-10-01 20:42   ` Leo Famulari
2017-10-01 21:05     ` ng0
2017-10-02 14:57     ` Ludovic Courtès
2017-10-02 18:19       ` Leo Famulari
2017-10-02 22:47         ` Maxim Cournoyer
2017-10-03 12:31           ` Ludovic Courtès
2017-10-03 14:24           ` Leo Famulari
2017-10-04  4:22             ` Maxim Cournoyer
2017-10-04 16:54               ` Leo Famulari
2017-10-04 23:53                 ` Maxim Cournoyer
2017-10-05  4:52                   ` Maxim Cournoyer
2017-10-05  6:08                     ` Jan Nieuwenhuizen
2017-10-02 15:09 ` Ludovic Courtès
2017-10-02 17:05   ` Jan Nieuwenhuizen
2017-10-02 18:22   ` Leo Famulari
2017-10-02 20:00     ` Ludovic Courtès
2017-10-02 20:22       ` Jan Nieuwenhuizen
2017-10-02 20:29         ` Leo Famulari
2017-10-03 12:30         ` Ludovic Courtès
2017-10-20 21:17       ` Leo Famulari
2017-11-28 13:30         ` Ludovic Courtès
2017-12-14 16:53           ` Ludovic Courtès [this message]
2017-12-15  9:30             ` bug#28659: Always enable substitutes for fixed-output derivations Ludovic Courtès
2022-02-03  2:58               ` bug#28659: Content-addressed mirror is not used upon invalid hash zimoun

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=874lot9rou.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=28659@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /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).