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

fetchGit and submodules #58

Closed
roberth opened this issue May 12, 2019 · 10 comments
Closed

fetchGit and submodules #58

roberth opened this issue May 12, 2019 · 10 comments
Labels
enhancement New feature or request

Comments

@roberth
Copy link

roberth commented May 12, 2019

I love the support for 'normal' GitHub repo's, but niv in its current implementation can't include the submodules, which makes it useless in some cases.
This can be solved by adding support for fetchGit.

@nmattia
Copy link
Owner

nmattia commented May 27, 2019

Definitely. Whenever we merge #35 (cough cough Soon ™) I'll most likely deprecate the url_template fetching for github repos and use fetchGit/fetchFromGitHub instead.

@PierreR
Copy link

PierreR commented Nov 19, 2019

@nmattia I guess the resolution of this issue would solve my issue:

unpacking source archive /build/v3.7.2.tar.gz
error: zip file must contain a single file or directory.
hint: Pass stripRoot=false; to fetchzip to assume flat list of files.

I am trying to replace a call to pkgs.fetchgit with niv. Here is my source.json:

    "puppet-unit-test": {
        "sha256": "0hyvh2niq939rxhs7wx6szmvrs7s6nrn3sxf1rma5xl41aw3b068",
        "type": "tarball",
        "url": "http://bitbucket.cirb.lan/CICD/puppet-unit-test/archive/v3.7.2.tar.gz",
        "url_template": "http://bitbucket.cirb.lan/CICD/puppet-unit-test/archive/v3.7.2.tar.gz",
        "version": "3.7.2"

@nmattia
Copy link
Owner

nmattia commented Nov 20, 2019

@PierreR in this case you can also use type = "file" and do the unpacking yourself. But yes, having fetchgit and the bitbucket git@... uri should fix this.

@nmattia
Copy link
Owner

nmattia commented Dec 5, 2019

Forgot to update this! There's experimental support for fetchGit:

$ niv add git [email protected]:nmattia/niv -a rev=deadbeef

@andir
Copy link
Collaborator

andir commented May 26, 2020

How would I use fetchSubmodules = true with this?

@Nadrieril
Copy link

This is not directly supported, but you can make it work as follows.
First you need to use an unstable version of nix, so that fetchGit accepts a submodules argument (it's not called fetchSubmodules anymore). Then change sources.nix to pass the submodules argument to fetchGit:

diff --git a/nix/sources.nix b/nix/sources.nix                                                                                                     
index 8a725cb..800b0f8 100644                                                                                                                      
--- a/nix/sources.nix                                                                                                                              
+++ b/nix/sources.nix                                                                                                                              
@@ -19,7 +19,7 @@ let                                                                                                                              
       pkgs.fetchzip { inherit (spec) url sha256; };                                                                                               
                                                                                                                                                   
   fetch_git = spec:                                                                                                                               
-    builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };                                                                               
+    builtins.fetchGit { url = spec.repo; inherit (spec) rev ref submodules; };
  
   fetch_builtin-tarball = spec:
     builtins.trace

Finally, add "submodules": true in a sources.json entry that has "type": "git". Example:

    "dhall-haskell": {
        "ref": "master",
        "repo": "https://github.com/dhall-lang/dhall-haskell",
        "rev": "9afffaea7108a86df197cb97b64a9504fe37ecfc",
        "submodules": true,
        "type": "git"
    },

@shajra
Copy link

shajra commented Sep 9, 2020

@nmattia I just realized how long-standing this issue has been. I've personally run into a second time now (submodules aren't so rare to never see them... but they aren't the common case). What are your latest thoughts on how best to solve it? Is there anything I can do to help push it over the finish line?

@nmattia
Copy link
Owner

nmattia commented Sep 10, 2020

hey @shajra , I wrote up some thoughts in here: #229 (comment)

I unfortunately don't have as much time as I used to these days, but one way to contribute would be to share the above and get feedback on it; then we can actually go forward (implementation shouldn't take long).

Also I didn't see @Nadrieril 's comment above; that's definitely something we could add to sources.nix right now! PRs welcome.

@tfc
Copy link
Contributor

tfc commented Apr 28, 2022

Hey i think this can be closed now with the latest PR being merged, right? #352

@nmattia
Copy link
Owner

nmattia commented Apr 28, 2022

Yes, thanks!

@nmattia nmattia closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants