Skip to content

nix-prefetch-github? #21732

Closed
Closed

Description

@lukego

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.

Activity

  1. Mic92 commented on Jan 7, 2017

    @Mic92
    Member

    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

  2. domenkozar commented on Jan 7, 2017

    @domenkozar
    Member

    Related: #21734

  3. zimbatm commented on Jan 15, 2017

    @zimbatm
    Member

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

  4. edolstra commented on Jan 16, 2017

    @edolstra
    Member

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

  5. added
    9.needs: documentation
    on Jan 16, 2017
  6. Mic92 commented on Jan 16, 2017

    @Mic92
    Member

    This method is not documented as far as I know.

  7. domenkozar commented on Jan 16, 2017

    @domenkozar
    Member

    Agreed - we should change docs at least.

  8. dezgeg commented on Jan 16, 2017

    @dezgeg
    Contributor

    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?

  9. domenkozar commented on Aug 16, 2017

    @domenkozar
    Member

    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
  10. robinvd commented on Sep 14, 2017

    @robinvd

    @domenkozar What does the -A flag do?

  11. domenkozar commented on Sep 14, 2017

    @domenkozar
    Member
    $ 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
    
  12. domenkozar commented on Dec 9, 2017

    @domenkozar
    Member

    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).

  13. added
    6.topic: fetch
    on Dec 23, 2017
  14. seppeljordan commented on Mar 27, 2018

    @seppeljordan
    Contributor

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

  15. FRidh commented on May 28, 2018

    @FRidh
    Member

    Added in #39214.

  16. nrolland commented on Jun 20, 2018

    @nrolland

    (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 ?

  17. pSub commented on Jul 15, 2018

    @pSub
    Member

    @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.

  18. pSub commented on Jul 15, 2018

    @pSub
    Member

    Closing. Such a program was added in #39214.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    6.topic: fetch9.needs: documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions