Thank you for your interest in contributing to khanelinix! This document provides guidelines for contributing to this Nix-based dotfiles configuration.
-
Library Usage:
- Single-line
with lib;and generalwith pkgs;usage are acceptable patterns that do not break static analysis. Avoid block-levelwith lib;that obscures variable origin. - Prefer inlining
lib.usages toinherit (lib)when 1 or 2 usages of the library function - Keep
let inblocks scoped as close to usage as possible
- Single-line
-
Imports: Group related imports together within the inputs or let binding
-
Naming:
- Use camelCase for variables
- Use kebab-case for files/directories
-
Options: Define namespace-scoped options (khanelinix.*)
- Reduce option repetition by using a shared top level option
- Use top level option values throughout configuration when possible
-
Conditionals: Prefer
lib.mkIf,lib.optionals,lib.optionalStringinstead ofif then elseexpressions- Only use
if then elsewhen it makes the expression too complicated using other means
- Only use
-
Organization: Group related items within each module
-
Theming: Handle theme toggling with conditional paths and mkIf expressions
- Prefer specific theme module customizations over stylix
- Prefer all theme modules over the defaults of each module
-
Reduce Repetition: Utilize Nix functions and abstractions to minimize duplicated code
-
Source Patching in Derivations:
- Prefer
fetchpatch2for upstream commits and pull requests when a fixed patch URL is available. - For
fetchpatch2, start withhash = lib.fakeHash;, build once, and copy thegot:SRI hash from the fixed-output derivation failure into the derivation. - Do not use
nix-prefetch-urlas the final hash source forfetchpatch2.nix-prefetch-urlhashes the raw downloaded bytes, whilefetchpatch2normalizes the patch before hashing its output. nix-prefetch-urlis still appropriate for plainfetchurland similar raw-download fetchers.- Prefer
substituteInPlaceover ad-hocsed/perlfor local source edits inside derivations. - Prefer
--replace-failso builds fail loudly when upstream source changes, signaling that the patch should be reviewed or removed.
- Prefer
- Host specific customization: Place in host named configuration modules
- Platform specific customization: Place in nixos/darwin modules
- Home application specific customization: Place in home modules
- User specific customization: Place in user home configuration
- Prefer handling customization in home configuration, wherever possible
This repository follows a Conventional Commits style format with a subject and, for anything non-trivial, a body explaining the reason for the change:
type(scope): description
[blank line]
[why this change was needed]
[important context, constraints, or tradeoffs]
feat(codex): add mcp integrationfix(waybar): restore accidentally deleted iconrefactor(nix): tweak gc scheduledocs(ai-tools): add fixup/autosquash workflow to git skillchore(flake): lock update
- Use lowercase for the description
- Keep the subject line under 50 characters when possible
- Use imperative mood ("add", "fix", "update", not "added", "fixed", "updated")
- No trailing period in the subject line
- Keep
typeto standard values (feat,fix,refactor,docs,chore) - Keep
scopespecific to the primary area affected - Breaking changes may use
!(for example:refactor(devShells)!: ...) - Prefer a commit body for any change that is not completely obvious
- Subject is the what; body is the why, plus any important implementation context or constraints
- Avoid one-line commits unless the change is genuinely trivial
- Write the body as short prose, not a changelog dump
- Format code: Run
nix fmt(uses treefmt with nixfmt, deadnix, statix) - Run pre-commit hooks:
nix run .#checks.${system}.pre-commit-hooks - Check a specific system:
nix build .#nixosConfigurations.${host}.config.system.build.toplevel
- Follow the code style guidelines above
- Test your changes on your system
- Ensure all formatting and checks pass
- Use secrets management with sops-nix for any sensitive data
- Create atomic commits - each commit should represent one logical change
- Prefer one module per commit when changes are logically independent
- Follow the commit message convention, including a body that explains why
- Ensure pre-commit hooks pass
- Test that the configuration builds successfully
- Never commit secrets or keys to the repository
- Use sops-nix for secrets management
- Follow security best practices in configurations
- Use the Security Auditor agent for security-related changes
Thank you for contributing to khanelinix!