Convention-based Nix project builder, based on adios-flake and inspired by blueprint.
Drop your Nix files in the right places, and red-tape turns them into a complete flake — packages, devshells, checks, NixOS hosts, modules, templates, and lib — with zero boilerplate.
{
inputs = {
red-tape.url = "github:phaer/red-tape";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs:
inputs.red-tape.mkFlake {
inherit inputs;
src = ./.;
};
}Then just add files following the conventions below.
.
├── package.nix # → packages.${system}.default
├── packages/
│ ├── hello.nix # → packages.${system}.hello
│ └── goodbye/default.nix # → packages.${system}.goodbye
├── devshell.nix # → devShells.${system}.default
├── devshells/
│ └── backend.nix # → devShells.${system}.backend
├── formatter.nix # → formatter.${system}
├── checks/
│ └── mycheck.nix # → checks.${system}.mycheck
├── hosts/
│ ├── myhost/configuration.nix # → nixosConfigurations.myhost
│ └── custom/default.nix # → nixosConfigurations.custom (custom builder)
├── modules/
│ └── nixos/
│ ├── server.nix # → nixosModules.server
│ └── injected.nix # → nixosModules.injected
├── templates/
│ ├── default/flake.nix # → templates.default
│ └── minimal/flake.nix # → templates.minimal
└── lib/default.nix # → lib (re-exported as flake output)
All package/devshell/check/formatter files receive { pkgs, lib, system, flake, inputs, perSystem, ... }.
If you keep Nix files in a subdirectory (e.g. nix/), pass prefix = "nix" to mkFlake.
red-tape.mkFlake {
# Required
inputs = { ... }; # Flake inputs (must include self)
src = ./.; # Project root to scan
# Optional
self = inputs.self; # Defaults to inputs.self
prefix = null; # Subdirectory prefix (e.g. "nix")
systems = [ ... ]; # Target systems (default: x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin)
modules = []; # Additional adios modules
perSystem = null; # Per-system function (adios-flake passthrough)
config = {}; # Extra adios config paths
flake = {}; # Extra raw flake outputs
}red-tape automatically adds packages and devshells to checks:
- Each package becomes
checks.${system}.pkgs-${name} - Each devshell becomes
checks.${system}.devshell-${name} - Each package's
passthru.testsare included aschecks.${system}.pkgs-${name}-${test}
Run all checks with:
nix flake check -LBy default, red-tape supports two host types:
File in hosts/${name}/ |
Type | Output Key |
|---|---|---|
configuration.nix |
nixos |
nixosConfigurations |
default.nix |
custom |
nixosConfigurations |
Custom hosts (default.nix) receive { flake, inputs, hostName } and can return anything.
# In your flake.nix
red-tape.mkFlake {
inherit inputs;
src = ./.;
modules = [
(import "${inputs.red-tape}/contrib/darwin.nix")
(import "${inputs.red-tape}/contrib/home-manager.nix")
(import "${inputs.red-tape}/contrib/system-manager.nix")
];
};This adds:
darwin-configuration.nix→darwinConfigurations+modules/darwin/→darwinModules(via nix-darwin)home-configuration.nix→homeConfigurations+modules/home/→homeModules(via home-manager)system-configuration.nix→systemConfigs(via system-manager)
By default, only modules/nixos/ → nixosModules is wired. Contrib modules add more:
red-tape.mkFlake {
inherit inputs;
src = ./.;
modules = [
(import "${inputs.red-tape}/contrib/darwin.nix") # modules/darwin/ → darwinModules
(import "${inputs.red-tape}/contrib/home-manager.nix") # modules/home/ → homeModules
];
};Or define custom types via config:
red-tape.mkFlake {
inherit inputs;
src = ./.;
config = {
"red-tape/modules" = {
moduleTypes = { flake = "flakeModules"; };
};
};
};| Module | What it does |
|---|---|
contrib/darwin.nix |
darwin host type → darwinConfigurations, modules/darwin/ → darwinModules |
contrib/home-manager.nix |
home-manager host type → homeConfigurations, modules/home/ → homeModules |
contrib/system-manager.nix |
system-manager host type → systemConfigs |
| red-tape | blueprint | flake-parts | |
|---|---|---|---|
| Approach | Filesystem conventions | Filesystem conventions | Module options |
| Module system | adios-flake | None (pure functions) | NixOS modules |
| Boilerplate | Minimal | Minimal | More explicit |
| Extension | Contrib modules | Limited | flake-parts modules |
| Host support | NixOS + contrib (darwin, home-manager, system-manager) | None | Via modules |
| Learning curve | Know the directory layout | Know the directory layout | Know the option schema |
MIT