diff --git a/AGENTS.md b/AGENTS.md index c257133..98d0d4b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -206,3 +206,98 @@ Key inputs: - `sops-nix` - Secrets management - `lanzaboote` - Secure boot - `jovian` - Steam Deck support (allyx) + +## Lib Module (`lib/`) + +Custom utility library exposed via `lib.mjallen.*` through Snowfall Lib. Used for creating modules and managing versions. + +### Directory Structure +``` +lib/ +├── default.nix # Entry point: exports module, file, versioning +├── README.md # Detailed documentation +├── module/ # Module creation helpers +│ └── default.nix +├── file/ # File/path utilities +│ └── default.nix +└── versioning/ # Multi-source version pinning + └── default.nix +``` + +### Module Utilities (`lib.mjallen.module`) + +**`mkModule`** - Create NixOS service modules with standardized options: +```nix +lib.mjallen.module.mkModule { + config, name, description, options, moduleConfig, domain ? "services" +} +``` +Standard options: `enable`, `port`, `reverseProxy`, `firewall`, `createUser`, `configureDb`, `redis`, `puid`, `pgid`, `timeZone`, etc. + +**`mkContainerService`** - For Podman/OCI containers (auto-generates container definition): +```nix +lib.mjallen.module.mkContainerService { + config, name, image, internalPort, description, options, volumes, environment +} +``` + +**`mkSopsEnvFile`** - Generate SOPS secrets + template env-file: +```nix +lib.mjallen.module.mkSopsEnvFile { + secrets, name, content, restartUnit, owner, group, mode, sopsFile +} +``` + +**Option Helpers:** +- `mkOpt type default description` - Standard option +- `mkBoolOpt default description` - Boolean option +- `mkReverseProxyOpt name` - Caddy reverse proxy sub-options + +**Convenience Shorthands:** +- `enabled` = `{ enable = true; }` +- `disabled` = `{ enable = false; }` + +### Home Manager Utilities + +**`mkHomeModule`** - Create Home Manager modules: +```nix +lib.mjallen.module.mkHomeModule { + config, domain, name, description, options, moduleConfig +} +``` + +### File Utilities (`lib.mjallen.file`) + +- `readFile path` - Read file contents +- `pathExists path` - Check if path exists +- `safeImport path default` - Safe Nix import +- `getFile relativePath` - Get path relative to flake root +- `importModulesRecursive path` - Recursively discover Nix modules +- `scanSystems systemsPath` - Discover system configurations +- `filterNixOSSystems systems` - Filter for Linux systems +- `filterDarwinSystems systems` - Filter for macOS systems +- `scanHomes homesPath` - Parse home-manager configurations + +### Versioning Utilities (`lib.mjallen.versioning`) + +For packages with `version.json` (multi-variant source pinning): + +- `selectVariant spec variantName system` - Select variant from spec +- `render value variables` - Template substitution (`${var}`) +- `mkSrc pkgs comp variables` - Build single source +- `mkAllSources pkgs selected` - Build all sources for selected variant + +See `lib/versioning/default.nix` for full API and `docs/version.schema.json` for schema. + +### Usage in Packages + +Create `packages//version.json` with variant definitions, then use: +```nix +let + versioning = inputs.self.lib.mjallen.versioning; + spec = inputs.self.lib.mjallen.file.readFile ./version.json; + selected = versioning.selectVariant spec variantName system; + sources = versioning.mkAllSources pkgs selected; +in +# Use sources.componentName for each source +``` diff --git a/checks/pre-commit-hooks/default.nix b/checks/pre-commit-hooks/default.nix index e8597b2..8044db9 100644 --- a/checks/pre-commit-hooks/default.nix +++ b/checks/pre-commit-hooks/default.nix @@ -18,5 +18,12 @@ pre-commit-hooks-nix.lib.${pkgs.stdenv.hostPlatform.system}.run { lib.snowfall.fs.get-file "treefmt.nix" ); }; + nixfmt-rfc-style = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + statix = { + enable = true; + }; }; } diff --git a/modules/home/programs/opencode/default.nix b/modules/home/programs/opencode/default.nix index 293c0a3..6b4d71b 100644 --- a/modules/home/programs/opencode/default.nix +++ b/modules/home/programs/opencode/default.nix @@ -46,8 +46,8 @@ in output = [ "text" ]; }; limit = { - context = 262144; - output = 262144; + context = 131072; + output = 32768; }; }; }; diff --git a/modules/nixos/services/ai/default.nix b/modules/nixos/services/ai/default.nix index d662ace..c100d27 100755 --- a/modules/nixos/services/ai/default.nix +++ b/modules/nixos/services/ai/default.nix @@ -68,7 +68,7 @@ let "30" "--jinja" "--ctx-size" - "4096" + "131072" "--threads" "8" "--batch-size" diff --git a/modules/nixos/system/default.nix b/modules/nixos/system/default.nix index a9e6a65..ad2ebac 100644 --- a/modules/nixos/system/default.nix +++ b/modules/nixos/system/default.nix @@ -11,6 +11,7 @@ in brightnessctl dconf disko + kdiskmark nil nix-output-monitor nixos-anywhere