Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both ref & rev in flake input url #8226

Open
dpc opened this issue Apr 17, 2023 · 2 comments
Open

Support both ref & rev in flake input url #8226

dpc opened this issue Apr 17, 2023 · 2 comments
Labels
feature Feature request or proposal

Comments

@dpc
Copy link

dpc commented Apr 17, 2023

Describe the bug

Currently when I try to use both ref and ref in flake input url I get:

error: URL 'github:ipetkov/crane?ref=v0.12.1&rev=445a3d222947632b5593112bb817850e8a9cf737' contains both a commit hash and a branch/tag name v0.12.1 445a3d222947632b5593112bb817850e8a9cf737

Steps To Reproduce

Use an flake input url that has both ref and rev (that point at the same commit).

Expected behavior

I think it should be supported. nix should just verify that that ref is still pointing at that rev.

rev is for pinning to a hash for security/reliability, while ref is for letting humans reading the code know which release version is it. One could put the ref in a comment, but then there's nothing to make sure it's not incorrect.

@dpc dpc added the feature Feature request or proposal label Apr 17, 2023
@a-h
Copy link

a-h commented Sep 20, 2023

nix flake clone is pretty useless without changing this.

If I try to clone a specific commit of a flake without a "ref" of main, I get a failure.

nix flake clone "github:numtide/system-manager/e8957ab8b4cf02574adb5f09ef4a2ef9ee48ef01" --dest local 
error: Git input 'git+https://github.com/numtide/system-manager.git?rev=e8957ab8b4cf02574adb5f09ef4a2ef9ee48ef01' has a commit hash but no branch/tag name

If I add in the branch of main, and set the rev, it complains.

nix flake clone "github:numtide/system-manager/main?rev=e8957ab8b4cf02574adb5f09ef4a2ef9ee48ef01" --dest local
error: URL 'github:numtide/system-manager/main?rev=e8957ab8b4cf02574adb5f09ef4a2ef9ee48ef01' contains both a commit hash and a branch/tag name main e8957ab8b4cf02574adb5f09ef4a2ef9ee48ef01

Here's where the error is thrown.

https://github.com/NixOS/nix/blame/5633c0975b9dec6bceaa85003223a346d7d1bd0b/src/libfetchers/git.cc#L114

@johannwagner
Copy link

We also ran into an issue by using builtins.fetchTree, which requires to set rev and ref to have a locked input. This also triggers this mentioned assertion. If we remove rev, the input is not locked anymore and cannot be used without --impure. If we omit ref, the commit hash is not found within our repository.

Example:

builtins.fetchTree {
  type = "gitlab";
  owner = "wobcom/nix";
  repo = "very-nice-repository";
  host = "git.wobcom.de";
  ref = "very-nice-branch";
  rev = "abcefac8153fce1ae8bb103ba2258f08614392d3";
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal
Projects
None yet
Development

No branches or pull requests

3 participants