Nix flake without git

How do I run a nix flake without git.

Either I want to use another VCS like fossil or mercurial.

Or in my current case trying to set up macos - which does not include git. SO I want flake.nix to set up my machine include installing got via home-manager.

No I can do nix shell nixpkgs#git - but the standard way appears to be set devShell in flake.nix and use nix develop but the latter fails as you need git. I also want other things in the startup. I want not to have to rememeber all the parameters to nix shell but put them in a .nix file

At least mercurial is supported under the hg+* schemas:

  • mercurial: Mercurial repositories. The URL form is similar to the git type, except that the URL schema must be one of hg+http, hg+https, hg+ssh or hg+file.

Fossil doesn’t seem to have (documented) support currently.

The github, gitlab, and similar hoster specific schemas also do not require git being installed, as here actually API endpoints of the hosters are used. So this could be a viable workaround for the initial bootstrapping.

Last but not least, if you want to bootstrap from a local copy that you already have on your disk, but do not want to enter an ephemeral shell that provides git, you can use the path schema to use the local copy as is. You might miss out some flake related features like rev or lastModified* then.

1 Like

You don’t need git, it shouldn’t fail unless your flake is in a git repository. Can you try nix develop path:$(pwd) instead, and share the actual error message?

Edit: I may also have misunderstood what you’re doing, if so, carry on please

You have understood.

I have the source it a git repo.

I was trying to setup in a VM which does not have git installed in but maintained on the main machine that does have git.

What is annoying is that I can set up a shell.nix and run nix-shell which does what I want

Hum, well, fun edge case. How do you even get the git repo downloaded without git, with the .git directory in tact no less? Via a shared folder?

Either way, the path:$(pwd) thing should probably resolve the problem.