Skip to content

fix: add host attr of github/gitlab flakerefs to URL serialization#2789

Merged
mkenigs merged 1 commit intorelease-1.3.16from
fix/fetchers/host-in-locked-url
Feb 28, 2025
Merged

fix: add host attr of github/gitlab flakerefs to URL serialization#2789
mkenigs merged 1 commit intorelease-1.3.16from
fix/fetchers/host-in-locked-url

Conversation

@ysndr
Copy link
Copy Markdown
Contributor

@ysndr ysndr commented 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.

Release Notes

Fixes installing flakerefs pointing to custom github or gitlab instances via the github:owner/name?host=internalgithub.company.com format.

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.
@ysndr ysndr requested a review from a team as a code owner February 28, 2025 12:46
@floxbot floxbot added the team-cli Tickets relevant to the flox CLI team label Feb 28, 2025
@ysndr ysndr changed the base branch from main to release-1.3.16 February 28, 2025 18:00
@mkenigs mkenigs merged commit a184bea into release-1.3.16 Feb 28, 2025
24 checks passed
@mkenigs mkenigs deleted the fix/fetchers/host-in-locked-url branch February 28, 2025 18:34
ysndr added a commit 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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-cli Tickets relevant to the flox CLI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants