This repository is a template for starting new projects with dev environment and dependencies handled by Nix, automatically loaded with direnv, and using Just for easy initial setup and commands handling, as well as Pre-commit for running checks on each commit.
This template tries to make as few assumptions about your system as possible by making sure that most dependencies are defined in the Nix flake itself. However, it still cannot avoid these two assumptions:
- Your system can run Nix flakes.
- Your system has direnv installed (because it is used to automatically load the flake, so it has to already be available).
For Nix flakes support, I recommend using The Determinate Nix Installer to install the Nix package manager on your machine. Or, for a more drastic and permanent solution, why not have your whole system be a Nix flake by using NixOS as your operating system?
For direnv, see their Getting Started for installation instructions.
If you are using Visual Studio Code, I recommend installing the direnv extension as well. This way, any other extension you have installed will benefit from the dependencies added by the Nix flake.
You have two options to start using this template:
- If creating a new repository on Github, you can directly use this template as its starting point.
- Otherwise, simply copy and paste the files from this repository at the root of your project.
Once the files are in place, you should:
- Run
direnv allow
to allow direnv to load the .envrc file. This should in turn automatically build the Nix flake and load the dependencies. - Run
just setup
to run the setup command (this will simply install the pre-commit hook).
You are now ready to start hacking!