init(release): desktop template -> desktop wip

This commit is contained in:
Rasyidan Akbar F. 2025-10-24 11:08:12 +07:00
commit 5bc78a031f
22 changed files with 716 additions and 11 deletions

View file

@ -1,23 +1,19 @@
# Repository Guidelines # Repository Guidelines
## Project Structure & Module Organization ## Project Structure & Module Organization
This flake manages both macOS (`macbook-pro`) and NixOS (`dev-vm`) hosts. `flake.nix` collects shared modules while `flake.lock` pins inputs. Platform modules live in `modules/darwin/` and `modules/nixos/`; the Linux base `system.nix` pulls in `users.nix`, `network.nix`, `ssh.nix`, and `containerization.nix`. Host overlays such as `modules/nixos/hosts/dev-vm.nix` add virtio tooling or per-machine packages. User-facing configuration sits under `modules/home/rsydn/` with `programs/`, `shell/`, and `devtools/`; Darwin layers `shell/nushell.nix` and Linux sticks to `shell/fish.nix`. Secrets remain encrypted in `secrets/*.sops.yaml` and appear at runtime under `~/.config/secrets/`. Shared logic lives in `flake.nix`, with inputs pinned in `flake.lock`. Platform modules sit under `modules/darwin/` and `modules/nixos/`; Linux hosts compose `modules/nixos/system.nix` plus `users.nix`, `network.nix`, `ssh.nix`, and `containerization.nix`. Host-specific overlays like `modules/nixos/hosts/dev-vm.nix` supply virtualization packages, while macOS tweaks belong in `modules/darwin/hosts/`. Home Manager layers for `rsydn` are under `modules/home/rsydn/` with `programs/`, `shell/`, and `devtools/`. Secrets stay encrypted in `secrets/*.sops.yaml` and surface at runtime in `~/.config/secrets/`.
## Build, Test & Development Commands ## Build, Test, and Development Commands
- `nix develop` enter the dev shell with `git`, `nixfmt-classic`, and SOPS tooling prewired. Use `nix develop` to enter the project shell with `git`, `nixfmt-classic`, and SOPS ready. Run `nix fmt` before committing to format all Nix sources. `XDG_CACHE_HOME=$PWD/.cache nix flake check` validates every host without polluting the global cache. For macOS changes, run `darwin-rebuild --dry-run --flake .#macbook-pro` and follow with `darwin-rebuild switch --flake .#macbook-pro`. Validate the Linux VM closure via `nix build .#nixosConfigurations.dev-vm.config.system.build.toplevel`.
- `nix fmt` format every Nix file; run before committing module or overlay changes.
- `XDG_CACHE_HOME=$PWD/.cache nix flake check` evaluate all hosts without polluting the global cache.
- `darwin-rebuild --dry-run --flake .#macbook-pro``darwin-rebuild switch --flake .#macbook-pro` preview then apply macOS updates.
- `nix build .#nixosConfigurations.dev-vm.config.system.build.toplevel` validate the Linux VM closure before switching.
## Coding Style & Naming Conventions ## Coding Style & Naming Conventions
Use two-space indentation, trailing commas, and lower-kebab filenames (e.g. `shell/nushell.nix`). Declare custom options in the `rsydn.*` namespace and prefer shared modules over ad-hoc host tweaks. Indent with two spaces and keep trailing commas in attribute sets. Prefer lower-kebab filenames (e.g. `shell/nushell.nix`), and expose custom options under the `rsydn.*` namespace. Format Nix with `nix fmt`; avoid ad-hoc host tweaks when a shared module fits.
## Testing Guidelines ## Testing Guidelines
Treat `nix flake check` as mandatory gatekeeping. Capture activation output (`darwin-rebuild --dry-run`, `nix build .#nixosConfigurations.dev-vm…`) and attach summaries to reviews. Co-locate regression tests next to their modules with the `<option-name>.nix` pattern. Treat `nix flake check` as the minimum gate; capture its output for reviews. When adjusting host builds, keep dry-run transcripts (`darwin-rebuild --dry-run`, `nix build .#nixosConfigurations.dev-vm…`) to share in PRs. Co-locate regression tests next to their modules using the `<option-name>.nix` pattern.
## Commit & Pull Request Guidelines ## Commit & Pull Request Guidelines
Keep commit subjects short and imperative (`add dev-vm virtualization module`) and scope each commit narrowly. PRs should list validation commands, link issues or TODOs, and include screenshots or terminal snippets when modifying prompts, Tailscale, or SSH flows. Write imperative commit subjects such as `add dev-vm virtualization module`, and keep each commit narrowly scoped. PRs should list validation commands run, link related issues or TODOs, and attach screenshots or terminal snippets when touching prompts, Tailscale, or SSH flows.
## Security & Configuration Tips ## Security & Configuration Tips
Age keys live at `~/.config/sops/age/keys.txt`; regenerate via Home Manager if missing. Read secrets from the managed files (`open ~/.config/secrets/openai-api-key | str trim`) and scope them with `with-env`. Tailscale and OpenSSH run by default on Linux; rotate keys regularly and audit `services.tailscale.extraUpFlags` before enabling exit nodes. Age keys live at `~/.config/sops/age/keys.txt`; regenerate via Home Manager if missing. Access secrets with `open ~/.config/secrets/<name> | str trim` and scope them using `with-env`. Audit `services.tailscale.extraUpFlags` before enabling exit nodes, and rotate SSH/Tailscale keys regularly.

132
DESKTOP-SETUP.md Normal file
View file

@ -0,0 +1,132 @@
# Desktop Setup Guide
This guide explains how to add desktop configurations to your NixOS system.
## Architecture
Desktop configuration is split into 3 layers:
### Layer 1: Base Infrastructure (`modules/nixos/*.nix`)
Hardware support that all desktops need:
- `audio.nix` - PipeWire audio stack
- `bluetooth.nix` - Bluetooth support
- `graphics.nix` - OpenGL/Vulkan acceleration
- `fonts.nix` - System fonts
### Layer 2: Desktop Environments (`modules/nixos/desktops/`)
System-level DE/WM configuration:
- `hyprland.nix` - Hyprland compositor
- `plasma.nix` - KDE Plasma 6
- `niri.nix` - Niri compositor
- `base.nix` - Shared DE settings
### Layer 3: User Configuration (`modules/home/rsydn/desktop/`)
Home Manager user-level configs:
- `base.nix` - GTK/Qt theming
- `apps/` - GUI application configs
- `wayland/` - Compositor user configs
- `themes/` - Theme configurations
## Quick Start
### 1. Update `flake.nix`
Add a new host configuration:
```nix
nixosConfigurations.my-desktop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./modules/nixos/system.nix
./modules/nixos/hosts/desktop-dev.nix # Your host config
home-manager.nixosModules.home-manager {
home-manager.users.rsydn = import ./modules/nixos/home/desktop.nix;
}
];
};
```
### 2. Update `modules/nixos/system.nix`
Add desktop infrastructure imports:
```nix
{ lib, ... }: {
imports = [
./users.nix
./network.nix
./ssh.nix
./containerization.nix
# Add these for desktop:
./audio.nix
./bluetooth.nix
./graphics.nix
./fonts.nix
];
# ... rest of config
}
```
### 3. Customize Host Configuration
Copy and modify `modules/nixos/hosts/desktop-dev.nix`:
- Set hostname
- Choose desktop environment (import from `desktops/`)
- Add hardware-specific settings (GPU drivers, etc.)
### 4. Enable Compositor in Home Manager
Edit `modules/home/rsydn/desktop/wayland/default.nix`:
```nix
imports = [
./hyprland # Uncomment the compositor you want
# ./niri
];
```
### 5. Build and Switch
```bash
# Check configuration
nix flake check
# Build
sudo nixos-rebuild switch --flake .#my-desktop
```
## Examples
### Hyprland Development Workstation
1. Host imports `desktops/hyprland.nix`
2. Home Manager imports `desktop/wayland/hyprland`
3. Customize keybinds in `desktop/wayland/hyprland/default.nix`
### KDE Plasma Gaming Rig
1. Host imports `desktops/plasma.nix`
2. Home Manager imports `desktop/base.nix` only
3. Enable Steam in host config
4. Add gaming packages
## Ricing Guide
All customization should happen in Layer 3 (`modules/home/rsydn/desktop/`):
1. **Themes**: Add theme files in `desktop/themes/`
2. **Compositor styling**: Edit `desktop/wayland/{hyprland,niri}/`
3. **Application configs**: Edit `desktop/apps/`
4. **Keep Layer 1 & 2 minimal** - they provide functionality, not aesthetics
## Switching Desktop Environments
Simply change the import in your host config:
```nix
# Before
imports = [ ../desktops/hyprland.nix ];
# After
imports = [ ../desktops/plasma.nix ];
```
Then rebuild your system.

View file

@ -0,0 +1,19 @@
{ pkgs, ... }:
{
# Browser configurations
home.packages = with pkgs; [
firefox
# chromium
# brave
];
# Firefox config (expand as needed)
# programs.firefox = {
# enable = true;
# profiles.default = {
# settings = {
# "browser.startup.homepage" = "about:home";
# };
# };
# };
}

View file

@ -0,0 +1,28 @@
{ pkgs, lib, ... }:
{
# Terminal emulators
# Kitty - GPU-accelerated terminal
programs.kitty = {
enable = lib.mkDefault false;
# theme = "Dracula";
# settings = {
# font_family = "JetBrains Mono";
# font_size = 12;
# };
};
# Alacritty - GPU-accelerated terminal
programs.alacritty = {
enable = lib.mkDefault false;
# settings = {
# font.normal.family = "JetBrains Mono";
# font.size = 12;
# };
};
# WezTerm - GPU-accelerated terminal
# programs.wezterm = {
# enable = false;
# };
}

View file

@ -0,0 +1,36 @@
{ lib, pkgs, config, ... }:
{
# Base desktop user configuration
# GTK theming
gtk = {
enable = lib.mkDefault true;
theme = lib.mkDefault {
name = "Adwaita-dark";
package = pkgs.gnome-themes-extra;
};
};
# Qt theming
qt = {
enable = lib.mkDefault true;
platformTheme.name = lib.mkDefault "gtk";
style.name = lib.mkDefault "adwaita-dark";
};
# XDG user directories
xdg = {
enable = true;
userDirs = {
enable = true;
createDirectories = true;
};
};
# Basic GUI packages
home.packages = with pkgs; [
# Add common desktop apps here
# firefox
# vscodium
];
}

View file

@ -0,0 +1,21 @@
# Themes
Add your theme configurations here. Each theme should set:
- GTK theme
- Qt theme
- Terminal colors
- Compositor colors (if applicable)
- Wallpapers
Example structure:
```nix
# catppuccin.nix
{ pkgs, ... }: {
gtk.theme = {
name = "Catppuccin-Mocha";
package = pkgs.catppuccin-gtk;
};
# ... more theme settings
}
```

View file

@ -0,0 +1,11 @@
{ ... }:
{
# Wayland compositor configurations
# Import the compositor you want to use
imports = [
# Uncomment the one you want:
# ./hyprland
# ./niri
];
}

View file

@ -0,0 +1,46 @@
{ lib, pkgs, ... }:
{
# Hyprland user configuration
wayland.windowManager.hyprland = {
enable = lib.mkDefault true;
xwayland.enable = lib.mkDefault true;
settings = {
# Minimal config - expand as needed
"$mod" = "SUPER";
# Example keybinds
bind = [
"$mod, Return, exec, kitty" # Terminal
"$mod, Q, killactive"
"$mod, M, exit"
"$mod, F, fullscreen"
"$mod, Space, togglefloating"
# Move focus
"$mod, h, movefocus, l"
"$mod, l, movefocus, r"
"$mod, k, movefocus, u"
"$mod, j, movefocus, d"
];
# Example settings
general = {
gaps_in = 5;
gaps_out = 10;
border_size = 2;
};
decoration = {
rounding = 8;
};
};
};
# Hyprland utilities
home.packages = with pkgs; [
# wofi # Launcher
# waybar # Status bar
# dunst # Notifications
];
}

View file

@ -0,0 +1,39 @@
{ lib, pkgs, ... }:
{
# Niri user configuration
programs.niri = {
settings = {
# Minimal config - expand as needed
input = {
keyboard.xkb = {
layout = "us";
};
};
# Example keybinds
binds = {
"Mod+Return".action.spawn = [ "kitty" ];
"Mod+Q".action.close-window = { };
"Mod+F".action.fullscreen-window = { };
# Focus movement
"Mod+H".action.focus-column-left = { };
"Mod+L".action.focus-column-right = { };
"Mod+J".action.focus-window-down = { };
"Mod+K".action.focus-window-up = { };
};
layout = {
gaps = 8;
center-focused-column = "never";
};
};
};
# Niri utilities
home.packages = with pkgs; [
# fuzzel # Launcher (recommended for niri)
# waybar # Status bar
# dunst # Notifications
];
}

14
modules/nixos/audio.nix Normal file
View file

@ -0,0 +1,14 @@
{ lib, ... }:
{
# Modern audio stack - PipeWire replaces PulseAudio + JACK + ALSA
services.pipewire = {
enable = lib.mkDefault true;
alsa.enable = lib.mkDefault true;
alsa.support32Bit = lib.mkDefault true; # For 32-bit games/apps
pulse.enable = lib.mkDefault true; # PulseAudio compatibility
jack.enable = lib.mkDefault true; # JACK compatibility
};
# Real-time audio priority
security.rtkit.enable = lib.mkDefault true;
}

View file

@ -0,0 +1,13 @@
{ lib, ... }:
{
hardware.bluetooth = {
enable = lib.mkDefault false; # Enable when needed
powerOnBoot = lib.mkDefault true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Experimental = true; # Better codec support
};
};
};
}

View file

@ -0,0 +1,34 @@
# Desktop Environments
This directory contains system-level desktop environment configurations.
## Available Desktop Environments
- `hyprland.nix` - Dynamic tiling Wayland compositor
- `plasma.nix` - KDE Plasma 6 desktop environment
- `niri.nix` - Scrollable-tiling Wayland compositor
- `base.nix` - Shared desktop settings (imported by all DEs)
## Usage
Import one desktop environment in your host configuration:
```nix
# modules/nixos/hosts/your-host.nix
{
imports = [
../desktops/hyprland.nix
# OR
# ../desktops/plasma.nix
# OR
# ../desktops/niri.nix
];
}
```
## Adding a New Desktop Environment
1. Create a new file (e.g., `gnome.nix`)
2. Import `./base.nix`
3. Enable the desktop environment
4. Add essential system packages

View file

@ -0,0 +1,28 @@
{ lib, pkgs, ... }:
{
# Shared desktop settings (imported by all DEs)
# XDG portals for desktop integration
xdg.portal = {
enable = lib.mkDefault true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
# Policy kit for privilege escalation
security.polkit.enable = lib.mkDefault true;
# GVFS for trash, mounting, etc
services.gvfs.enable = lib.mkDefault true;
# Common desktop packages
environment.systemPackages = with pkgs; [
# File managers (choose one)
# nautilus # GNOME
# dolphin # KDE
# thunar # XFCE
# Basic utilities
pavucontrol # Audio control
networkmanagerapplet # Network management GUI
];
}

View file

@ -0,0 +1,31 @@
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
# Hyprland - Dynamic tiling Wayland compositor
programs.hyprland = {
enable = lib.mkDefault true;
xwayland.enable = lib.mkDefault true;
};
# Wayland-specific portal
xdg.portal.wlr.enable = lib.mkDefault true;
# Essential Wayland tools (system-level)
environment.systemPackages = with pkgs; [
# Wayland essentials
wayland
wl-clipboard
wlr-randr
# Screenshot & screen recording
grim # Screenshot
slurp # Region selector
# wf-recorder # Screen recording (optional)
# Add your preferred apps here
# kitty # Terminal
# wofi # Launcher
# waybar # Bar
];
}

View file

@ -0,0 +1,28 @@
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
# Niri - Scrollable-tiling Wayland compositor
programs.niri = {
enable = lib.mkDefault true;
};
# Wayland-specific portal
xdg.portal.wlr.enable = lib.mkDefault true;
# Essential Wayland tools
environment.systemPackages = with pkgs; [
# Wayland essentials
wayland
wl-clipboard
# Screenshot tools
grim
slurp
# Add your preferred apps here
# kitty # Terminal
# fuzzel # Launcher (recommended for niri)
# waybar # Bar
];
}

View file

@ -0,0 +1,16 @@
{ lib, ... }:
{
imports = [ ./base.nix ];
# KDE Plasma 6
services.desktopManager.plasma6.enable = lib.mkDefault true;
# SDDM display manager
services.displayManager.sddm = {
enable = lib.mkDefault true;
wayland.enable = lib.mkDefault true;
};
# KDE apps are managed by Plasma
# Add extra packages in your host config if needed
}

40
modules/nixos/fonts.nix Normal file
View file

@ -0,0 +1,40 @@
{ lib, pkgs, ... }:
{
fonts = {
enableDefaultPackages = lib.mkDefault true;
packages = with pkgs; [
# Nerd Fonts for terminal icons
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
# Core fonts
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
liberation_ttf
# Code fonts
fira-code
jetbrains-mono
];
fontconfig = {
enable = lib.mkDefault true;
defaultFonts = {
monospace = [
"JetBrains Mono"
"FiraCode Nerd Font"
];
sansSerif = [ "Noto Sans" ];
serif = [ "Noto Serif" ];
emoji = [ "Noto Color Emoji" ];
};
};
};
}

View file

@ -0,0 +1,22 @@
{ lib, pkgs, ... }:
{
# Hardware acceleration (OpenGL/Vulkan)
hardware.graphics = {
enable = lib.mkDefault true;
enable32Bit = lib.mkDefault true; # For 32-bit games/apps
extraPackages = with pkgs; [
# Common drivers (expand based on your hardware)
mesa.drivers
vulkan-validation-layers
vulkan-tools
# Intel-specific (comment out if not using Intel)
intel-media-driver
intel-vaapi-driver
# AMD-specific (comment out if not using AMD)
# rocmPackages.clr.icd
];
};
}

View file

@ -0,0 +1,24 @@
{ ... }:
{
# Desktop user configuration (for Hyprland/Niri setups)
imports = [
# Base CLI tools
../../home/rsydn/base.nix
# Desktop additions
../../home/rsydn/desktop/base.nix
../../home/rsydn/desktop/apps/browsers.nix
../../home/rsydn/desktop/apps/terminals.nix
# Choose your compositor
../../home/rsydn/desktop/wayland
# Enable specific compositor in wayland/default.nix
# Add theme when ready
# ../../home/rsydn/desktop/themes/catppuccin.nix
];
# Override options here
# programs.kitty.enable = true;
}

View file

@ -0,0 +1,32 @@
{ pkgs, ... }:
{
# Gaming user configuration (for KDE Plasma)
imports = [
# Base CLI tools
../../home/rsydn/base.nix
# Desktop base
../../home/rsydn/desktop/base.nix
../../home/rsydn/desktop/apps/browsers.nix
];
# Gaming-specific user packages
home.packages = with pkgs; [
# Communication
# discord
# teamspeak_client
# Streaming/Recording
# obs-studio
# Media
# spotify
];
# KDE-specific settings (optional)
# programs.plasma = {
# enable = true;
# workspace.theme = "breeze-dark";
# };
}

View file

@ -0,0 +1,42 @@
{ pkgs, ... }:
{
# Example desktop development workstation configuration
# Copy and modify for your actual hardware
# Boot configuration (adjust for your system)
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Hostname
networking.hostName = "desktop-dev";
# Import desktop environment (choose one)
imports = [
../desktops/hyprland.nix
# ../desktops/plasma.nix
# ../desktops/niri.nix
];
# Hardware-specific settings (adjust for your hardware)
# boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "sd_mod" ];
# GPU drivers (uncomment if using NVIDIA)
# services.xserver.videoDrivers = [ "nvidia" ];
# hardware.nvidia = {
# modesetting.enable = true;
# open = false; # Use proprietary driver
# };
# Optional: Enable bluetooth
# hardware.bluetooth.enable = true;
# Development-specific packages
environment.systemPackages = with pkgs; [
# Add desktop dev tools here
# docker-compose
# k9s
];
# This value determines the NixOS release compatibility
system.stateVersion = "24.05";
}

View file

@ -0,0 +1,53 @@
{ pkgs, ... }:
{
# Example gaming desktop configuration
# Copy and modify for your actual hardware
# Boot configuration
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Hostname
networking.hostName = "gaming-rig";
# Import KDE Plasma for gaming
imports = [ ../desktops/plasma.nix ];
# Gaming-specific settings
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
# GameMode for performance optimization
programs.gamemode.enable = true;
# GPU drivers (example: NVIDIA)
# services.xserver.videoDrivers = [ "nvidia" ];
# hardware.nvidia = {
# modesetting.enable = true;
# powerManagement.enable = false;
# open = false;
# package = config.boot.kernelPackages.nvidiaPackages.stable;
# };
# Gaming packages
environment.systemPackages = with pkgs; [
# Launchers
lutris
heroic
# bottles
# Tools
mangohud # FPS overlay
# gamescope # Gaming compositor
# protonup-qt # Proton version manager
# Communication
discord
];
# This value determines the NixOS release compatibility
system.stateVersion = "24.05";
}