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

Add name argument to builtins.fetchTarball and builtins.fetchgit #904

Closed
domenkozar opened this issue May 13, 2016 · 6 comments
Closed

Add name argument to builtins.fetchTarball and builtins.fetchgit #904

domenkozar opened this issue May 13, 2016 · 6 comments

Comments

@domenkozar
Copy link
Member

Current behavior:

  • builtins.fetchTarball currently names the derivation after the url (words after last slash in the url)
  • builtins.fetchgit currently always names the derivation git-export
  • Hydra nix-prefetch-git currently names the derivation git-export (and has an old standing bug in that script of stripping anything that prefixes on .git instead of just .git folder, so .gitignore would also be deleted
  • nixpkgs nix-prefetch-git currently names the derivation after url and rev name

All in all, this leads to a lot of frustration since hashes of those derivations will differ. I'll try to fix the Hydra part (and look into since when nix-prefetch-git is crazy).

Mainly, I would hope that fetchTarball and fetchgit can be used interchangeably and it's currently not possible due to different hardcoded names.

cc @ocharles as he mentioned this recently on IRC
cc @edolstra

@domenkozar
Copy link
Member Author

domenkozar commented May 13, 2016

Just to be clear about my motivation: I'd like to build my derivation on Hydra and locally using some git as source and currently it's not possible to match Hydra's produced hash using nix-prefetch-git as its GitPlugin.

@domenkozar
Copy link
Member Author

Wrote a script to get all hashes for an example repo:

builtins.fetchTarball: "/nix/store/g43i2h7hh43zr146g9wbq2cs5wjj9dac-master"
builtins.fetchgit: "/nix/store/fws69vhxrmxjgp83dh9xc86zlclp8k2j-git-export"
Nixpkgs nix-prefetch-git: path is /nix/store/dxawz07sxcd6m25r982qwljxfz128bak-snabb
Hydra nix-prefetch-git: path is /nix/store/nvn3q89lawxa1ar7x9ywhglnnki3y0dd-git-export

The script (assumes recent Nix at result):

fetchTarball=$(nix-instantiate -E 'builtins.fetchTarball https://github.com/snabbco/snabb/tarball/master' --eval)
fetchgit=$(./result/bin/nix-instantiate -E 'builtins.fetchgit https://github.com/snabbco/snabb.git' --eval)
nixprefetchgit=$(nix-prefetch-git https://github.com/snabbco/snabb.git |& grep 'path is')
hydranixprefetchgit=$($(nix-build -E '(import "${builtins.fetchTarball https://github.com/NixOS/hydra/tarball/dc790c5f7eacda1c819ae222bf87674781ae1124}/release.nix" {}).build')/bin/nix-prefetch-git https://github.com/snabbco/snabb.git |& grep 'path is')

echo "builtins.fetchTarball: $fetchTarball"
echo "builtins.fetchgit: $fetchgit"
echo "Nixpkgs nix-prefetch-git: $nixprefetchgit"
echo "Hydra nix-prefetch-git: $hydranixprefetchgit"

@domenkozar
Copy link
Member Author

Started with nixpkgs: NixOS/nixpkgs#15469

Next up: Hydra should use nixpkgs nix-prefetch-url

@domenkozar
Copy link
Member Author

I can remove the differences in inputs between what's used as the source, but I really don't see a solution to naming of these derivations without providing a way to name them (or just using the same name everywhere).

@expipiplus1
Copy link
Contributor

How does this impact fetching from local directories, for example src = ./.? Would the solution involve some function like namePath = name: path: ...?

I'm bumping into NixOS/hydra#172 and it would be super to be able to implement some kind of workaround until this can be fixed properly. I'd be more than happy to have a crack at this if someone points me in the right direction :)

@domenkozar
Copy link
Member Author

domenkozar commented Apr 6, 2017

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

No branches or pull requests

2 participants