Nixpkgs: nix-prefetch-github?

Created on 7 Jan 2017  Â·  16Comments  Â·  Source: NixOS/nixpkgs

Just wondering: Is there a nix-prefetch-github command somewhere?

Imaginary example:

$ nix-prefetch-github nixos nixpkgs 16.09
{
  owner = "nixos";
  repo = "nixpkgs";
  rev = "...";
  sha256 = "...";
}

Just thinking this could be very handy for automatically generating sources lists e.g. if you want to be able to address all releases of a given project. Just to avoid the busy-work of manually translating the branch/tag to a revision id and "use a fake sha256, get real sha256 from error message, copy-paste and build again" dance.

fetch documentation

Most helpful comment

This method is not documented as far as I know.

All 16 comments

There is no such wrapper, but I would be happy to merge it.
It would be a thin shell wrapper around fetchzip. The wrapper could also implement the following targets:

  • fetchFromBitbucket
  • fetchFromGitLab
  • fetchFromSavannah

Implementation details can be looked up here:

https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix#L194

If it's just updating the sha256 then nix-prefetch-url -A mypackage.src can be used

Closing because we already have nix-prefetch-url -A.

This method is not documented as far as I know.

Agreed - we should change docs at least.

Does nix-prefetch-url -A mypackage.src even give the right answer given that fetchFromGitHub uses fetchzip? Or is it smart enough to do same as nix-build --hash?

At least two bits:

  • nix-prefetch-url -A is not documented in --help
  • prefetching nixpkgs is not easy with this method. As @lukego states we'd have to print the arguments to the fetch* function to really be iterative

@domenkozar What does the -A flag do?

$ nix-prefetch-url -A linuxPackages.kernel.src
 [78443/90991 KiB, 11001.6 KiB/s]g/pub/linux/kernel/v4.x/linux-4.9.49.tar.xz’... [0/0 KiB, 0.0 Ki [0/90991 KiB, 0.0 KiB/s]
path is ‘/nix/store/mbdwpv9cvyk3wfnd6mvzw0f6yklj9cgq-linux-4.9.49.tar.xz’
1ywiww2h1gf3ps305irzk7n9xkcgg9bclr2jw6r5cqxmh3qxrv2p

Impure world might not have:

a) access to Nix expressions
b) ability to update Nix expressions

so nix-prefetch-url -A is not an option in those cases (like cabal2nix).

Hi, I wrote a little something to prefetch github sources. Check it out here: seppeljordan/nix-prefetch-github or install it from pypi.

Added in #39214.

(installing via nix-env -i nix-prefetch-github)

if I nix-prefetch-github ghc ghc, what does it do exactly ?
is it like nix-prefetch-url which downloads and stores in the content addressable store ?

@nrolland From what I've seen it just downloads the source and computes the hash, but it does not add it to the nix-store.

Closing. Such a program was added in #39214.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthiasbeyer picture matthiasbeyer  Â·  3Comments

ghost picture ghost  Â·  3Comments

langston-barrett picture langston-barrett  Â·  3Comments

ob7 picture ob7  Â·  3Comments

lverns picture lverns  Â·  3Comments