2026-03-28 15:57:10 +00:00
# FredOS NixOS Configuration
2026-03-28 16:02:40 +00:00
Flake-based NixOS configuration for three machines, built and deployed directly from GitHub. No local config management required after initial setup.
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
## Machines
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
| Hostname | Description |
|---|---|
| FredOS-Gaming | AMD desktop, UEFI/systemd-boot |
| FredOS-Macbook | Intel laptop, UEFI/systemd-boot |
| FredOS-Mediaserver | Intel server, BIOS/GRUB |
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
## Structure
2026-03-28 15:57:10 +00:00
```
2026-03-28 19:25:26 +00:00
├── .github
│ └── workflows
│ └── update.yml # Auto-updates flake.lock daily
2026-04-01 21:14:16 +01:00
├── apps
│ ├── fastfetch.nix # Fastfetch config
│ ├── flatpaks.nix # Flatpak apps
│ └── zen.nix # Zen browser config
├── home-manager
│ ├── fred.nix # User-level Home Manager config
│ └── gnome-hm.nix # GNOME Home Manager settings
2026-03-28 19:25:26 +00:00
├── hosts
2026-04-01 21:14:16 +01:00
│ ├── FredOS-Gaming.nix # Gaming: packages, Steam, boot options
│ ├── FredOS-Macbook.nix # Macbook: packages, power management, boot options
│ ├── FredOS-Mediaserver.nix # Mediaserver: packages, networking, SSH
2026-03-28 19:25:26 +00:00
│ └── hardware
2026-04-01 21:14:16 +01:00
│ ├── FredOS-Gaming.nix # AMD GPU, kernel modules, filesystems, bootloader, hostname
│ ├── FredOS-Macbook.nix # Broadcom WiFi, Intel GPU, Bluetooth, filesystems, bootloader, hostname
│ └── FredOS-Mediaserver.nix # Intel CPU, data disks, mergerfs pool, GRUB, hostname
├── services
2026-04-07 20:42:19 +01:00
│ ├── arr-interconnect.nix # Cross-service API key wiring for *arr apps
│ ├── authelia.nix # SSO/2FA gateway (protects homepage & camera)
2026-04-01 21:14:16 +01:00
│ ├── bazarr.nix # Subtitle management
│ ├── cloudflare-ddns.nix # Cloudflare dynamic DNS
2026-04-07 20:42:19 +01:00
│ ├── fail2ban.nix # Intrusion prevention (SSH, nginx, Authelia, *arr, etc.)
2026-04-01 21:14:16 +01:00
│ ├── game-servers.nix # Game server definitions
│ ├── go2rtc.nix # Camera/RTSP streaming
2026-04-07 20:42:19 +01:00
│ ├── homepage.nix # Homepage dashboard with auto-extracted API keys
2026-04-01 21:14:16 +01:00
│ ├── jellyfin.nix # Media server
2026-04-07 20:42:19 +01:00
│ ├── nginx.nix # Reverse proxy + ACME wildcard cert via Cloudflare DNS-01
2026-04-01 21:14:16 +01:00
│ ├── prowlarr.nix # Indexer manager
│ ├── qbittorrent-nox.nix # Torrent client
│ ├── radarr.nix # Movie management
│ ├── server-permissions.nix # File/dir permission setup
│ └── sonarr.nix # TV management
├── settings
│ ├── audio.nix # PipeWire / audio config
│ ├── gnome.nix # GNOME desktop settings
│ ├── locale.nix # Locale, timezone, keyboard
│ └── users.nix # User accounts
2026-03-28 19:25:26 +00:00
├── walls # Wallpapers
2026-04-01 21:14:16 +01:00
├── common.nix # Shared config imported by all hosts
2026-03-28 19:25:26 +00:00
├── flake.lock # Auto-generated, updated daily by GitHub Actions
└── flake.nix # Flake inputs and host definitions
2026-03-28 15:57:10 +00:00
```
2026-03-28 16:02:40 +00:00
## Day-to-day usage
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
Edit files directly on GitHub, then on the machine run:
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
```bash
update
```
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
That's it. The alias is defined in `common.nix` and expands to:
```bash
sudo nixos-rebuild switch --flake github:ediblerope/nixos-config --refresh --no-write-lock-file
```
Nix automatically matches the running machine's hostname to the correct `nixosConfigurations` entry.
Other useful aliases:
```bash
clean # sudo nix-collect-garbage -d
```
2026-03-28 15:57:10 +00:00
---
## Adding a new machine
### 1. Fresh NixOS install
2026-04-01 21:14:16 +01:00
Boot the NixOS installer and complete the standard installation.
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
### 2. Enable flakes temporarily
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
Add this to `/etc/nixos/configuration.nix` and rebuild:
2026-03-28 15:57:10 +00:00
```nix
nix.settings.experimental-features = [ "nix-command" "flakes" ];
```
2026-03-28 16:02:40 +00:00
```bash
sudo nixos-rebuild switch
```
2026-03-28 15:57:10 +00:00
### 3. Create the hardware config on GitHub
2026-04-01 21:14:16 +01:00
Copy the contents of `/etc/nixos/hardware-configuration.nix` and create `hosts/hardware/FredOS-NEWHOST.nix` on GitHub. Append the hostname and bootloader config to it:
2026-03-28 15:57:10 +00:00
```nix
networking.hostName = "FredOS-NEWHOST";
2026-04-01 21:14:16 +01:00
# For UEFI/systemd-boot machines:
2026-03-28 16:02:40 +00:00
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
# For BIOS/GRUB machines instead:
# boot.loader.grub.enable = true;
# boot.loader.grub.devices = [ "/dev/sda" ]; # verify with: sudo grub-probe --target=disk /
2026-03-28 15:57:10 +00:00
```
2026-03-28 16:02:40 +00:00
### 4. Register the host in flake.nix
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
In `flake.nix` on GitHub, add to `nixosConfigurations` :
2026-03-28 15:57:10 +00:00
```nix
FredOS-NEWHOST = mkHost "FredOS-NEWHOST";
```
2026-03-28 16:02:40 +00:00
### 5. Add host-specific config
2026-03-28 15:57:10 +00:00
2026-03-28 16:02:40 +00:00
Create `hosts/FredOS-NEWHOST.nix` on GitHub for any machine-specific packages or services:
2026-03-28 15:57:10 +00:00
```nix
{ config, pkgs, lib, ... }:
{
config = lib.mkIf (config.networking.hostName == "FredOS-NEWHOST") {
2026-04-01 21:14:16 +01:00
# host-specific packages and services here
2026-03-28 15:57:10 +00:00
};
}
```
Then add it to the imports list in `common.nix` :
```nix
./hosts/FredOS-NEWHOST.nix
```
### 6. Switch to the flake
2026-03-28 16:02:40 +00:00
Run this once on the new machine with the explicit hostname:
2026-03-28 15:57:10 +00:00
```bash
sudo nixos-rebuild switch --flake github:ediblerope/nixos-config#FredOS -NEWHOST --refresh --no-write-lock-file
```
2026-03-28 16:02:40 +00:00
After this succeeds, the plain `update` alias works from then on.
2026-03-28 15:57:10 +00:00
---
2026-03-28 16:02:40 +00:00
## Flake inputs
| Input | Source |
|---|---|
| nixpkgs | `github:NixOS/nixpkgs/nixos-unstable` |
| home-manager | `github:nix-community/home-manager` |
| zen-browser | `github:0xc000022070/zen-browser-flake` |
| nix-flatpak | `github:gmodena/nix-flatpak` |
2026-04-07 20:42:19 +01:00
| nix-cachyos-kernel | `github:xddxdd/nix-cachyos-kernel/release` |
2026-03-28 16:02:40 +00:00
2026-04-07 20:49:04 +01:00
## Mediaserver secrets
Several services on FredOS-Mediaserver require secrets that are stored on the machine (not in the repo). After a fresh deploy, create these before running `update` :
```bash
# Cloudflare API token (used by DDNS and ACME wildcard cert)
# See services/cloudflare-ddns.md for token permissions
echo -n 'your-cloudflare-api-token' | sudo tee /var/secrets/cloudflare-token
sudo chmod 600 /var/secrets/cloudflare-token
# go2rtc RTSP camera URL
echo -n 'rtsp://username:password@camera -ip:554/stream1' | sudo tee /var/secrets/go2rtc-rtsp-url
sudo chmod 600 /var/secrets/go2rtc-rtsp-url
# Authelia secrets — auto-migrated from Docker on first deploy
# If migrating from Docker, ensure these exist at /home/fred/docker/authelia/:
# - configuration.yml (jwt_secret, session secret, storage key are extracted)
# - users_database.yml (copied to /var/lib/authelia-main/)
# For a fresh install, create manually:
sudo mkdir -p /var/secrets/authelia
echo -n 'random-jwt-secret' | sudo tee /var/secrets/authelia/jwt_secret
echo -n 'random-session-secret' | sudo tee /var/secrets/authelia/session_secret
echo -n 'random-storage-encryption-key' | sudo tee /var/secrets/authelia/storage_encryption_key
sudo chmod 600 /var/secrets/authelia/*
# Authelia user database (for a fresh install)
2026-04-07 21:00:03 +01:00
# Create users_database.yml with this structure:
# ---
# users:
# username:
# password: "$argon2id$..." # hashed — see below
# displayname: Display Name
# email: user@example.com
#
# Generate a password hash with:
# nix-shell -p authelia --run "authelia crypto hash generate argon2"
2026-04-07 20:49:04 +01:00
sudo mkdir -p /var/lib/authelia-main
2026-04-07 21:00:03 +01:00
sudo nano /var/lib/authelia-main/users_database.yml
2026-04-07 20:49:04 +01:00
sudo chown authelia-main:authelia-main /var/lib/authelia-main/users_database.yml
```
2026-03-28 15:57:10 +00:00
## Notes
2026-03-28 16:02:40 +00:00
- `hosts/hardware/` files are committed to the repo — they contain UUIDs and disk layout but no sensitive credentials
- Host-specific behaviour is gated with `lib.mkIf (config.networking.hostName == "...")` or `lib.elem config.networking.hostName [...]`
- GitHub API rate limit (60 req/hour unauthenticated) can occasionally be hit if running `update` many times in quick succession during active config changes — wait ~15 minutes and retry