tsandrini / flake-parts-builder

Nix flakes interactive template builder based on flake-parts. [maintainer=@tsandrini]
MIT License
3 stars 0 forks source link
flakes nix nix-flake nix-flakes nix-template nix-templates nixos-configuration nixos-flake

practical-flakes-template

flake check FlakeHub

!WARNING!

Currently rewriting into an interactive template builder! For more info see branch v1. This will evetually be archived into a separate branch.

Description

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! 👍

Features

  1. 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
  2. devenv.sh is awesome! 🔥
    • includes a devenv shell already preconfigured to format and lint nix
  3. treefmt is the one and only formatter to rule them all 🙏
  4. 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
  5. 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
  6. And finally, examples included 🖌️

Usage

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

Variants

There are also a few other different variants of the base template that may be better suited for your needs

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.