Run janitorial cleanup for this flake with dendritic-aware linting...
Run cleanup and linting for this dendritic NixOS flake with awareness of repository-specific conventions and pattern conflicts.
This repository has custom lint infrastructure that respects exclusions:
Primary command: nix run .#lint
--ignore '.agents/**'--exclude '.agents'Format command: nix run .#fmt
Pre-commit hook: Automatically installed in dev shell
git commitAlways excluded (configured in lint scripts):
.agents/skills/** - Template code with placeholders like <SERVICE-NAME>Review carefully before touching:
modules/flake-parts/host-configurations.nix - Host collector, module resolution may be intentionalmodules/flake-parts/lib.nix - Helper functions used by loader_ - Work-in-progress code intentionally not importedsecrets/ - Never lint or modify secretsStatix and deadnix don't understand the dendritic pattern. Here's how to resolve conflicts:
Statix suggests:
# Statix: "Consider using mkEnableOption"
options.myFeature.enable = lib.mkEnableOption "myFeature";
config = lib.mkIf cfg.enable { ... };
Dendritic pattern requires: Import-to-enable (no enable options)
# Correct dendritic pattern
flake.modules.nixos.myFeature = {
services.myFeature.enable = true; # Enabled by default
};
Resolution: REJECT statix suggestion. Modules in this repo are correct.
Exception: Containerized services (in services/containers/) conventionally use enable options due to heavier lifecycle management.
Statix suggests: Removing "manual inherit" in loader files
Dendritic loaders need: Explicit inherit for clarity in import resolution
Resolution:
modules/flake-parts/ directorystatix fix --ignore manual_inheritDeadnix flags: Unused inputs or config arguments
Dendritic modules often need: These for future extensibility or flake-parts structure
Resolution:
flake-parts/): Keep arguments, they're infrastructure_ prefix for intentionally unused: { _config, lib, ... }: ...Statix flags: Multiple definitions of same attribute
Collector pattern uses: Same aspect name across files (configs merge)
Resolution: This is correct! Collector pattern intentionally defines same name in multiple files.
flake.modules.nixos.syncthing defined in base module AND each hostlib.mkMerge automaticallyWhen nix flake check fails, diagnose the pattern:
Likely cause: Conditional imports (dendritic anti-pattern)
Example:
# ā Causes infinite recursion
imports = lib.mkIf someCondition [ someModule ];
Fix: Load dendritic-pattern skill to diagnose and fix conditional import issues
Likely cause: Collector pattern conflict without lib.mkDefault
Example:
# Two modules define same value without merge strategy
# Module A: services.myapp.port = 8080;
# Module B: services.myapp.port = 9090;
Fix: Base module should use lib.mkDefault, host overrides without
Likely cause: Cross-class import (nixos ā darwin or vice versa)
Example:
# ā Importing NixOS module into Darwin context
flake.modules.darwin.myFeature = {
imports = [ config.flake.modules.nixos.someFeature ];
};
Fix: Extract shared code to generic class, import generic into both
Likely cause: Malformed flake-parts module
Fix: Check module exports flake.modules.<class>.<name> correctly
These fixes are safe in this repository:
ā
Empty let blocks
ā Formatting
nix run .#fmt ā Legacy syntax
rec { ... } ā separate let bindingā ļø Anything in modules/flake-parts/
ā ļø Unused function arguments
ā ļø Suggestions to add options
mkEnableOption suggestionsā ļø Changes to imports
ā ļø lib.mkIf/lib.mkMerge changes
ā Files with # statix: ignore comments
ā Template files (already excluded)
ā Secrets directory
ā Host hardware-configuration.nix (generated by nixos-generate-config)
nix run .#lint
Review output and categorize:
For each error, ask:
Present findings:
Found 15 issues:
- 8 safe fixes (formatting, empty let blocks)
- 5 enable option suggestions (REJECT - dendritic conflict)
- 2 unused arguments in loader (KEEP - infrastructure)
Auto-apply 8 safe fixes?
For safe fixes:
nix run .#fmt # Format
# Manual fixes for specific issues
For statix fixes (carefully):
# Review each fix before applying
statix fix --ignore '.agents/**' <specific-file>
For deadnix (carefully):
# Only in non-loader files
deadnix -e --exclude '.agents' <specific-file>
nix run .#lint
nix flake check --no-build # Verify no eval errors
Summary of:
NEVER auto-apply mkEnableOption suggestions
# ā Statix suggests this - REJECT IT
options.myFeature.enable = lib.mkEnableOption "myFeature";
config = lib.mkIf cfg.enable { ... };
# ā
Dendritic pattern (correct for this repo)
flake.modules.nixos.myFeature = {
services.myFeature.enable = true; # Import-to-enable
};
Why: Breaks dendritic import-to-enable pattern. Features activate via imports, not enable options (except containers).
NEVER run cleanup on template files
# ā WRONG
statix fix .agents/skills/flake-module-creator/assets/
Why: Templates contain placeholders like <SERVICE-NAME> which are intentionally invalid Nix syntax. Already excluded via --ignore '.agents/**'.
NEVER auto-fix loader files without careful review
Files requiring extra care:
modules/flake-parts/host-configurations.nixmodules/flake-parts/lib.nixmodules/flake-parts/meta.nixWhy: Central infrastructure. Manual imports, explicit inherits, and unused arguments may be intentional for:
Breaking loader breaks entire flake.
NEVER ignore flake check failures
# ā WRONG - Suppressing without diagnosis
# (just run fmt and ignore flake check errors)
Why: nix flake check catches:
These indicate dendritic pattern violations. Fix root cause, don't suppress.
NEVER modify dotfile-managed program configs
See docs/agents/dotfiles-policy.md for complete list.
Programs managed in ~/dotfiles (never configure here):
Why: Configuration lives in separate dotfiles repo. NixOS only installs packages, never configures these programs.
NEVER apply fixes that change imports without understanding impact
# ā DANGEROUS - Removing "unused" import
imports = [
# config.flake.modules.nixos.baseModule # Statix: unused?
];
Why: Imports are the dendritic wiring. Removing imports can:
Always verify import is truly unused by checking what it provides.
NEVER fix "repeated keys" in collector patterns
# Multiple files define same aspect - THIS IS CORRECT
# modules/services/syncthing.nix
flake.modules.nixos.syncthing = { ... };
# modules/hosts/host1.nix - SAME NAME, intentional
flake.modules.nixos.syncthing = { ... };
Why: Collector pattern intentionally uses same aspect name across files. Configs merge automatically via lib.mkMerge. Statix flags this as error but it's correct dendritic pattern.
When cleanup reveals dendritic pattern issues:
imports, options, or loader files