Add host attribute of github/gitlab flakerefs to URL serialization#12580
Merged
edolstra merged 1 commit intoNixOS:masterfrom Feb 28, 2025
Merged
Add host attribute of github/gitlab flakerefs to URL serialization#12580edolstra merged 1 commit intoNixOS:masterfrom
edolstra merged 1 commit intoNixOS:masterfrom
Conversation
`GitArchiveInputScheme::toUrl` currently drops the `host` attribute,
creating invalid urls when locking `github:` or `gitlab:` urls pointing to alterative instances and serializing the input back to a url.
```
❯ cat flake.nix
{
inputs.gnome-2048 = {
url = "gitlab:GNOME/gnome-2048?host=gitlab.gnome.org";
flake = false;
};
outputs = inputs: {};
}
f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35
❯ nix flake metadata
warning: creating lock file '/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35/flake.lock':
• Added input 'gnome-2048':
'gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D' (2025-02-21)
Resolved URL: path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35
Locked URL: path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35?lastModified=1740744684&narHash=sha256-nxUL/JiTYbZX2c1XiN/TC6aA1hf%2B1YXsUvhL7ASY2uE%3D
Path: /nix/store/f4xczpwhdxs8gal1rika1c5bvhyd472l-source
Last modified: 2025-02-28 13:11:24
Inputs:
└───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46)
```
Note the gnome-2048 input url missing the original host query.
The Url after this commit:
```
[...]
Inputs:
└───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?host=gitlab.gnome.org&narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46)
```
ysndr
added a commit
to flox/flox
that referenced
this pull request
Feb 28, 2025
Backport of upstream PR targeting nix >= 2.27 <NixOS/nix#12580> When installing `github` or `gitlab` flake refs with an alternative host to an environment, the environment will fail to build in the general case where the store paths are not substitutable: ``` flox install gitlab:foo/bar?host=gitlab.example.com ❌ ERROR: Failed to build environment: Failed to realise 'bar': error: … while fetching the input 'gitlab:foo/bar/87687do78you0876ear1eallya2eacd62read77cadthis' error: unable to download 'https://gitlab.com/api/v4/projects/foo%2bar/repository/archive.tar.gz?sha= 87687do78you0876ear1eallya2eacd62read77cadthis': HTTP error 404 response body: {"message":"404 Project Not Found"} ``` That is because nix drops the `host` parameter when serializing the locked flakeref to a url. The included patch adds the `?host` query back to the locked url.
mkenigs
pushed a commit
to flox/flox
that referenced
this pull request
Feb 28, 2025
Backport of upstream PR targeting nix >= 2.27 <NixOS/nix#12580> When installing `github` or `gitlab` flake refs with an alternative host to an environment, the environment will fail to build in the general case where the store paths are not substitutable: ``` flox install gitlab:foo/bar?host=gitlab.example.com ❌ ERROR: Failed to build environment: Failed to realise 'bar': error: … while fetching the input 'gitlab:foo/bar/87687do78you0876ear1eallya2eacd62read77cadthis' error: unable to download 'https://gitlab.com/api/v4/projects/foo%2bar/repository/archive.tar.gz?sha= 87687do78you0876ear1eallya2eacd62read77cadthis': HTTP error 404 response body: {"message":"404 Project Not Found"} ``` That is because nix drops the `host` parameter when serializing the locked flakeref to a url. The included patch adds the `?host` query back to the locked url.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
ysndr
added a commit
to flox/flox
that referenced
this pull request
Jul 18, 2025
Originally introduced in <#2789> the patch was merged upstream into master in February via <NixOS/nix#12580>. Assuming it was available via Nix in nixpkgs in late June, we removed the patch in <#3176>, which bumped our nix distribution to v2.28.2. It turns out that the upstream patch was only released via nix **2.29.0**, thus by removing our patch we regressed that behavior. This commit reintroduces the patch, while we use nix 2.28.3.
tomberek
pushed a commit
to flox/flox
that referenced
this pull request
Jul 18, 2025
Originally introduced in <#2789> the patch was merged upstream into master in February via <NixOS/nix#12580>. Assuming it was available via Nix in nixpkgs in late June, we removed the patch in <#3176>, which bumped our nix distribution to v2.28.2. It turns out that the upstream patch was only released via nix **2.29.0**, thus by removing our patch we regressed that behavior. This commit reintroduces the patch, while we use nix 2.28.3.
ysndr
added a commit
to flox/flox
that referenced
this pull request
Nov 6, 2025
Drops the patches for * NixOS/nix#12580 * NixOS/nix#12642 * NixOS/nix#13340 All three have been merged upstream in the current release of nix (v2.31.2).
ysndr
added a commit
to flox/flox
that referenced
this pull request
Nov 6, 2025
Drops the patches for * NixOS/nix#12580 * NixOS/nix#12642 * NixOS/nix#13340 All three have been merged upstream in the current release of nix (v2.31.2).
ysndr
added a commit
to flox/flox
that referenced
this pull request
Nov 6, 2025
Drops the patches for * NixOS/nix#12580 * NixOS/nix#12642 * NixOS/nix#13340 All three have been merged upstream in the current release of nix (v2.31.2).
ysndr
added a commit
to flox/flox
that referenced
this pull request
Nov 7, 2025
Drops the patches for * NixOS/nix#12580 * NixOS/nix#12642 * NixOS/nix#13340 All three have been merged upstream in the current release of nix (v2.31.2).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
GitArchiveInputScheme::toUrlcurrently drops thehostattribute, creating invalid urls when lockinggithub:orgitlab:urls pointing to alterative instances and serializing the input back to a url.Context
Note the gnome-2048 input url missing the original host query.
The Url after this commit:
The Nix maintainer team uses a GitHub project board to schedule and track reviews.