You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nix/flake: installables exclude attribute path from URL (#1819)
I ran into an issue causing the generated `.devbox/gen/flake` to contain
an invalid flake reference when adding some installables to
`devbox.json`, specifically those which pointed to a remote resource.
Local files were fine.
After a quick hike around the repo, the fix seemed trivial enough to
open up a PR rather than open up an issue. Interestingly, I didn't seem
to find any issues around this even though this bug would've been around
for some months.
As it turns out, `Installable`s returned from `ParseInstallable`
included the attribute path when provided a value with any scheme aside
from `<empty string>`, `flake`, `path`, or `github`. This was because
the `parseURLRef` method was not separating the fragment out of the
refURL. More generically, the affected branches were any of those that
set `parsed.URL` to the result of `refURL.String()`, since that specific
method will re-add `Fragment` unless its empty.
Additionally, the test for `ParseInstallable` with a flake was passing
because the test case itself had an invalid flake reference. I corrected
that, as well as adding a couple of relevant test cases for some other
types as well.
## Repro steps
1. Add any non-local-path flake reference **with an Installable** to
`devbox.json`
e.g. `https://github.com/NixOS/patchelf/archive/master.tar.gz#patchelf`
2. Execute the following
```sh
DEVBOX_DEBUG=1 devbox shell
```
3. Observe the following `nix` error:
```sh
Error: nix print-dev-env --json "path:/path/to/your/.devbox/gen/flake": exit status 1
2024/02/16 18:44:09 Command stderr: error: unexpected fragment 'patchelf' in flake reference 'tarball+https://github.com/NixOS/patchelf/archive/master.tar.gz#patchelf'
```
## How was it tested?
Updating the relevant test, then making adjustments to ensure they
pass.
---------
Co-authored-by: Greg Curtis <[email protected]>
0 commit comments