nix-community / vgo2nix

Convert go.mod files to nixpkgs buildGoPackage compatible deps.nix files [maintainer=@adisbladis]
MIT License
90 stars 21 forks source link

Fix replace handling #36

Closed Lucus16 closed 3 years ago

Lucus16 commented 4 years ago

This PR builds on https://github.com/adisbladis/vgo2nix/pull/27

I added a test for URL replacements based on how they are used elsewhere on github. Note that this URL replacement isn't useful, the backing git repositories are still the same, but it works fine as a test and is unlikely to break. Most real world examples involve pull requests that will eventually be deleted.

I then wrote URL replacement support which passes the tests. It's not a very elegant solution but it seems to work.

matt-snider commented 4 years ago

I'm currently trying to package ProtonMail/proton-bridge but was stumped when I ran into #22.

I tried your fork and it worked, so first of all thanks for sharing your solution! :+1:

I did have one issue, which was an error about invalid commits for docker-credential-helpers and bcrypt. That sort of makes sense, because the values for those deps in the go.mod file appear to be placeholders. But still, I wonder why they are evaluated if they get replaced anyway. I'm not very familiar with Go, so maybe they are doing something non-standard in that go.mod file. At any rate, I was able to fix those two references and replace them with valid commits and then it worked. :tada:

Lucus16 commented 4 years ago

It is normal for go.mod to contain invalid commits when a replace with a valid commit is given. My code incorrectly makes use of the replaced version to retrieve one of the paths.

matt-snider commented 4 years ago

@Lucus16 Yeah it seems like I spoke to soon. The deps.nix file is now generated (before it error'd out), but looking at it closer I see that the original dependencies are still listed there. I guess that's what you mean in your last sentence.

SuperSandro2000 commented 4 years ago

This PR fixes some of the bugs master has but packages like dmitri.shuralyov.com/gpu/mtl are still not working.

Edit: Taken form #40: If I change line 48 to

-   commitShaRev := regexp.MustCompile(`^v\d+\.\d+\.\d+-(?:\d+\.)?[0-9]{14}-(.*?)$`)
+   commitShaRev := regexp.MustCompile(`^v\d+\.\d+\.\d+-(?:\d+\.)?[0-9]{14}-(.*?)(?:\+incompatible)?$`)

This works. See https://github.com/nix-community/vgo2nix/pull/40/commits/27b8b52117966ed3ef2f47584e0dec4414dfb582#diff-7ddfb3e035b42cd70649cc33393fe32cR49