Hi,
I wrote a small script to "prefetch" github git repositories and
also to automatically calculate the appropriate arguments for
nixpkgs.fetchFromGitHub. I thought I'll share my script with the
community. The source code can be found on PyPI
and GitHub
and thus can be installed via pip.
If you might be interested in using this, feel free to do so.
Feedback is welcome and appreciated.
Cheers,
Sebastian
Hi Silvan,
You would get not only the "hash" but also the latest commit sha aka "rev". This script uses the github API to find out the latest commit "rev" and falls back to "nix-prefetch-git" if the github API rate limit is reached which can be nice if you use it on a travis-ci server or something similar. And yes, this all can be done with a bash script, but I don't see why everybody should write their own bash script every time they need to do this kind of task. Thank you for your feedback :) much appreciated :)
Cheers,
Sebastian
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/60A74B10-A7E2-4061-867D-19EAAF76FBAA%40icloud.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+unsubscribe@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/87vacm6y74.fsf%40write-only.cryp.to.
I've tried to implement "simple" Bash script based on comments above, but I think hash computation for fetchFromGitHub isn't straightforward
https://gist.github.com/danbst/1b7d6b97401ebdc34df0a03b8f3a1424There are 2 ways of hash computing:
1) hash=$(nix-prefetch-url "https://github.com/$project/archive/$rev.tar.gz")
2) hash=$(nix-prefetch-git "github.com/$project.git" --rev "$rev" --quiet | jq -r .sha256)The output is:
(as per https://github.com/NixOS/nixpkgs/blob/192221ae3f2493f1e47a77726059dc4a65a9800d/pkgs/development/tools/misc/hydra/default.nix#L69-L74)But should be
{
owner = "NixOS";
repo = "hydra";
rev = "b7bc4384b7b471d1ddf892cb03f16189a66d5a0d";
sha256 = "05g37z3ilazzqa5rqj5zljndwxjbvpc18xibh6jlwjwpvg3kpbbh";
}
Hi,
@Danylo: You have to run nix-prefetch-github with python 3. Then it *should* work.
Hi,
On Friday, April 20, 2018 at 1:00:27 PM UTC+3, Danylo Hlynskyi wrote:I've tried to implement "simple" Bash script based on comments above, but I think hash computation for fetchFromGitHub isn't straightforward
https://gist.github.com/danbst/1b7d6b97401ebdc34df0a03b8f3a1424
There are 2 ways of hash computing:
1) hash=$(nix-prefetch-url "https://github.com/$project/archive/$rev.tar.gz")
2) hash=$(nix-prefetch-git "github.com/$project.git" --rev "$rev" --quiet | jq -r .sha256)
The output is:
<snip 2 wrong outputs>(as per https://github.com/NixOS/nixpkgs/blob/192221ae3f2493f1e47a77726059dc4a65a9800d/pkgs/development/tools/misc/hydra/default.nix#L69-L74)But should be
{
owner = "NixOS";
repo = "hydra";
rev = "b7bc4384b7b471d1ddf892cb03f16189a66d5a0d";
sha256 = "05g37z3ilazzqa5rqj5zljndwxjbvpc18xibh6jlwjwpvg3kpbbh";
}
The 100% fool-proof way is to generate the same Nix expression you'd be generating but with a bogus hash, and then parse it from the error message:
$ nix-build -E 'with import <nixpkgs> {}; fetchFromGitHub { owner = "NixOS"; repo = "hydra"; rev = "b7bc4384b7b471d1ddf892cb03f16189a66d5a0d"; sha256 = "0000000000000000000000000000000000000000000000000000"; }'....unpacking source archive /tmp/nix-build-source.drv-0/b7bc4384b7b471d1ddf892cb03f16189a66d5a0d.tar.gzfixed-output derivation produced path '/nix/store/52dmfk71mamdh3hsklqdvawksg61an8y-source' with sha256 hash '05g37z3ilazzqa5rqj5zljndwxjbvpc18xibh6jlwjwpvg3kpbbh' instead of the expected hash '0000000000000000000000000000000000000000000000000000'error: build of '/nix/store/gxvpc4fgs2nvpycifk5a0vab30qrvy8d-source.drv' failed
This is also the only fully general way, for example if you want your script to support the keepDotGit or fetchSubmodules.
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/c229229c-e0a9-4199-8849-9e6dec91a8a7%40googlegroups.com.