Compare commits

...

7 Commits

Author SHA1 Message Date
24a09a9922 [desktop] Add steam sleep inhibitor
Adds sleep inhibitor based on whether or not Steam is actively streaming
a remote session
2025-07-19 15:11:33 -07:00
f757ea7271 [kodi] Add kdeconnect 2025-07-19 14:55:35 -07:00
64149713d2 [home] Add k8s management apps 2025-07-16 22:38:19 -07:00
88b413e0af [nixbook] disable gaming 2025-07-16 18:52:51 -07:00
c5070eb4bf [home] Re-enable openscad-unstable 2025-07-13 12:07:01 -07:00
6b4dc1e6b7 Add CLAUDE.md 2025-07-13 12:06:55 -07:00
aadd8c7b6c [home] Add claude-code 2025-07-13 12:06:46 -07:00
6 changed files with 238 additions and 4 deletions

110
CLAUDE.md Normal file
View File

@@ -0,0 +1,110 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Repository Overview
This is a NixOS configuration repository using flakes, managing multiple machines and home-manager configurations. The repository follows a modular architecture with reusable "roles" that can be composed for different machines.
## Architecture
### Flake Structure
- **flake.nix**: Main entry point defining inputs (nixpkgs, home-manager, plasma-manager, etc.) and outputs for multiple NixOS configurations
- **Machines**: `nix-book`, `boxy`, `wixos` (WSL configuration)
- **Home configurations**: Standalone home-manager configuration for user `johno`
### Directory Structure
- `machines/`: Machine-specific configurations with hardware-configuration.nix
- `roles/`: Modular system configurations (audio, bluetooth, desktop, users, etc.)
- `home/`: Home Manager configurations and user-specific modules
- `home/modules/`: User environment modules (emacs, i3+sway, plasma-manager, tmux)
- `packages/`: Custom package definitions
### Role-Based Configuration System
The repository uses a custom "roles" system where each role is a NixOS module with enable options:
- `roles.desktop`: Desktop environment with sub-options for X11, Wayland, KDE, gaming, SDDM
- `roles.audio`: Audio configuration
- `roles.bluetooth`: Bluetooth support
- `roles.users`: User account management
- `roles.virtualisation`: Virtualization setup
- `roles.kodi`: Kodi media center
Example role usage in machine configuration:
```nix
roles = {
audio.enable = true;
desktop = {
enable = true;
gaming = true;
kde = true;
wayland = true;
};
users.enable = true;
};
```
## Common Commands
### Building and Switching Configurations
```bash
# Build and switch to a specific machine configuration
sudo nixos-rebuild switch --flake .#<hostname>
# Build without switching
nixos-rebuild build --flake .#<hostname>
# Build home-manager configuration only
home-manager switch --flake .#johno
```
### Available Machine Configurations
- `nix-book`: Uses `home/home-nix-book.nix`
- `boxy`: Gaming desktop with AMD GPU, uses `home/home.nix`
- `wixos`: WSL configuration, uses `home/home.nix`
### Flake Operations
```bash
# Update flake inputs
nix flake update
# Check flake
nix flake check
# Show flake info
nix flake show
```
### Bootstrap New Machine
Use the provided bootstrap script:
```bash
sudo ./bootstrap.sh <hostname>
```
This script pulls from the remote git repository and applies the configuration.
## Development Workflow
### Adding New Machines
1. Create new directory in `machines/<hostname>/`
2. Add `configuration.nix` with role assignments
3. Include hardware-configuration.nix (generated by nixos-generate-config)
4. Add nixosConfiguration to flake.nix outputs
### Adding New Roles
1. Create directory in `roles/<role-name>/`
2. Create `default.nix` with module definition using mkEnableOption
3. Add role import to `roles/default.nix`
4. Configure role options in machine configurations
### Home Manager Modules
- Located in `home/modules/`
- Each module has its own `default.nix`
- Imported in main home configuration files
## Key Configuration Details
- **Experimental features**: nix-command and flakes are enabled
- **User**: Primary user is `johno` with trusted-user privileges
- **Locale**: en_US.UTF-8, America/Los_Angeles timezone
- **SSH**: OpenSSH enabled on all configurations
- **Garbage collection**: Automatic, deletes older than 10 days
- **Unfree packages**: Allowed globally

View File

@@ -39,6 +39,7 @@ in
# '')
pkgs.bitwarden
pkgs.claude-code
pkgs.codex
pkgs.dunst
pkgs.element-desktop
@@ -55,7 +56,7 @@ in
pkgs.moonlight-qt
pkgs.ncdu
pkgs.nextcloud-talk-desktop
#pkgs.openscad-unstable
pkgs.openscad-unstable
pkgs.pandoc
#pkgs.pinentry-qt
#pkgs.pytest
@@ -67,6 +68,10 @@ in
pkgs.wofi
pkgs.vlc
## Kubernetes cluster management
pkgs.kubectl
pkgs.kubernetes-helm
globalInputs.google-cookie-retrieval.packages.${system}.default
];

View File

@@ -15,7 +15,7 @@
desktop = {
enable = true;
wayland = true;
gaming = true;
gaming = false;
kde = true;
sddm = true;
};

View File

@@ -20,5 +20,6 @@ with lib;
./kde.nix
./programs.nix
./sddm.nix
./steam-sleep-inhibitor.nix
];
}

View File

@@ -0,0 +1,116 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
steamSleepInhibitor = pkgs.writeShellScript "steam-sleep-inhibitor" ''
#!/usr/bin/env bash
# Steam log path - adjust if different
STEAM_LOG="$HOME/.local/share/Steam/logs/streaming_log.txt"
FALLBACK_LOG="$HOME/.steam/steam/logs/streaming_log.txt"
# Find Steam log file
if [[ -f "$STEAM_LOG" ]]; then
LOG_FILE="$STEAM_LOG"
elif [[ -f "$FALLBACK_LOG" ]]; then
LOG_FILE="$FALLBACK_LOG"
else
# Monitor Steam process for streaming activity
LOG_FILE=""
fi
INHIBITOR_PID=""
MONITORING=false
cleanup() {
if [[ -n "$INHIBITOR_PID" ]]; then
echo "Stopping sleep inhibitor (PID: $INHIBITOR_PID)"
kill "$INHIBITOR_PID" 2>/dev/null
fi
exit 0
}
start_inhibitor() {
if [[ -z "$INHIBITOR_PID" ]]; then
echo "Starting sleep inhibitor for Steam Remote Play session"
${pkgs.systemd}/bin/systemd-inhibit \
--what=sleep \
--who="Steam Remote Play" \
--why="Active streaming session detected" \
--mode=block \
sleep infinity &
INHIBITOR_PID=$!
fi
}
stop_inhibitor() {
if [[ -n "$INHIBITOR_PID" ]]; then
echo "Stopping sleep inhibitor - streaming session ended"
kill "$INHIBITOR_PID" 2>/dev/null
INHIBITOR_PID=""
fi
}
# Check if Steam Remote Play is active by looking for streaming processes
check_streaming_active() {
# Check for Steam streaming processes
if pgrep -f "streaming_client" >/dev/null || \
pgrep -f "steamremoteplay" >/dev/null || \
${pkgs.procps}/bin/pgrep -f "Remote Play" >/dev/null; then
return 0
fi
# Check for active network connections on Steam streaming ports
if ${pkgs.nettools}/bin/netstat -an 2>/dev/null | grep -E ":(27036|27037)" | grep ESTABLISHED >/dev/null; then
return 0
fi
return 1
}
trap cleanup EXIT INT TERM
echo "Steam sleep inhibitor monitoring started"
while true; do
if check_streaming_active; then
if [[ "$MONITORING" == "false" ]]; then
MONITORING=true
start_inhibitor
fi
else
if [[ "$MONITORING" == "true" ]]; then
MONITORING=false
stop_inhibitor
fi
fi
sleep 10
done
'';
in
{
config = mkIf (cfg.enable && cfg.kde && cfg.gaming) {
# Steam streaming sleep inhibitor service
systemd.user.services.steam-sleep-inhibitor = {
description = "Steam Remote Play Sleep Inhibitor";
wantedBy = [ "default.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${steamSleepInhibitor}";
Restart = "always";
RestartSec = "5";
};
};
# Steam-specific environment variables to prevent sleep interference
environment.sessionVariables = {
SDL_VIDEO_ALLOW_SCREENSAVER = "1";
};
};
}

View File

@@ -29,7 +29,7 @@ in
{
users.extraUsers.kodi = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "audio" "video" ];
extraGroups = [ "wheel" "networkmanager" "audio" "video" ];
};
networking.firewall = {
@@ -38,10 +38,12 @@ in
};
environment.systemPackages = with pkgs; [
kodiPkg
kodiPkg
wget
];
programs.kdeconnect.enable = true;
services = if cfg.autologin then {
displayManager = {
autoLogin.enable = true;