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

Flake inputs should be able to do a sparse checkout of a Git repository #5811

Open
virchau13 opened this issue Dec 21, 2021 · 7 comments
Open
Labels

Comments

@virchau13
Copy link

Is your feature request related to a problem? Please describe.
Being able to get a subset of the files for very big repositories is often necessary. For example, I had to download the entire repository (~2.7GiB) of ryanoasis/nerd-fonts just to use the 53.7 KiB font-patcher script in the root. Similarly, using the same nerd-fonts repository, I may only want to download the patched-fonts/FantasqueSansMono/ directory and ignore the rest of the files.

Describe the solution you'd like
In flake inputs, it should be possible to specify a subset of files / directories from a Git repository, and the flake fetcher automatically tries something like a sparse checkout before falling back to simply cloning the full repository. This may be useful for more than just Git repositories, too.

Describe alternatives you've considered
For fetching single files from GitHub repositories, one can use fetchurl; but this doesn't fit with the entire model of flakes as a whole (nix flake update won't update it, etc.) Also, this doesn't work for directories.

@rehno-lindeque
Copy link
Contributor

rehno-lindeque commented Apr 25, 2022

This is now implemented in lib.fetchgit, lib.fetchFromGitHub as of NixOS/nixpkgs#135881.

I would love to have this available in builtins.fetchTree as well in order to do work directly inside nixpkgs (instead of in private overlays).

{
  inputs = {
    pytorch = {
      url =  "github:me/nixpkgs";
      ref = "pytorch-1.11.0";
      subtree = "pkgs/development/python-modules/pytorch"; # or sparseCheckout
      flake = false;
    };
  };
  outputs = { self, ... }: {
    overlays.default = final: prev: {
      pytorch_1_11_0 = final.callPackage self.inputs.pytorch {}; 
      pytorch-bin_1_11_0 = final.callPackage "${self.inputs.pytorch}/bin.nix" {};
    };
  };
}

Related: #3785 #4097 #4414

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixpkgss-current-development-workflow-is-not-sustainable/18741/69

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-2-9-0-released/19407/6

@michaelBelsanti
Copy link

This feature was merged some time ago and this issue should be closed.

@virchau13
Copy link
Author

@quasigod-io I did some searching and can't find a PR or documentation for this feature. Can you point me to where this was implemented?

@michaelBelsanti
Copy link

Nevermind, I made a mistake reading this issue last night. My apologies.

@dzmitry-lahoda
Copy link

do we have example repo to look at? so we can be sure it works?

@stale stale bot added the stale label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants