103 lines
2.8 KiB
Markdown
103 lines
2.8 KiB
Markdown
# NixOS Configuration
|
|
|
|
This repository contains my personal NixOS configuration, structured in a pyramidal way for easy management and reuse.
|
|
|
|
## Structure
|
|
|
|
### System Configuration
|
|
|
|
The system configuration is organized in layers:
|
|
|
|
1. **Base** (`system/base/default.nix`): Common configuration for all machines
|
|
2. **Desktop** (`system/desktop/default.nix`): Configuration specific to desktop environments
|
|
3. **Server** (`system/server/default.nix`): Configuration specific to server environments
|
|
4. **Machine-specific** (`machines/<machine>/default.nix`): Configuration specific to individual machines
|
|
|
|
### Home Configuration
|
|
|
|
The home configuration follows a similar structure:
|
|
|
|
1. **Base** (`home/base/default.nix`): Common home configuration for all environments
|
|
2. **Desktop** (`home/desktop/default.nix`): Home configuration specific to desktop environments
|
|
3. **Server** (`home/server/default.nix`): Home configuration specific to server environments
|
|
|
|
## Available Configurations
|
|
|
|
This repository includes configurations for the following machines:
|
|
|
|
1. **nixos** (VM): A virtual machine configuration for testing
|
|
2. **desktop-pc**: A physical desktop PC with NVIDIA GPU
|
|
3. **home-server**: A home server with Samba and Jellyfin services
|
|
|
|
## Usage
|
|
|
|
To build and switch to a specific configuration:
|
|
|
|
```bash
|
|
# For the VM
|
|
sudo nixos-rebuild switch --flake .#nixos
|
|
|
|
# For the desktop PC
|
|
sudo nixos-rebuild switch --flake .#desktop-pc
|
|
|
|
# For the home server
|
|
sudo nixos-rebuild switch --flake .#home-server
|
|
```
|
|
|
|
### Helper Script
|
|
|
|
A helper script is provided to make switching between configurations easier:
|
|
|
|
```bash
|
|
# Switch to the VM configuration (default)
|
|
./switch.sh
|
|
|
|
# Switch to the desktop PC configuration
|
|
./switch.sh desktop-pc
|
|
|
|
# Switch to the home server configuration
|
|
./switch.sh home-server
|
|
```
|
|
|
|
## Adding a New Machine
|
|
|
|
To add a new machine:
|
|
|
|
1. Create a new directory in `machines/` with the machine name
|
|
2. Create a `default.nix` file with machine-specific configuration
|
|
3. Copy the hardware configuration to `machines/<machine>/hardware-configuration.nix`
|
|
4. Update `flake.nix` to include the new machine
|
|
|
|
Example:
|
|
|
|
```nix
|
|
# In flake.nix
|
|
new-machine = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
specialArgs = inputs;
|
|
modules = [
|
|
# Base system configuration
|
|
./system/base
|
|
|
|
# Desktop or server configuration
|
|
./system/desktop # or ./system/server
|
|
|
|
# Machine-specific configuration
|
|
./machines/new-machine
|
|
|
|
# Home-manager configuration
|
|
home-manager.nixosModules.home-manager {
|
|
# ... home-manager configuration
|
|
}
|
|
];
|
|
};
|
|
```
|
|
|
|
## Customization
|
|
|
|
- For desktop environments, enable the desktop configurations
|
|
- For server environments, enable the server configurations and disable desktop configurations
|
|
|
|
## License
|
|
|
|
This configuration is personal and provided as-is without any warranty. |