This repository contains the configuration files and scripts for managing my NixOS machines. It is designed for personal use but can serve as a reference for others interested in setting up and managing NixOS systems.
Feel free to use parts of this repository, but note that it is tailored to my specific needs and may require adjustments for your use case.
The repository is structured to allow easy management of multiple NixOS hosts, with a clear separation between core, optional, and host-specific configurations. Below is an overview of the key directories:
flake.nix: The entry point for the repository, defining the Nix flake configuration.docs/: Documentation for various configurations and troubleshooting guides..hosts/: Host-specific configurations.- Each subdirectory (e.g.,
desktop/,server/,vm/) contains settings unique to a specific machine. - Host configurations may include machine-specific options like
diskoor hardware drivers.
- Each subdirectory (e.g.,
modules/: Reusable configuration modules.common/: User-specific configurations shared across machines.- Subdirectories for different users (e.g.,
root/,me/,guest/) and platforms (nixos/,home/).
- Subdirectories for different users (e.g.,
nixos/: System-level configurations.core/: Modules applied to all machines (e.g., hardware, kernel, shell, system).optional/: Modules applied to specific machines (e.g., bootloader, WiFi, GPU drivers).
home/: Home-manager configurations.core/: Modules applied to all users.optional/: Modules for specific use cases (e.g., desktop environments, general software).users/: User-specific configurations (e.g.,me/with custom packages like Git).
secrets/: Encrypted secrets managed withsops..sops.yaml: Configuration file forsops.
- Core Modules (
core/): Applied systematically to all machines. - Optional Modules (
optional/): Applied to specific machines or use cases. - Host-Specific Configurations (
hosts/): Applied only to a single machine.
This structure allows for easy scalability and modularity. Adding a new machine typically involves:
- Creating a new subdirectory in
hosts/. - Copying a template configuration.
- Adding any required optional modules (e.g., drivers, WiFi).
- Importing shared user configurations from
modules/common/users.
To use a host configuration on a fresh NixOS installation, follow these steps:
-
Set the Hostname
Ensure the hostname is set correctly:hostname <machine name>
-
Connect to the Internet
Verify that the machine has internet access and the necessary credentials to clone this repository. -
Update the Configuration
Ensure the machine's configuration is up-to-date by pulling the latest changes from the repository. -
Backup Hardware Configuration
Replace the generatedhardware-configuration.nixfile with the one specific to the host:# Overwrite hardware-configuration.nix file with the generated one cp /etc/nixos/hardware-configuration.nix \ ./hosts/$(hostname)/hardware-configuration.nix # Commit and push the new file git commit -am "Add hardware-configuration for $(hostname)" && git push
-
Deploy the Configuration
Apply the configuration using the NixOS rebuild command:sudo nixos-rebuild switch --flake .#$(hostname)
| Configuration | Type | Location | VPN IP | Description |
|---|---|---|---|---|
| shunya-dsktp | Desktop | Local | 10.9.97.152 |
Main desktop machine |
| nb250-10n | Server | Local | 10.9.97.185 |
Notebook acting as a server |
Each host has a dedicated README.md file documenting the services and configurations specific to that machine.
This repository uses a basic CI setup to validate configurations. The CI pipeline ensures that:
- The NixOS configurations are syntactically correct.
- Flake checks pass without errors.
To run the checks locally:
nix flake checkWhile this repository is primarily for personal use, I welcome constructive feedback, tips, and suggestions. If you notice areas for improvement or have ideas for better practices, feel free to open an issue or reach out.
This repository is shared under the Apache-2.0 License. You are free to use and modify the code, but please give credit where it's due.
Special thanks to the NixOS community for their excellent documentation and support, which made this setup possible.