63 lines
2.3 KiB
Markdown
63 lines
2.3 KiB
Markdown
# ❄️ My NixOS Configuration
|
|
|
|
This directory contains the declarative configuration for my user environment, managed by **Home Manager**.
|
|
|
|
## 🛠️ How it Works (The Nix Way)
|
|
|
|
In NixOS, configuration files are managed "declaratively" rather than manually.
|
|
|
|
1. **The Source of Truth**: Everything is defined in your `.nix` files.
|
|
2. **The Nix Store**: When you "switch," Nix builds your files and stores them in `/nix/store/`. These are **immutable** (read-only).
|
|
3. **Symlinking**: Home Manager creates symbolic links in your home directory (like `~/.pi/agents/settings.json`) that point back to that read-only store.
|
|
|
|
## ✍️ How to Make Changes
|
|
|
|
**Do not edit the files in your home directory.** They are read-only symlinks. To change settings:
|
|
|
|
1. **Edit your source code**: Open `home.nix` in `nvim`.
|
|
2. **Modify the Nix block**: Locate the `home.file` section for your agents.
|
|
3. **Apply changes**:
|
|
```bash
|
|
home-manager switch
|
|
```
|
|
|
|
## ❓ Why "sudo" doesn't work
|
|
The `/nix/store` is mounted as read-only at the system level. This ensures your system always matches your config and allows for instant **rollbacks** if something breaks.
|
|
|
|
### Example: Adding a local file and remote extensions
|
|
|
|
```nix
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
home.file = {
|
|
# 1. Manual/Local File Management
|
|
".pi/agents/settings.json".text = ''
|
|
{
|
|
"defaultProvider": "openrouter",
|
|
"extensionsPath": "~/.pi/extensions"
|
|
}
|
|
'';
|
|
|
|
# 2. Adding an entire folder (e.g., extensions) from Gitea
|
|
".pi/extensions/my-tool".source = pkgs.fetchgit {
|
|
url = "https://your-gitea-instance.com";
|
|
rev = "main"; # or a specific commit hash
|
|
sha256 = "0000000000000000000000000000000000000000000000000000"; # Run 'nix-prefetch-git' to get this
|
|
};
|
|
|
|
# 3. Recursive directory from your local config folder
|
|
# This maps everything inside your local 'agents' folder to ~/.pi/agents/
|
|
".pi/agents" = {
|
|
source = ./agents;
|
|
recursive = true;
|
|
};
|
|
};
|
|
}
|
|
```
|
|
|
|
### Tips for Extensions
|
|
* **Git Tracking**: If you use `git add .` in your config directory, Nix will track your local changes.
|
|
* **Fetchers**: Use [pkgs.fetchgit](https://nixos.org) for Gitea repos to ensure they are version-controlled and reproducible.
|
|
* **Permissions**: If an extension needs to be executable, add `executable = true;` to the `home.file` block.
|