I’ve recently started running Linux on my local machine and decided to play around with Nix in order to avoid having to install a bunch of dependencies globally on the system. I came across https://github.com/the-nix-way/dev-templates which has templates for various languages and toolchains and I’m quite happy with it so far.
To adopt it in one of my projects (https://github.com/andrestc/ztop) I ran $ nix flake init --template "https://flakehub.com/f/the-nix-way/dev-templates/*#zig"
which setups a flake.nix file with the dependencies that are going to be setup.
The development workflow is:
- Run
nix develop
to get a shell into the project environment. - Code & build my project normally. In the example above, I get an environment with Zig toolchain and can simply run zig build.
This relies on some experimental Nix features and I had to slap the following into .config/nix/nix.conf
:
experimental-features = nix-command flakes
I was able to use the same workflow for this site (powered by Hugo) by simply initializing the project using the Go template and adding Hugo nix package to flake.nix.