Compare commits
2 Commits
439e8bd489
...
0822bc9eac
| Author | SHA1 | Date | |
|---|---|---|---|
| 0822bc9eac | |||
| 70e7817f33 |
130
AGENTS.md
130
AGENTS.md
@@ -4,28 +4,132 @@
|
|||||||
**NEVER run git commands.** This repo uses Jujutsu (`jj`). Use `jj status`, `jj diff`, `jj commit`, etc.
|
**NEVER run git commands.** This repo uses Jujutsu (`jj`). Use `jj status`, `jj diff`, `jj commit`, etc.
|
||||||
|
|
||||||
## Build Commands
|
## Build Commands
|
||||||
|
|
||||||
|
### Local Development
|
||||||
```bash
|
```bash
|
||||||
nix run .#build # Build current host config
|
nix run .#build # Build current host config
|
||||||
nix run .#build -- <hostname> # Build specific host (chidi, jason, michael, mindy, tahani)
|
nix run .#build -- <hostname> # Build specific host (chidi, jason, michael, mindy, tahani)
|
||||||
nix run .#apply # Build and apply locally (darwin-rebuild/nixos-rebuild switch)
|
nix run .#apply # Build and apply locally (darwin-rebuild/nixos-rebuild switch)
|
||||||
nix flake check # Validate flake
|
nix flake check # Validate flake
|
||||||
|
```
|
||||||
|
|
||||||
# Remote NixOS deployment (colmena)
|
### Remote Deployment (NixOS only)
|
||||||
|
```bash
|
||||||
colmena build # Build all NixOS hosts
|
colmena build # Build all NixOS hosts
|
||||||
colmena apply --on <host> # Deploy to specific NixOS host (michael, mindy, tahani)
|
colmena apply --on <host> # Deploy to specific NixOS host (michael, mindy, tahani)
|
||||||
colmena apply # Deploy to all NixOS hosts
|
colmena apply # Deploy to all NixOS hosts
|
||||||
```
|
```
|
||||||
|
|
||||||
## Code Style
|
### Formatting
|
||||||
- **Formatter**: Alejandra with tabs (run `alejandra .` to format)
|
```bash
|
||||||
- **Function args**: Destructure on separate lines `{inputs, pkgs, ...}:`
|
alejandra . # Format all Nix files
|
||||||
- **Imports**: Use relative paths from file location (`../../profiles/foo.nix`)
|
```
|
||||||
- **Attribute sets**: One attribute per line, trailing semicolons
|
|
||||||
- **Lists**: `with pkgs; [...]` for packages, one item per line for long lists
|
|
||||||
|
|
||||||
## Structure
|
## Code Style
|
||||||
- `hosts/<name>/` - Per-machine configs (darwin: chidi, jason | nixos: michael, mindy, tahani)
|
|
||||||
- `profiles/` - Reusable program/service configs (imported by hosts)
|
### Formatter
|
||||||
- `modules/` - Custom NixOS/darwin modules
|
- **Tool**: Alejandra
|
||||||
- `lib/` - Shared constants and utilities
|
- **Config**: `alejandra.toml` specifies tabs for indentation
|
||||||
- `secrets/` - SOPS-encrypted secrets (`.sops.yaml` for config)
|
- **Command**: Run `alejandra .` before committing
|
||||||
|
|
||||||
|
### File Structure
|
||||||
|
- **Hosts**: `hosts/<hostname>/` - Per-machine configurations
|
||||||
|
- Darwin: `chidi`, `jason`
|
||||||
|
- NixOS: `michael`, `tahani`
|
||||||
|
- **Profiles**: `profiles/` - Reusable program/service configurations (imported by hosts)
|
||||||
|
- **Modules**: `modules/` - Custom NixOS/darwin modules
|
||||||
|
- **Lib**: `lib/` - Shared constants and utilities
|
||||||
|
- **Secrets**: `secrets/` - SOPS-encrypted secrets (`.sops.yaml` for config)
|
||||||
|
|
||||||
|
### Nix Language Conventions
|
||||||
|
|
||||||
|
**Function Arguments**:
|
||||||
|
```nix
|
||||||
|
{inputs, pkgs, lib, ...}:
|
||||||
|
```
|
||||||
|
Destructure arguments on separate lines. Use `...` to capture remaining args.
|
||||||
|
|
||||||
|
**Imports**:
|
||||||
|
```nix
|
||||||
|
../../profiles/foo.nix
|
||||||
|
```
|
||||||
|
Use relative paths from file location, not absolute paths.
|
||||||
|
|
||||||
|
**Attribute Sets**:
|
||||||
|
```nix
|
||||||
|
options.my.gitea = {
|
||||||
|
enable = lib.mkEnableOption "Gitea git hosting service";
|
||||||
|
bucket = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "S3 bucket name";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
One attribute per line with trailing semicolons.
|
||||||
|
|
||||||
|
**Lists with Packages**:
|
||||||
|
```nix
|
||||||
|
with pkgs;
|
||||||
|
[
|
||||||
|
age
|
||||||
|
alejandra
|
||||||
|
ast-grep
|
||||||
|
]
|
||||||
|
```
|
||||||
|
Use `with pkgs;` for package lists, one item per line.
|
||||||
|
|
||||||
|
**Modules**:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
cfg = config.my.feature;
|
||||||
|
in {
|
||||||
|
options.my.feature = {
|
||||||
|
enable = mkEnableOption "Feature description";
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
# configuration
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Destructure args on separate lines
|
||||||
|
- Use `with lib;` for brevity with NixOS lib functions
|
||||||
|
- Define `cfg` for config options
|
||||||
|
- Use `mkIf`, `mkForce`, `mkDefault` appropriately
|
||||||
|
|
||||||
|
**Conditional Platform-Specific Code**:
|
||||||
|
```nix
|
||||||
|
++ lib.optionals stdenv.isDarwin [
|
||||||
|
_1password-gui
|
||||||
|
dockutil
|
||||||
|
]
|
||||||
|
++ lib.optionals stdenv.isLinux [
|
||||||
|
lm_sensors
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
- **Option names**: `my.<feature>.<option>` for custom modules
|
||||||
|
- **Hostnames**: Lowercase, descriptive (e.g., `michael`, `tahani`)
|
||||||
|
- **Profile files**: Descriptive, lowercase with hyphens (e.g., `homebrew.nix`)
|
||||||
|
|
||||||
|
### Secrets Management
|
||||||
|
- Use SOPS for secrets (see `.sops.yaml`)
|
||||||
|
- Never commit unencrypted secrets
|
||||||
|
- Secrets files in `hosts/<host>/secrets.nix` import SOPS-generated files
|
||||||
|
|
||||||
|
### Imports Pattern
|
||||||
|
Host configs import:
|
||||||
|
1. System modules (`modulesPath + "/..."`)
|
||||||
|
2. Host-specific files (`./disk-config.nix`, `./hardware-configuration.nix`)
|
||||||
|
3. SOPS secrets (`./secrets.nix`)
|
||||||
|
4. Custom modules (`../../modules/*.nix`)
|
||||||
|
5. Base profiles (`../../profiles/*.nix`)
|
||||||
|
6. Input modules (`inputs.<module>.xxxModules.module`)
|
||||||
|
|
||||||
|
Home-manager users import profiles in a similar manner.
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{
|
{...}: {
|
||||||
...
|
|
||||||
}: {
|
|
||||||
programs.aerospace = {
|
programs.aerospace = {
|
||||||
enable = true;
|
enable = true;
|
||||||
launchd.enable = true;
|
launchd.enable = true;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
programs.mise = {
|
programs.mise = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableFishIntegration = true;
|
enableFishIntegration = true;
|
||||||
enableZshIntegration = true;
|
globalConfig.settings = {
|
||||||
settings = {
|
|
||||||
auto_install = false;
|
auto_install = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
repo_root_style = "bold cyan";
|
repo_root_style = "bold cyan";
|
||||||
repo_root_format = "[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ";
|
repo_root_format = "[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ";
|
||||||
};
|
};
|
||||||
custom.scm = {
|
custom.scm = {
|
||||||
when = "jj-starship detect";
|
when = "jj-starship detect";
|
||||||
shell = ["jj-starship" "--strip-bookmark-prefix" "cschmatzler/" "--truncate-name" "20" "--bookmarks-display-limit" "1"];
|
shell = ["jj-starship" "--strip-bookmark-prefix" "cschmatzler/" "--truncate-name" "20" "--bookmarks-display-limit" "1"];
|
||||||
format = "$output ";
|
format = "$output ";
|
||||||
|
|||||||
Reference in New Issue
Block a user