split hosts

This commit is contained in:
Melvin Ragusa
2026-02-05 09:51:31 +01:00
parent b3e967e4ea
commit 5e944043b1
10 changed files with 314 additions and 29 deletions

View File

@@ -1,18 +0,0 @@
# configuration.nix
# Main NixOS configuration entry point
{
config,
pkgs,
inputs,
lib,
username,
...
}:
{
imports = [
./hardware-configuration.nix
./modules
./modules/limine-custom-labels.nix
];
}

View File

@@ -1,5 +1,5 @@
{
description = "atlas - NixOS Config for Desktop";
description = "NixOS Configurations - atlas, laptop, and server";
# ═══════════════════════════════════════════════════════════════
# INPUTS
@@ -48,18 +48,32 @@
inputs@{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
username = "pinj"; # Single source of truth for username
in
{
nixosConfigurations.atlas = nixpkgs.lib.nixosSystem {
username = "pinj";
# Helper function to create NixOS configurations
mkHost =
hostname:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs username;
};
modules = [
./configuration.nix
./hosts/${hostname}/configuration.nix
{ nixpkgs.overlays = [ inputs.nix-cachyos-kernel.overlays.pinned ]; }
];
};
in
{
nixosConfigurations = {
# Desktop - full gaming and media setup
atlas = mkHost "atlas";
# Server - headless, core + dev only
server = mkHost "server";
# Laptop - desktop environment, no gaming
laptop = mkHost "laptop";
};
};
}

75
hosts/README.md Normal file
View File

@@ -0,0 +1,75 @@
# Host Configurations
This directory contains NixOS configurations for multiple machines.
## Structure
```
hosts/
├── atlas/ # Desktop gaming machine
│ ├── configuration.nix # Main config (core + hardware + desktop + dev + gaming + services)
│ └── hardware-configuration.nix # Hardware-specific settings
├── laptop/ # Laptop with desktop environment
│ ├── configuration.nix # Main config (core + hardware + desktop + dev + services)
│ └── hardware-configuration.nix # Placeholder - generate on actual machine
└── server/ # Headless server
├── configuration.nix # Main config (core + hardware[no GPU] + dev + maintenance)
└── hardware-configuration.nix # Placeholder - generate on actual machine
```
## Module Assignments
### All Hosts
- **Core**: boot, networking, users, system, localization
- **Development**: tools, docker, shell
### Atlas & Laptop Only
- **Hardware**: GPU, audio, storage, power
- **Desktop**: window manager, apps, theming, portals
- **Services**: printing, avahi, maintenance (navidrome only on atlas)
### Atlas Only
- **Gaming**: steam, gamemode, wine
### Server Only
- Headless - no desktop or gaming
- SSH enabled for remote management
## Usage
### Build a specific host
```bash
# Build atlas (current desktop)
nixos-rebuild switch --flake .#atlas
# Build server (once hardware-config is ready)
nixos-rebuild switch --flake .#server
# Build laptop (once hardware-config is ready)
nixos-rebuild switch --flake .#laptop
```
### Setting up a new machine
1. Install NixOS on the target machine
2. Generate hardware config:
```bash
sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix
```
3. Copy that file to `hosts/<hostname>/hardware-configuration.nix` in this repo
4. Adjust `hosts/<hostname>/configuration.nix` as needed
5. Build and switch:
```bash
nixos-rebuild switch --flake .#<hostname>
```
## Adding a new host
1. Create `hosts/<hostname>/` directory
2. Copy `configuration.nix` from similar host as template
3. Generate `hardware-configuration.nix` on target machine
4. Add to `flake.nix`:
```nix
nixosConfigurations.<hostname> = mkHost "<hostname>";
```

View File

@@ -0,0 +1,23 @@
# configuration.nix
# Main NixOS configuration entry point for atlas (desktop)
{
config,
pkgs,
inputs,
lib,
username,
...
}:
{
imports = [
./hardware-configuration.nix
../../modules/core
../../modules/hardware
../../modules/desktop
../../modules/services
../../modules/dev
../../modules/gaming
../../modules/limine-custom-labels.nix
];
}

View File

@@ -0,0 +1,32 @@
# configuration.nix
# Laptop NixOS configuration - desktop environment, no gaming
{
config,
pkgs,
inputs,
lib,
username,
...
}:
{
imports = [
./hardware-configuration.nix
../../modules/core
../../modules/hardware
../../modules/desktop
../../modules/dev
../../modules/services/maintenance.nix
../../modules/services/printing.nix
../../modules/services/avahi.nix
# Uncomment if you want music server on laptop:
# ../../modules/services/navidrome.nix
];
# Laptop-specific configuration
# Hostname should be set in hardware-configuration.nix or here
# networking.hostName = "laptop";
# Laptop-specific power management tweaks can go here
# The power module already enables power-profiles-daemon
}

View File

@@ -0,0 +1,63 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usb_storage"
"usbhid"
"uas"
"sd_mod"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/mapper/cryptroot";
fsType = "xfs";
};
boot.initrd.luks.devices."cryptroot".device =
"/dev/disk/by-uuid/ecb02db3-6fe8-499e-9a31-38a8143aa092";
# ─── Encrypted Swap ───
# Include swap keyfile in initramfs (so it's available before root is mounted)
boot.initrd.secrets."/var/lib/secrets/swap.key" = /var/lib/secrets/swap.key;
boot.initrd.luks.devices."cryptswap" = {
device = "/dev/disk/by-uuid/0e51324d-5929-4b4c-bd6e-a3130cf8adc2";
keyFile = "/var/lib/secrets/swap.key";
allowDiscards = true; # Enable TRIM for NVMe SSD
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/614D-6CCA";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
swapDevices = [
{ device = "/dev/mapper/cryptswap"; }
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@@ -0,0 +1,32 @@
# configuration.nix
# Server NixOS configuration - headless, no desktop environment
{
config,
pkgs,
inputs,
lib,
username,
...
}:
{
imports = [
./hardware-configuration.nix
../../modules/core
../../modules/hardware/audio.nix
../../modules/hardware/storage.nix
../../modules/hardware/power.nix
../../modules/dev
../../modules/services/maintenance.nix
];
# Server-specific overrides
# Hostname should be set in hardware-configuration.nix or here
# networking.hostName = "server";
# Enable SSH for remote management
services.openssh.enable = true;
# Server doesn't need the GPU module (usually headless or different GPU)
# If server has a GPU, add: ../../modules/hardware/gpu-amd.nix
}

View File

@@ -0,0 +1,63 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usb_storage"
"usbhid"
"uas"
"sd_mod"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/mapper/cryptroot";
fsType = "xfs";
};
boot.initrd.luks.devices."cryptroot".device =
"/dev/disk/by-uuid/ecb02db3-6fe8-499e-9a31-38a8143aa092";
# ─── Encrypted Swap ───
# Include swap keyfile in initramfs (so it's available before root is mounted)
boot.initrd.secrets."/var/lib/secrets/swap.key" = /var/lib/secrets/swap.key;
boot.initrd.luks.devices."cryptswap" = {
device = "/dev/disk/by-uuid/0e51324d-5929-4b4c-bd6e-a3130cf8adc2";
keyFile = "/var/lib/secrets/swap.key";
allowDiscards = true; # Enable TRIM for NVMe SSD
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/614D-6CCA";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
swapDevices = [
{ device = "/dev/mapper/cryptswap"; }
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

1
result Symbolic link
View File

@@ -0,0 +1 @@
/nix/store/32cir8faxycc2f3i5gpq2c73vsgrfzwr-nixos-system-nix-26.05.20260204.00c21e4