- Nix 100%
| c3 | feat: update package importing | |
| java | feat: update package importing | |
| meta | chore: rename template to meta | |
| python | fix(python): deprecate direnv flakes | |
| rust | feat(rust): remove cranelift codegen | |
| flake.nix | chore: rename template to meta | |
| LICENSE | chore: add LICENSE | |
| README.md | doc(comms): clarify in readme | |
hyperpastels flake templates
This repository contains my personal nix templates that I use to initialize projects.
Project Layout
The flake.nix contains entries for every template offered by this set.
Each entry contains the path to the template folder, which intern contains all the files that will be copied by the init command.
All template folders are placed adjacent to the flake file, at the root of this repository.
Using these templates
Nix allows the initialization of directories using the command nix flake init. This command will copy all the template files to the current working directory (so invoke it once you're inside the project folder).
To use these templates, invoke it as
nix flake init --template "git+https://codeberg.org/hyperpastel/flake-templates.git"#<template_name>
Replace <template_name> with the name of any of the folders in this directory for the corresponding template, i.e. replacing it with rust to initialize a project for rust.
However, pasting the URL everytime is tedious. Instead, you can add this repository's flake to your systems nix registry, allowing it to be stored locally and then reused under an alias.
To do this, your system needs to already be configured through flakes (see this guide for details).
Then, inside your systems flake.nix, add this repository as a flake input:
{
inputs = {
# ...
templates.url = "git+https://codeberg.org/hyperpastel/flake-templates.git";
# ...
};
# ...
}
The name of the input can be chosen freely, and especially if using several template sets, you may wish to give it a more decisive name. Then, at whichever place you configure your system's environment, add the following:
nix.registry.project-templates.flake = templates;
The name on the left can be chosen freely again, the one on the right must match your earlier declaration. Remember to add the flake input as package parameters at the top of that file, likely something like:
{ templates, pkgs, lib, ... }:
Rebuild your systems configuration, i.e. through
sudo nixos-rebuild switch --flake /path/to/config/flake
You can now invoke the previous init command as
nix flake init --template project-template#rust
assuming you've named the registry entry the same way as above.