[Nix#8993] flake inputs percent-encode URLs where fetchurl and co do not, making some URLs impossible to express in flake inputs #113

Open
opened 2024-03-16 06:44:58 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#8993

Describe the bug

Flake input URLs unconditionally percent-encode their input URLs in ways that fetchurl and co do not, which makes some URLs impossible to express in flake inputs.

Steps To Reproduce

Take the following flake.nix:

{
  inputs = {
    example = {
      url = "https://example.com/foo+bar";
      flake = false;
    };
  };
  outputs = { self, example }: {};
}

Running nix build for this flake produces an error as expected, but in the error we can see the following line:

error: unable to download 'https://example.com/foo%2Bbar': HTTP error 404

(Notice that the plus sign has been replaced with %2B).

If we change the flake to this:

{
  inputs = { };
  outputs = { self }: {
    packages.x86_64-linux.default = builtins.fetchurl {
      url = "https://example.com/foo+bar";
      sha256 = "";
    };
  };
}

The equivalent error is instead:

error: unable to download 'https://example.com/foo+bar': HTTP error 404

(Notice that the plus sign has been preserved).

Expected behavior

URL encoding is certainly useful, and RFC 3986 does indicate that + is not a valid URL character, but I ran into this issue while attempting to package software that nonetheless uses a + in its source URL, and 404s with the URL-encoded equivalent. Perhaps there could be an attribute on flake inputs to disable URL encoding?

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/8993 **Describe the bug** Flake input URLs unconditionally percent-encode their input URLs in ways that `fetchurl` and co do not, which makes some URLs impossible to express in flake inputs. **Steps To Reproduce** Take the following `flake.nix`: ```nix { inputs = { example = { url = "https://example.com/foo+bar"; flake = false; }; }; outputs = { self, example }: {}; } ``` Running `nix build` for this flake produces an error as expected, but in the error we can see the following line: ``` error: unable to download 'https://example.com/foo%2Bbar': HTTP error 404 ``` (Notice that the plus sign has been replaced with `%2B`). If we change the flake to this: ```nix { inputs = { }; outputs = { self }: { packages.x86_64-linux.default = builtins.fetchurl { url = "https://example.com/foo+bar"; sha256 = ""; }; }; } ``` The equivalent error is instead: ``` error: unable to download 'https://example.com/foo+bar': HTTP error 404 ``` (Notice that the plus sign has been preserved). **Expected behavior** URL encoding is certainly useful, and [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt) *does* indicate that `+` is not a valid URL character, but I ran into this issue while attempting to package software that nonetheless uses a `+` in its source URL, and 404s with the URL-encoded equivalent. Perhaps there could be an attribute on flake inputs to disable URL encoding? **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-16 06:44:58 +00:00
jade added the
Area/flakes
label 2024-03-30 00:04:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#113
No description provided.