A new, faster evaluation-time Git fetcher


#1

Hey y’all,

Over the past few weeks I’ve been working with @shlevy at Target to make an evaluation-time Nix fetcher for Git repositories. It has a few improvements documented in the readme, but briefly:

✓ way faster clones!
✓ shallow clones, sometimes!
✓ annotated tags!
✓ works with builtins.filterSource!
✓ morally pure if you follow good tagging etiquette!

Ideally we’ll be able to get the improvements upstream. We’ve gone this route to make it easier to prototype and prove out the changes.

Check it out, and let me know what you think =)


#2

Sweet! Does it support submodules? builtins.fetchGit currently does not :frowning:


#3

I suppose this depends if shallow clones support git submodules. Theoretically it should be possible.


#4

“morally pure” got me :slight_smile:


#5

You mean git clone --shallow-submodules?


#6

Does it support private repos like builtins.fetchGit?


#7

sounds exciting. Maybe add a comment on how to install for those who never installed any nix plugin


#8

Just wanted to note, you can add nix-plugins like this (excerpt from configuration.nix):

  let
    nixpkgs-unstable = (import (fetchGit {
      url = https://github.com/NixOS/nixpkgs-channels;
      ref = "nixos-unstable";
    }) { config = { allowUnfree = true; }; });
  in {
      nix.extraOptions = ''
        plugin-files = ${nixpkgs-unstable.nix-plugins}/lib/nix/plugins/libnix-extra-builtins.so
      '';
    }

After this setup, you can then try and run the test in the nix-fetchers repo with ./test/run.

Edit: I found that out through https://nixos.org/nix/manual/#conf-plugin-files - couldn’t for the life of me find it in the nix-plugins repo.


#9

@manveru Hm, adding plugin-files to my nix.conf just gives me illegal configuration line 'plugin-files ...' no matter what version of nix I use.


#10

Copying the line from nix.conf and using it as a command line option instead with --plugin-files seems to work though?


#11

Derp, I forgot the equals sign :stuck_out_tongue: