|
|
|
|
@@ -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/<name>/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
|
|
|
|
|
```
|
|
|
|
|
|