···11-This repository contains NixOS and Home Manager configurations for various machines. The goal is to manage system and user configurations declaratively using Nix.
22-33-### Project Structure
44-55-The repository is structured as a Nix flake.
66-77-- `flake.nix`: The main entry point. It defines the flake's inputs (like `nixpkgs`, `home-manager`, etc.) and outputs. The main outputs are `nixosConfigurations` and `homeConfigurations`.
88-- `hosts/`: Contains the configurations for specific machines. Each subdirectory corresponds to a host and contains a `configuration.nix` file, which is the main configuration for that host.
99-- `shared/`: Contains modules that are shared across different hosts. This is where most of the configuration logic resides. These modules are organized into subdirectories based on their purpose (e.g., `desktop`, `server`, `home-manager`).
1010-- `home-manager/`: Contains configurations for Home Manager, which is used to manage user-specific dotfiles and packages.
1111-1212-### Key Concepts
1313-1414-- **NixOS Modules**: The configurations are built using the NixOS module system. The `shared/` directory contains many reusable modules. When you need to add or change a configuration, you'll likely be editing one of these files or creating a new one.
1515-- **Home Manager**: Home Manager is used to manage user-level configurations (dotfiles, packages, services). The main Home Manager configuration is in `shared/home-manager/main.nix`.
1616-- **Flake Outputs**:
1717- - `nixosConfigurations`: Defines the system configurations for different hosts. Each attribute in this set corresponds to a host.
1818- - `homeConfigurations`: Defines user configurations that can be deployed with Home Manager.
1919- - `exportedConfigs`: These are configurations that can be used by other flakes.
2020-2121-### Developer Workflow
2222-2323-#### Adding a new host
2424-2525-1. Create a new directory in `hosts/` for the new host.
2626-2. Add a `configuration.nix` file inside the new directory. You can use one of the existing host configurations as a template.
2727-3. Add a new entry to the `nixosConfigurations` in `flake.nix` for the new host, pointing to your new `configuration.nix`.
2828-4. Import the necessary shared modules into your `configuration.nix`.
2929-3030-#### Modifying a configuration
3131-3232-1. Identify which module or host configuration you need to change.
3333-2. Make your changes to the respective `.nix` file.
3434-3. To apply the changes to a machine, run `sudo nixos-rebuild switch --flake .#<hostname>` on that machine, where `<hostname>` is the name of the host you want to update.
3535-3636-#### Updating dependencies
3737-3838-To update the flake's inputs (e.g., `nixpkgs`), run:
3939-4040-```bash
4141-nix flake update
4242-```
4343-4444-This will update the `flake.lock` file with the latest versions of the dependencies.
4545-4646-### Important Files
4747-4848-- `flake.nix`: The central point of the configuration.
4949-- `shared/meta.nix`: Imports a base set of shared modules.
5050-- `shared/home-manager/main.nix`: The main entry point for user-specific configurations managed by Home Manager.
5151-- `hosts/<hostname>/configuration.nix`: The main configuration file for a specific host.
5252-- `hosts/<hostname>/users/<username>.nix`: User-specific configurations for a given host, leveraging Home Manager. See `hosts/stellapent-cier/users/gildedguy.nix` for an example.
5353-5454-When working on this codebase, remember that it's all about declarative configuration. Instead of changing things imperatively on the system, you declare the desired state in these `.nix` files, and Nix takes care of making it happen.11+AGENT.md