PracticalFlakes are a set of highly opinionated templates to quickly bootstrap your next nix project in flakes 😎
To quickly initialize a new project run
nix flake init -t github:tsandrini/practical-flakes-template
And you're good to go! 👍
- Drop-in modularity using
flake-parts ⚙️
- the main idea is that if you have a bunch of projects using this template you
can simply just copy the individual
parts/
directories to share functionality - this way, no matter if you're developing language features, packages, NixOS modules, home-manager userspace, you can always use the same underlying structure
- the main idea is that if you have a bunch of projects using this template you
can simply just copy the individual
- devenv.sh is awesome! 🔥
- includes a devenv shell already preconfigured to format and lint nix
- treefmt is the one and only formatter to rule them all 🙏
- Already preconfigured github actions
and gitlab CI 💪
- automatic
nix flake check
on pull/merge requests - automatic nixpkgs flake inputs checker (github only)
- automatic cron based flake inputs updates (github only)
- (optional) push to FlakeHub
- automatic
- Prepared for custom
lib
overrides 🤓- depending on what you're currently aiming to write, you might need some custom helpers or library functions, this template already set ups all the necessary boilerplate to get it all going
- And finally, examples included 🖌️
After a proper installation process you can enter the development environment
with direnv allow
(or alternatively
nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")
)
While not many, the code has some required references to the practicalFlakes
identifier. This can be renamed in the whole project using the script
rename-project
(which is available in the dev environment)
rename-project . myAwesomeApp
You're also encouraged to update your flakes with
nix flake update
There are also a few other different variants of the base template that may be better suited for your needs
- main: The main, default template.
- home: Conceptually and structurally the same as the default template, but also includes prepared and preconfigured home-manager as well as examples of how to use it
- minimal: Structurally the same as the default template, but stripped of all of the included examples and additional prepared files
- isolated: Centralizes all of the nix related stuff into a
nix/
folder. This can be useful when you'd like to not pollute your root with stuff not directly tied to the code. - isolated-minimal: Isolated combined with minimal, that is, structurally the same as minimal, however, stripped out of all the examples and unnecessary code
You can install your desired template variant using
nix flake init -t github:tsandrini/practical-flakes-template#myVariant
For example,
nix flake init -t github:tsandrini/practical-flakes-template#isolated-minimal
.