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

Use fetchFromGitHub instead of fetchgit when the source is a GitHub clone URL #260

Open
taktoa opened this issue Feb 7, 2017 · 10 comments

Comments

@taktoa
Copy link
Member

taktoa commented Feb 7, 2017

Pretty self-explanatory. Should be very easy to implement, and will save some bandwidth for anyone who uses cabal2nix on GitHub repos (since, IIRC, it will only download the revision tarball, not the whole git repo).

It would also be nice if cabal2nix gave a warning when an SSH clone URL is given, since those are impure (they depend on the SSH keys in your home directory).

@taktoa
Copy link
Member Author

taktoa commented Feb 7, 2017

BTW, I might take a crack at this at some point, but I'm busy right now, so I figured I'd at least put up an issue.

@Fresheyeball
Copy link

Fresheyeball commented Sep 11, 2017

What about those of us who are not using github? Can this be made compatible?

@taktoa
Copy link
Member Author

taktoa commented Sep 11, 2017

Then it should fall back to fetchgit? I didn't say "use fetchFromGitHub always"...

@domenkozar
Copy link
Member

domenkozar commented Dec 9, 2017

@Fresheyeball it's possible to use shallow clone (--depth 1) on revision with some remotes if they have uploadpack.allowReachableSHA1InWant=true set (github does).

But the optimization should only be used for github.com urls.

@domenkozar
Copy link
Member

Depends on NixOS/nixpkgs#21732

@domenkozar
Copy link
Member

Besides bandwidth, time would be spent for any package set projects like stack2nix, hackage2nix, stackage2nix, etc.

@domenkozar
Copy link
Member

domenkozar commented Dec 16, 2017

I've looked into how to implement this in cabal2nix.

fetchFromGitHub is really just a small wrapper around fetching a zip file.

Prefetching would be: nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/f40f2f21c03bec1cabd2a59c1863659e8c4d60dc.zip. Generated Nix expression would use fetchFromGitHub { ... }.

cabal2nix currently just guesses what prefetcher to use, by trying all of them and using the first one to succeed.

I'd propose we add a flag like --fetcher and support github as one of the options, as I'm afraid any automatic guessing within cabal2nix is going to be hard to get right.

Thoughts? /cc @peti

@peti
Copy link
Member

peti commented Dec 18, 2017

Personally, I am rather unhappy about the current "guessing code" and would love to replace it with a more deterministic solution that chooses the appropriate src value based on the command-line configuration.

@nh2
Copy link
Contributor

nh2 commented Sep 14, 2018

See input-output-hk/stack2nix#130 for more problems relating to this

@danwdart
Copy link

Hmm, is there some convertor if one uses lots of these then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants