Guidelines for contributing to this NixOS dotfiles repository.
See docs/ARCHITECTURE.md for a detailed overview of the codebase structure.
# Clone the repository
git clone git@github.com:robcohen/dotfiles.git
cd dotfiles
# Enter development shell (provides formatting tools, etc.)
nix develop
# Or use direnv
direnv allowAll Nix files are formatted with nixfmt. Run before committing:
nix fmt- Files:
kebab-case.nix(e.g.,bluetooth-common.nix) - Options:
camelCase(e.g.,enablePermissions) - Modules: Descriptive names matching functionality
New modules should follow this template:
# modules/category/my-module.nix
# Brief description of what this module does
{ config, lib, pkgs, ... }:
let
cfg = config.category.myModule;
in {
options.category.myModule = {
enable = lib.mkEnableOption "description of module";
someOption = lib.mkOption {
type = lib.types.str;
default = "value";
description = "What this option does";
};
};
config = lib.mkIf cfg.enable {
# Configuration here
};
}Standardize on this order:
{ config, lib, pkgs, inputs, ... }:- Create
profiles/programs/myprogram.nix - Import it in
profiles/user.nix - Optionally add feature gating:
lib.mkIf (hasFeature "development") { ... }
- Create
modules/hardware/mydevice.nixwith options - Import in relevant host configurations
- Document options in the file
- Prefer extracting common code to modules
- Use
lib.mkIffor conditional configuration - Add comments explaining non-obvious settings
This repository uses pre-commit hooks for:
- detect-secrets: Prevents accidental secret commits
- gitleaks: Scans for hardcoded credentials
- nixfmt-check: Ensures Nix formatting
Install hooks:
pre-commit installRun manually:
pre-commit run --all-files# Test NixOS build
nixos-rebuild build --flake .#hostname
# Test Home Manager build
home-manager build --flake .#user@hostname# Show all outputs
nix flake show
# Check for errors
nix flake check# See what would change
nixos-rebuild dry-activate --flake .#hostnameFollow conventional commits:
type(scope): description
[optional body]
Types:
feat: New featurefix: Bug fixrefactor: Code restructuringdocs: Documentationchore: Maintenance
Examples:
feat(bluetooth): add common Bluetooth module
fix(snix): correct resume device UUID
refactor(hosts): extract system tuning to module
docs: add ARCHITECTURE.md
- Create a feature branch
- Make changes following the style guide
- Run
nix fmtandpre-commit run --all-files - Test build on at least one host
- Submit PR with clear description
- Never commit secrets - Use SOPS for sensitive data
- Review security implications - Especially for kernel params, firewall rules
- Document security trade-offs - If disabling security features, explain why
- Check existing code for patterns
- Review docs/ for guides
- Open an issue for questions