Create development environment templates and project scaffolding with Nix flakes. Use when creating new project templates, setting up dev shells, configuring language-specific environments, or integrating with CI/CD.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
name: template-creation description: Create development environment templates and project scaffolding with Nix flakes. Use when creating new project templates, setting up dev shells, configuring language-specific environments, or integrating with CI/CD.
Template Creation Guide
Expert guidance for creating comprehensive development environment templates with Nix flakes.
Core Principles
- Reproducibility - Same template produces identical environments everywhere
- Developer experience - Fast to use, easy to understand
- Language-specific best practices - Follow conventions for each ecosystem
- Integration-ready - Works with editors, CI/CD, containers
- Maintainability - Easy to update dependencies and configurations
Template Creation Workflow
Copy this checklist when creating templates:
Template Creation Progress:
- [ ] Step 1: Identify target language/framework requirements
- [ ] Step 2: Design flake structure and inputs
- [ ] Step 3: Create devShell with all needed tools
- [ ] Step 4: Add language-specific configuration files
- [ ] Step 5: Configure editor/IDE integration
- [ ] Step 6: Add CI/CD configuration
- [ ] Step 7: Write documentation
- [ ] Step 8: Test on clean system
Flake Template Structure
Basic Template Layout
template/
├── flake.nix # Main flake definition
├── flake.lock # Locked dependencies
├── .envrc # direnv integration
├── .gitignore # Git ignore patterns
├── README.md # Documentation
└── src/ # Source code placeholder
Standard flake.nix Template
{
description = "Project description";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Add development tools here
];
shellHook = ''
echo "Development environment loaded"
'';
};
# Optional: packages, apps, etc.
}
);
}
Language-Specific Templates
Node.js/TypeScript
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs_20
nodePackages.npm
nodePackages.typescript
nodePackages.typescript-language-server
];
shellHook = ''
export PATH="$PWD/node_modules/.bin:$PATH"
'';
};
Configuration files to include:
tsconfig.json- TypeScript configurationpackage.json- Package manifest.prettierrc- Code formatting.eslintrc.js- Linting rules
Python
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
python311
python311Packages.pip
python311Packages.virtualenv
python311Packages.black
python311Packages.mypy
pyright
];
shellHook = ''
# Create venv if it doesn't exist
if [ ! -d .venv ]; then
python -m venv .venv
fi
source .venv/bin/activate
'';
};
Configuration files to include:
pyproject.toml- Project configurationrequirements.txtorpoetry.lock- Dependencies.python-version- Python version
Rust
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
rust-analyzer
clippy
rustfmt
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
Configuration files to include:
Cargo.toml- Package manifestrust-toolchain.toml- Toolchain version.rustfmt.toml- Formatting rules
Go
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
golangci-lint
delve
];
shellHook = ''
export GOPATH="$PWD/.go"
export PATH="$GOPATH/bin:$PATH"
'';
};
Editor Integration
VS Code
.vscode/settings.json:
{
"editor.formatOnSave": true,
"nix.enableLanguageServer": true,
"nix.serverPath": "nil"
}
direnv (.envrc)
use flake
CI/CD Integration
GitHub Actions
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: your-cache
- run: nix build
- run: nix flake check
Template Quality Checklist
-
nix flake checkpasses - DevShell includes all required tools
- Editor integration configured
- CI/CD workflow included
- README with setup instructions
-
.gitignorecovers generated files - License file included
- Works on Linux and macOS
Common Patterns
Multi-Shell Template
devShells = {
default = pkgs.mkShell {
# Default development environment
};
ci = pkgs.mkShell {
# Minimal CI environment
};
full = pkgs.mkShell {
# Full environment with optional tools
};
};
Cross-Platform Considerations
buildInputs = with pkgs; [
# Common tools
git
jq
] ++ lib.optionals stdenv.isDarwin [
# macOS-specific
darwin.apple_sdk.frameworks.Security
] ++ lib.optionals stdenv.isLinux [
# Linux-specific
inotify-tools
];
See Also
- Flake management: See managing-flakes for input and lock file management
- Writing Nix: See writing-nix for Nix code best practices
- Module scaffolding: See scaffolding-modules for NixOS module templates
More by khaneliman
View allManages encrypted secrets using sops-nix and age. Use when adding new secrets, rotating keys, debugging secret access, or setting up secret management for new hosts/users.
Conduct thorough, actionable code reviews focusing on critical issues. Use when reviewing pull requests, analyzing code changes, identifying bugs, security vulnerabilities, or suggesting improvements that developers will actually implement.
Comprehensive security vulnerability assessment and configuration review. Use when analyzing code for security flaws, reviewing dependencies for CVEs, auditing access controls, detecting secrets exposure, or validating compliance with security frameworks.
khanelinix directory structure and module placement. Use when creating new modules, deciding where files belong, or understanding the modules/ organization. Covers platform separation (nixos/darwin/home/common) and auto-discovery.
