Shell.nix outside the project folder

I’m the only one using Nix in a project. For now I just created shell.nix and other nix file inside the project folder but I didn’t include these file in the git repo. But I want to keep those files in repo to keep the history and other stuffs. What is the recommend way to do this? I thought in create a new repo to those files and create a symbolic link to them in my project. Is it a good idea?

A contrib/ in the project root is a common place to store useful files that may not necessarily be maintained. Perhaps your team could compromise with that? A comment header stating the file’s purpose would be apt, too (and may eventually move more team members to try Nix out).

More on contrib/.

If you don’t want to include them in the ‘upstream’ git repo, but want to keep them versioned in your ‘own’ tree, there is a couple of options as well:

  • git-along integrates with git tightly. TBQH I don’t quite understand where the files actually go :).
  • shellbit puts them all under a top-level nix expression, so you can load them right into nix-shell with -A. An example repo is at nixels.
  • nix-environments also just has a top-level nix expression without any particular tooling.
  • nix-shell-git just puts shell.nix files in a tree. An example repo is at nix-shells

@raboof it’s possible to use nix-shell-git with direnv?

Sorry, I don’t know, I like to enter my nix-shells explicitly :wink:

Thanks @Tmplt, contrib is a great idea.

I use direnv to avoid garbage-collector

ah that is kindof neat indeed, I didn’t realize nix-direnv took care of that (GitHub - nix-community/nix-direnv: A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]). OTOH it’s kind of nice that I can garbage-collect things that belong to projects I’m not actively working on :wink: