Claude memory, second brain, skills
This commit is contained in:
@@ -70,76 +70,111 @@ emacsclient -c -e '(switch-to-buffer (get-buffer-create "test"))'
|
|||||||
emacsclient -e '(message "hello")'
|
emacsclient -e '(message "hello")'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Code Style Guidelines
|
## Repository Structure
|
||||||
|
|
||||||
### File Organization
|
```
|
||||||
- **Home-manager modules**: `modules/home-manager/<name>.nix`
|
azos/
|
||||||
- **NixOS modules**: `modules/nixos/<name>.nix`
|
├── flake.nix # Main flake
|
||||||
- **Imports**: All modules in `modules/home-manager/default.nix` and `modules/nixos/default.nix` (alphabetical order)
|
├── home-manager/home.nix # Home-manager entry point; manually imports all modules
|
||||||
- **Home config**: `home-manager/home.nix` - main home-manager user config
|
├── _machines/ # Per-machine NixOS configs (pass suiteModules as specialArgs)
|
||||||
- **Custom packages**: `pkgs/` - custom package definitions
|
├── nixos/ # NixOS system configs (configuration.nix, configuration-vm.nix, etc.)
|
||||||
- **Overlays**: `overlays/` - package overlays (addpkgs, modifications, unstable-packages)
|
├── features/ # Machine-specific home-manager features (auto-discovered)
|
||||||
|
├── overlays/ # Package overlays
|
||||||
|
├── shells/ # Dev shells
|
||||||
|
└── azos-core/ # Shared feature library (git submodule)
|
||||||
|
├── flake.nix
|
||||||
|
├── features/ # Shared/reusable features (auto-discovered)
|
||||||
|
├── overlays/ # Core overlays
|
||||||
|
└── _lib/ # Module schema helpers
|
||||||
|
```
|
||||||
|
|
||||||
|
Features are auto-discovered by `import-tree` — no central imports file. Each feature's
|
||||||
|
`default.nix` registers itself via `config.flake.modules.homeManager.<name>`. Modules are
|
||||||
|
then explicitly imported in `home-manager/home.nix` via `suiteModules.homeManager.<name>`.
|
||||||
|
|
||||||
|
**Where to put a new feature:**
|
||||||
|
- Shared / reusable across machines → `azos-core/features/<name>/default.nix`
|
||||||
|
- Machine-specific → `azos/features/<name>/default.nix`
|
||||||
|
|
||||||
|
## Code Style Guidelines
|
||||||
|
|
||||||
### Nix Module Template
|
### Nix Module Template
|
||||||
|
|
||||||
```nix
|
All features follow this flake-parts registration pattern:
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
isEnabled =
|
|
||||||
config.azos.<module-name>.enable;
|
|
||||||
in {
|
|
||||||
options.azos.<module-name>.enable = lib.mkOption {
|
|
||||||
default = true;
|
|
||||||
example = true;
|
|
||||||
type = lib.types.bool;
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf isEnabled {
|
```nix
|
||||||
home.packages = with pkgs; [ pkg1 pkg2 ];
|
{...}: {
|
||||||
|
config.flake.modules.homeManager.<name> = {
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
options.azos.<name>.enable = lib.mkOption {
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
type = lib.types.bool;
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.azos.<name>.enable {
|
||||||
|
home.packages = with pkgs; [pkg1 pkg2];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Naming Conventions
|
### Naming Conventions
|
||||||
- Option paths: `config.azos.<module-name>.<option>`
|
- Option paths: `azos.<module-name>.<option>`
|
||||||
- Enable option: `enable` (bool), default `true`
|
- Module names: kebab-case (`git-config`, `claude-memory`)
|
||||||
- Module names: kebab-case (`libreoffice.nix`, `git-config.nix`)
|
- Feature directories: kebab-case, one `default.nix` per feature
|
||||||
- Option names: may differ from filename (e.g., `git.nix` uses `azos.git-config`)
|
- Variables: kebab-case
|
||||||
- Variables: kebab-case (`isEnabled`)
|
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
- Indentation: 2 spaces
|
- Indentation: 2 spaces
|
||||||
- Let bindings: multi-line with `isEnabled` on its own line
|
- Packages: `with pkgs; [pkg1 pkg2]` (no trailing semicolon inside list)
|
||||||
- Packages: Use `with pkgs; [ ... ]` syntax
|
|
||||||
|
|
||||||
### Imports
|
### Imports
|
||||||
- Always include `{...}` for module args
|
- Always include `{...}` for the outer module args
|
||||||
- Standard args: `lib, config, pkgs, ...`
|
- Inner module args: `lib, config, pkgs, ...`
|
||||||
- NixOS config args: `inputs, outputs, lib, config, pkgs, ...`
|
|
||||||
- Use `./relative/path.nix` for local imports
|
|
||||||
|
|
||||||
### Option Patterns
|
### Option Patterns
|
||||||
- Boolean enable: `lib.mkOption { default = true; example = true; type = lib.types.bool; }`
|
- Boolean enable: `lib.mkOption { default = false; example = true; type = lib.types.bool; }`
|
||||||
- Conditional config: `lib.mkIf isEnabled { ... }`
|
- Conditional config: `lib.mkIf config.azos.<name>.enable { ... }`
|
||||||
- User-overridable: `lib.mkDefault`
|
- Auto-enable a dependency: `azos.<dep>.enable = lib.mkDefault true;`
|
||||||
- Force value: `lib.mkForce` (sparingly)
|
- Force value: `lib.mkForce` (sparingly)
|
||||||
|
|
||||||
|
### Extensible Options
|
||||||
|
For options that multiple modules should be able to contribute to, use attrset options:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
options.azos.<name>.things = lib.mkOption {
|
||||||
|
default = {};
|
||||||
|
type = lib.types.attrsOf lib.types.path; # or lines, str, etc.
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Any module can then add entries without modifying the owning feature. Examples in use:
|
||||||
|
- `azos.claude.globalSkills` — attrset of skill name → markdown file path
|
||||||
|
- `azos.claude.globalMdSections` — attrset of key → markdown string (merged into `~/.claude/CLAUDE.md`)
|
||||||
|
|
||||||
### Home-Manager vs NixOS
|
### Home-Manager vs NixOS
|
||||||
- Home-manager: `home.packages`, `home.file`, `programs.<program>`
|
- Home-manager: `home.packages`, `home.file`, `programs.<program>`
|
||||||
- NixOS: `config.services`, `environment.systemPackages`
|
- NixOS: `config.services`, `environment.systemPackages`
|
||||||
|
|
||||||
|
### Deploying Files
|
||||||
|
- Static file: `home.file."dest".source = ./file;`
|
||||||
|
- Generated text: `home.file."dest".text = "...";`
|
||||||
|
- Runtime script (e.g. merging JSON at activation): `home.activation.<name> = lib.hm.dag.entryAfter ["writeBoundary"] ''...'';`
|
||||||
|
|
||||||
### Suites System
|
### Suites System
|
||||||
Modules are organized into suites (defined in `azos-core/`):
|
Top-level suites group related features (defined in `azos-core/`):
|
||||||
- `azos.suites.base` - Base packages and config
|
- `azos.suites.base` — base packages and config
|
||||||
- `azos.suites.editor` - Editor tools
|
- `azos.suites.editor` — editor tools
|
||||||
- `azos.suites.dev` - Development tools
|
- `azos.suites.dev` — development tools
|
||||||
- `azos.suites.station` - Desktop applications
|
- `azos.suites.station` — desktop applications
|
||||||
- `azos.suites.exwm` - EXWM window manager
|
- `azos.suites.exwm` — EXWM window manager
|
||||||
- Enable in `home-manager/home.nix` with `azos.suites.<name>.enable = true;`
|
|
||||||
|
The machine suite (`azos.suites.lauretta`) enables the relevant suites for this machine.
|
||||||
|
|
||||||
### Specializations
|
### Specializations
|
||||||
NixOS supports specializations for alternative configurations:
|
NixOS supports specializations for alternative configurations:
|
||||||
@@ -158,33 +193,62 @@ specialisation = {
|
|||||||
|
|
||||||
## Adding New Modules
|
## Adding New Modules
|
||||||
|
|
||||||
1. Create file in `modules/home-manager/` or `modules/nixos/`
|
1. Create `features/<name>/default.nix` (machine-specific) or `azos-core/features/<name>/default.nix` (shared)
|
||||||
2. Add import to `modules/<type>/default.nix` (alphabetical)
|
2. Use the module template above
|
||||||
3. Use module template above
|
3. Add `suiteModules.homeManager.<name>` to the imports list in `home-manager/home.nix`
|
||||||
4. Run `nix fmt`
|
4. Run `nix fmt`
|
||||||
|
|
||||||
|
> **Submodule gotcha**: New files in `azos-core/` must be `git add`-ed inside the submodule
|
||||||
|
> before `nix build` will see them — Nix flakes only evaluate git-tracked files.
|
||||||
|
> ```bash
|
||||||
|
> cd azos-core && git add features/<name>/
|
||||||
|
> ```
|
||||||
|
|
||||||
|
## Claude Integration
|
||||||
|
|
||||||
|
Claude Code is integrated with this environment via several azos-core features:
|
||||||
|
|
||||||
|
| Feature | Option | What it does |
|
||||||
|
|---------|--------|--------------|
|
||||||
|
| `azos-core/features/claude-memory` | `azos.claude-memory.enable` | Registers org-roam-mcp as a global MCP server in `~/.claude.json` |
|
||||||
|
| `azos-core/features/claude-skills` | `azos.claude-skills.enable` | Deploys skills to `~/.claude/commands/` and content to `~/.claude/CLAUDE.md` |
|
||||||
|
| `azos/features/claude` | `azos.claude.enable` | Installs claude-code, auto-enables the above two |
|
||||||
|
|
||||||
|
### Adding Claude skills or standing instructions
|
||||||
|
From any module — no need to touch azos-core:
|
||||||
|
```nix
|
||||||
|
azos.claude.globalSkills.my-skill = ./skills/my-skill.md;
|
||||||
|
azos.claude.globalMdSections.my-rule = ''
|
||||||
|
# My Rule
|
||||||
|
Always do X when Y.
|
||||||
|
'';
|
||||||
|
```
|
||||||
|
See `azos-core/features/claude-skills/README.md` for full documentation.
|
||||||
|
|
||||||
## Key Files
|
## Key Files
|
||||||
|
|
||||||
| File | Purpose |
|
| File | Purpose |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| `flake.nix` | Main flake, defines systems, overlays |
|
| `flake.nix` | Main flake, defines systems and overlays |
|
||||||
| `modules/home-manager/default.nix` | Home-manager imports |
|
| `home-manager/home.nix` | Home-manager entry point, imports all modules |
|
||||||
| `modules/nixos/default.nix` | NixOS imports |
|
| `_machines/lauretta.nix` | Lauretta machine config, passes `suiteModules` as specialArgs |
|
||||||
| `home-manager/home.nix` | User home-manager config, enables suites |
|
| `nixos/configuration.nix` | Lauretta NixOS system config |
|
||||||
| `nixos/configuration.nix` | Lauretta laptop config |
|
|
||||||
| `nixos/configuration-vm.nix` | Test VM config |
|
| `nixos/configuration-vm.nix` | Test VM config |
|
||||||
| `overlays/` | Custom package overlays |
|
| `overlays/` | Package overlays |
|
||||||
| `pkgs/` | Custom packages |
|
| `azos-core/` | Shared feature library (git submodule) |
|
||||||
| `azos-core/` | Shared modules (submodule) |
|
| `azos-core/features/` | Shared features (auto-discovered by import-tree) |
|
||||||
|
| `features/` | Machine-specific features (auto-discovered by import-tree) |
|
||||||
|
| `azos-core/features/editor/emacs/config.org` | Literate Emacs config |
|
||||||
|
| `azos-core/features/claude-skills/README.md` | Claude skills extensibility docs |
|
||||||
|
|
||||||
## Common Tasks
|
## Common Tasks
|
||||||
|
|
||||||
**Add system package**: Edit NixOS module, add to `environment.systemPackages = with pkgs; [ pkg ]`
|
**Add system package**: Edit a NixOS feature, add to `environment.systemPackages = with pkgs; [ pkg ]`
|
||||||
|
|
||||||
**Add home-manager package**: Edit module, add to `home.packages = with pkgs; [ pkg ]`
|
**Add home-manager package**: Edit a feature's config block, add to `home.packages = with pkgs; [ pkg ]`
|
||||||
|
|
||||||
**Add system service**: Edit NixOS module, add under `services.<service>`
|
**Add system service**: Edit a NixOS feature, add under `services.<service>`
|
||||||
|
|
||||||
**Add custom package**: Create file in `pkgs/`, add to `pkgs/default.nix`, use via overlay
|
**Add custom package**: Add to `azos-core/overlays/` via `config.flake.overlayPkgs.<name>`, then use as `pkgs.<name>`
|
||||||
|
|
||||||
**Access unstable packages**: Use `pkgs.unstable.<package>` (via unstable-packages overlay)
|
**Access unstable packages**: Use `pkgs.unstable.<package>` (via unstable-packages overlay)
|
||||||
|
|||||||
+1
-1
Submodule azos-core updated: 63e76667b0...4351ff8bd0
@@ -11,6 +11,8 @@
|
|||||||
};
|
};
|
||||||
config = lib.mkIf config.azos.claude.enable {
|
config = lib.mkIf config.azos.claude.enable {
|
||||||
home.packages = with pkgs; [claude-code claude-agent-acp];
|
home.packages = with pkgs; [claude-code claude-agent-acp];
|
||||||
|
azos.claude-memory.enable = lib.mkDefault true;
|
||||||
|
azos.claude-skills.enable = lib.mkDefault true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
suiteModules.homeManager.lauretta
|
suiteModules.homeManager.lauretta
|
||||||
suiteModules.homeManager.audio
|
suiteModules.homeManager.audio
|
||||||
suiteModules.homeManager.claude
|
suiteModules.homeManager.claude
|
||||||
|
suiteModules.homeManager.claude-memory
|
||||||
|
suiteModules.homeManager.claude-skills
|
||||||
suiteModules.homeManager.encryption
|
suiteModules.homeManager.encryption
|
||||||
suiteModules.homeManager.git-config
|
suiteModules.homeManager.git-config
|
||||||
suiteModules.homeManager.hfsprogs
|
suiteModules.homeManager.hfsprogs
|
||||||
|
|||||||
Reference in New Issue
Block a user