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

Fix using git deps with rev= in pyproject.toml #358

Closed

Conversation

bjornfor
Copy link

Currently poetry2nix calls builtins.fetchGit with ref=<rev>, which Nix
translates to ref=refs/heads/<rev> and breaks (git):

$ nix-build
+ /usr/bin/git -C /home/bf/.cache/nix/gitv3/1aba8psc37ekc9ph2m5ziidm644mj84yrrj7g6x8amy3g13kyjm4 cat-file -e 4d41bada407267a008473547085f8242bb8663e5
+ /usr/bin/git -C
/home/bf/.cache/nix/gitv3/1aba8psc37ekc9ph2m5ziidm644mj84yrrj7g6x8amy3g13kyjm4 fetch --quiet --force -- ssh://git@server.example/repo.git refs/heads/4d41bada407267a008473547085f8242bb8663e5:refs/heads/4d41bada407267a008473547085f8242bb8663e5
fatal: Couldn't find remote ref refs/heads/4d41bada407267a008473547085f8242bb8663e5
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)
fatal: the remote end hung up unexpectedly

(I wrote a git wrapper that traces the calls to the real git.)

Unfortunately, poetry does not support specifying both branch= and rev=
in pyproject.toml (it ignores branch= if rev= is set), so we have to fix
this in poetry2nix. (At least for now.)

Fix it by using the new builtins.fetchGit 'allRefs' parameter when rev=
is set. This parameter is only available in nixUnstable, but as the
current code is broken anyway, I think that's ok.

Currently poetry2nix calls builtins.fetchGit with ref=<rev>, which Nix
translates to ref=refs/heads/<rev> and breaks (git):

$ nix-build
+ /usr/bin/git -C /home/bf/.cache/nix/gitv3/1aba8psc37ekc9ph2m5ziidm644mj84yrrj7g6x8amy3g13kyjm4 cat-file -e 4d41bada407267a008473547085f8242bb8663e5
+ /usr/bin/git -C
/home/bf/.cache/nix/gitv3/1aba8psc37ekc9ph2m5ziidm644mj84yrrj7g6x8amy3g13kyjm4 fetch --quiet --force -- ssh://git@server.example/repo.git refs/heads/4d41bada407267a008473547085f8242bb8663e5:refs/heads/4d41bada407267a008473547085f8242bb8663e5
fatal: Couldn't find remote ref refs/heads/4d41bada407267a008473547085f8242bb8663e5
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)
fatal: the remote end hung up unexpectedly

(I wrote a git wrapper that traces the calls to the real git.)

Unfortunately, poetry does not support specifying both branch= and rev=
in pyproject.toml (it ignores branch= if rev= is set), so we have to fix
this in poetry2nix. (At least for now.)

Fix it by using the new builtins.fetchGit 'allRefs' parameter when rev=
is set. This parameter is only available in nixUnstable, but as the
current code is broken anyway, I think that's ok.
@bjornfor
Copy link
Author

Ping?

@bjornfor
Copy link
Author

bjornfor commented Sep 7, 2021

@adisbladis: Can you please have a look?

@bjornfor
Copy link
Author

Looks like nix 2.3 and 2.4 handles this differently: NixOS/nix#5128

@adisbladis
Copy link
Member

Since it seems that this PR relies on a bug in the unreleased Nix 2.4 I'm inclined to close it.

@adisbladis adisbladis closed this Sep 23, 2021
vlaci pushed a commit to vlaci/poetry2nix that referenced this pull request Oct 20, 2021
Another approach to make `poetry2nix` work with dependencies specified
by arbitrary `rev=<hash>` values on newer Nix revisions.

Relates-to: nix-community#358
Relates-to: NixOS/nix#5128
vlaci pushed a commit to vlaci/poetry2nix that referenced this pull request Oct 20, 2021
Another approach to make `poetry2nix` work with dependencies specified
by arbitrary `rev=<hash>` values on newer Nix revisions.

Relates-to: nix-community#358
Relates-to: NixOS/nix#5128
vlaci pushed a commit to vlaci/poetry2nix that referenced this pull request Oct 20, 2021
Another approach to make `poetry2nix` work with dependencies specified
by arbitrary `rev=<hash>` values on newer Nix revisions.

Relates-to: nix-community#358
Relates-to: NixOS/nix#5128
vlaci pushed a commit to vlaci/poetry2nix that referenced this pull request Oct 22, 2021
Another approach to make `poetry2nix` work with dependencies specified
by arbitrary `rev=<hash>` values on newer Nix revisions.

Relates-to: nix-community#358
Relates-to: NixOS/nix#5128
adisbladis pushed a commit that referenced this pull request Jan 17, 2022
Another approach to make `poetry2nix` work with dependencies specified
by arbitrary `rev=<hash>` values on newer Nix revisions.

Relates-to: #358
Relates-to: NixOS/nix#5128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants