unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Stephen Paul Weber <singpolyma@singpolyma.net>
Cc: guix-devel@gnu.org,  0@psycoti.ca
Subject: Re: git-fetch without a hash
Date: Wed, 21 Dec 2022 23:49:47 +0100	[thread overview]
Message-ID: <87h6xo2wz8.fsf@gnu.org> (raw)
In-Reply-To: <Y6J3vasfRdO+cYgC@singpolyma-beefy.lan> (Stephen Paul Weber's message of "Tue, 20 Dec 2022 22:04:29 -0500")

Hi,

Stephen Paul Weber <singpolyma@singpolyma.net> skribis:

> It seem that url-fetch will work without a hash (that is, with (sha256
> #f)) but git-fetch will not.

(sha256 #f) is not a documented use case.  :-)

> As near as I can tell this is because git-fetch uses a fixed
> derivation build going via nix/build.cc stuff which contains this
> line:
>
> 	if (i.second.hash == "") fixedOutput = false;
>
> And this results in /etc/resolv.conf not getting written and DNS
> resolution failing.
>
> Now, I *think* by my reading that it is intended for *only*
> fixed-output derivations to have network access, because otherwise the
> operation would be impure?

Yes, exactly.

> And then url-fetch is just not actually ending up in a build container
> and so it works even when it isn't fixed-output?

If an origin has (sha256 #f), it is *not* lowered to a fixed-output
derivation; consequently, its build environment lacks network access,
etc.

> However, there's no real reason that git-fetch *needs* to be
> fixed-output in terms of having a hash pre-defined, at least for local
> development and other purposes.  So is there a way around this?

What’s your use case?

If you want a package to refer to, say, the tip of the “main” branch of
some Git repo, then you can:

  • use ‘--with-branch=PKG=main’, or

  • write (package (source (git-checkout …)) …)

Both are actually equivalent.  ‘git-checkout’ represents a checkout made
on the client side, without knowing in advance what you’ll get out of
this checkout.  (So use with care, too.)

> If having a way around it is not desirable should url-fetch consider
> this an error as well?

I’m not sure; do you have an example where it’s not behaving as
expected?

> Finally, *if* git-fetch should not allow this, the current error
> message is beyond confusing (DNS resolution fails during git fetch and
> it tries to fall back to SWH).  So should git-fetch check for hash of
> #f and raise at that point with a better error message in that case?

Ideally, ‘origin’ would prevent a hash of #f altogether.  However, there
are a couple of weird use cases in (gnu packages …) that need to be
supported.  We should probably consider using a different trick there,
such as using a computed-file instead of an origin; we’ll have to check
what’s feasible.

Thanks,
Ludo’.


  reply	other threads:[~2022-12-21 22:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21  3:04 git-fetch without a hash Stephen Paul Weber
2022-12-21 22:49 ` Ludovic Courtès [this message]
2023-01-03 19:31   ` Stephen Paul Weber
2023-01-03 21:34     ` Ludovic Courtès
2023-01-05 10:06       ` Simon Tournier
2023-01-09 11:16         ` Ludovic Courtès
2023-01-11 15:34           ` Simon Tournier
2023-02-05 17:44             ` bokr
2023-02-06 17:01               ` Simon Tournier
2023-01-09 17:13       ` Ludovic Courtès
2023-01-09 17:35         ` Stephen Paul Weber
2023-01-17 16:01           ` 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=87h6xo2wz8.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=0@psycoti.ca \
    --cc=guix-devel@gnu.org \
    --cc=singpolyma@singpolyma.net \
    /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).