This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
# Moonlight: client for the Sunshine server on konishi (stream games to this laptop).
|
||||
custom.gaming.moonlight = true;
|
||||
|
||||
# RetroArch (bare — cores/ROMs added by hand, WebDAV configured in-app).
|
||||
custom.gaming.retroarch = true;
|
||||
|
||||
wayland.windowManager.hyprland.settings = {
|
||||
exec-once = [
|
||||
];
|
||||
|
||||
@@ -17,7 +17,10 @@ let
|
||||
cfg = config.custom.gaming;
|
||||
in
|
||||
{
|
||||
imports = [ ./moonlight.nix ];
|
||||
imports = [
|
||||
./moonlight.nix
|
||||
./retroarch.nix
|
||||
];
|
||||
|
||||
options.custom.gaming = {
|
||||
enable = lib.mkEnableOption "user-space gaming tools (launchers, Proton mgmt, MangoHud)";
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# RetroArch — libretro frontend/emulator, plus standalone Dolphin & PCSX2.
|
||||
#
|
||||
# Cores are managed declaratively through `retroarch.withCores`. The in-app
|
||||
# Online Updater / Core Downloader is compiled out of the nixpkgs build
|
||||
# (--disable-update_cores), and the libretro buildbot cores wouldn't run on
|
||||
# NixOS anyway (generic-Linux binaries linked against FHS paths). So cores come
|
||||
# from nixpkgs' `libretro.*` set and are baked into the wrapper — add or drop a
|
||||
# system by editing the list below.
|
||||
#
|
||||
# ROMs and BIOS/firmware are still supplied by hand:
|
||||
# * roms -> ~/roms (game files)
|
||||
# * system -> ~/.config/retroarch/system (BIOS dumps: PS1, Saturn, DS, CD, …)
|
||||
# Both are seeded as empty writable dirs via `.keep` placeholders, so
|
||||
# home-manager creates the trees without owning their contents.
|
||||
#
|
||||
# GameCube/Wii and PS2 are installed as the standalone emulators (dolphin-emu,
|
||||
# pcsx2) rather than libretro cores — those cores exist but the standalones are
|
||||
# far better maintained and less finicky.
|
||||
#
|
||||
# WebDAV cloud sync is configured in the RetroArch UI (Settings > Cloud Sync):
|
||||
# no server URL or credentials live in this repo, since there's no secrets
|
||||
# tooling here and the Nix store is world-readable.
|
||||
#
|
||||
# Gated by its own option, independent of `custom.gaming.enable`, matching the
|
||||
# moonlight module next door.
|
||||
let
|
||||
cfg = config.custom.gaming;
|
||||
in
|
||||
{
|
||||
options.custom.gaming.retroarch = lib.mkEnableOption "RetroArch (declarative cores) + standalone Dolphin/PCSX2";
|
||||
|
||||
config = lib.mkIf cfg.retroarch {
|
||||
home.packages = [
|
||||
(pkgs.retroarch.withCores (
|
||||
cores: with cores; [
|
||||
# Nintendo
|
||||
mesen # NES
|
||||
snes9x # SNES
|
||||
gambatte # Game Boy / Color
|
||||
mgba # GBA
|
||||
mupen64plus # N64 (Mupen64Plus-Next)
|
||||
melondsds # DS
|
||||
|
||||
# Sega
|
||||
genesis-plus-gx # SMS / GG / Genesis / Mega Drive / Sega CD / SG-1000
|
||||
picodrive # 32X
|
||||
beetle-saturn # Saturn
|
||||
flycast # Dreamcast / NAOMI
|
||||
|
||||
# Sony
|
||||
beetle-psx-hw # PS1 (HW upscaling)
|
||||
ppsspp # PSP
|
||||
|
||||
# Handhelds / misc
|
||||
beetle-pce # PC Engine / TurboGrafx / CD
|
||||
beetle-wswan # WonderSwan
|
||||
beetle-ngp # Neo Geo Pocket
|
||||
beetle-lynx # Atari Lynx
|
||||
beetle-vb # Virtual Boy
|
||||
|
||||
# Arcade
|
||||
fbneo # FinalBurn Neo
|
||||
]
|
||||
))
|
||||
|
||||
# Better as standalones than their libretro cores:
|
||||
pkgs.dolphin-emu # GameCube / Wii
|
||||
pkgs.pcsx2 # PS2
|
||||
];
|
||||
|
||||
home.file."roms/.keep".text = "";
|
||||
xdg.configFile."retroarch/system/.keep".text = "";
|
||||
};
|
||||
}
|
||||
@@ -32,6 +32,7 @@
|
||||
custom.gaming = {
|
||||
enable = true;
|
||||
nvidia = true;
|
||||
retroarch = true;
|
||||
};
|
||||
|
||||
wayland.windowManager.hyprland.settings = {
|
||||
@@ -90,6 +91,15 @@
|
||||
# their own class added here.
|
||||
"workspace 3, match:class heroic"
|
||||
"tile on, match:class heroic"
|
||||
|
||||
# RetroArch streamed via Moonlight (also registered as a Sunshine app).
|
||||
# Native Wayland app_id is `com.libretro.RetroArch` (set at map time) — the
|
||||
# exact string is needed so the rule applies on spawn; a loose `retroarch`
|
||||
# match misses at map and the window flashes onto the active workspace
|
||||
# first. `silent` sends it to ws3 (DP-1, the captured screen) without
|
||||
# yanking focus off whatever workspace you're driving from.
|
||||
"workspace 3 silent, match:class com.libretro.RetroArch"
|
||||
"fullscreen on, match:class com.libretro.RetroArch"
|
||||
];
|
||||
|
||||
render = {
|
||||
|
||||
@@ -20,11 +20,22 @@
|
||||
../common/features/nix-ld.nix
|
||||
../common/features/bluetooth.nix
|
||||
../common/features/ledger.nix
|
||||
../common/features/smb-mounts.nix
|
||||
../common/features/home
|
||||
];
|
||||
|
||||
networking.hostName = "arrakis";
|
||||
|
||||
# NAS media share — reachable only over the wg-home VPN. Lazy automount, so it
|
||||
# never blocks boot and (re)mounts on first access once the VPN is up.
|
||||
custom.smbMounts = [
|
||||
{
|
||||
server = "10.6.10.45";
|
||||
share = "media";
|
||||
mountPoint = "/mnt/media";
|
||||
}
|
||||
];
|
||||
|
||||
boot.kernelParams = [
|
||||
"i915=force_probe=46a6"
|
||||
"i915.enable_psr=0"
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# Lazy, VPN-friendly SMB/CIFS automounts.
|
||||
#
|
||||
# Each entry becomes a systemd *automount* rather than a plain mount, so:
|
||||
# * boot never hangs — nothing connects to the server at boot; only the
|
||||
# lightweight .automount unit is installed (noauto + x-systemd.automount).
|
||||
# * it mounts on first access — when something touches the mount point (e.g.
|
||||
# RetroArch reading its save dir), systemd performs the real CIFS mount.
|
||||
# * it's VPN-safe — a short mount-timeout means an access while the VPN is
|
||||
# down fails fast instead of blocking, and the automount re-arms so the next
|
||||
# access retries. Once wg-home is up, the next access succeeds. An idle
|
||||
# timeout unmounts the share so it re-mounts fresh after a VPN drop (no
|
||||
# stale handles).
|
||||
#
|
||||
# NOTE: wg-home is a NetworkManager connection managed outside the flake, so the
|
||||
# mount deliberately does NOT depend on the wg interface unit — the on-access
|
||||
# retry model needs no knowledge of when the VPN is up.
|
||||
let
|
||||
cfg = config.custom.smbMounts;
|
||||
in
|
||||
{
|
||||
options.custom.smbMounts = lib.mkOption {
|
||||
description = "Guest SMB/CIFS shares to expose as lazy, VPN-safe automounts.";
|
||||
default = [ ];
|
||||
type = lib.types.listOf (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
server = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "SMB server host or IP (reachable over the VPN), e.g. \"10.10.0.1\".";
|
||||
};
|
||||
share = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Share name on the server, e.g. \"retroarch\".";
|
||||
};
|
||||
mountPoint = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Local mount point, e.g. \"/mnt/retroarch\".";
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "naps62";
|
||||
description = "Local owner of the mounted files (CIFS uid/gid).";
|
||||
};
|
||||
idleTimeout = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "600";
|
||||
description = "Seconds of inactivity before the share is unmounted.";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg != [ ]) {
|
||||
# mount.cifs helper must be on PATH for systemd to perform the mount.
|
||||
environment.systemPackages = [ pkgs.cifs-utils ];
|
||||
|
||||
fileSystems = lib.listToAttrs (
|
||||
map (m: {
|
||||
name = m.mountPoint;
|
||||
value = {
|
||||
device = "//${m.server}/${m.share}";
|
||||
fsType = "cifs";
|
||||
options = [
|
||||
# --- guest auth (no credentials) ---
|
||||
"guest"
|
||||
# --- lazy, VPN-safe automount ---
|
||||
"_netdev" # network fs: don't treat as a boot-blocking local mount
|
||||
"noauto" # don't mount at boot…
|
||||
"x-systemd.automount" # …mount on first access instead
|
||||
"x-systemd.mount-timeout=10s" # fail fast if the server is unreachable
|
||||
"x-systemd.idle-timeout=${m.idleTimeout}" # unmount when idle → fresh remount after VPN drop
|
||||
"nofail" # never let a failed mount fault the system
|
||||
# --- ownership / perms so ${m.user} can read+write ---
|
||||
"uid=${m.user}"
|
||||
"gid=users"
|
||||
"file_mode=0664"
|
||||
"dir_mode=0775"
|
||||
# If the server is old and rejects the negotiated dialect, pin it,
|
||||
# e.g. add "vers=1.0" and "sec=ntlm". Modern servers auto-negotiate.
|
||||
];
|
||||
};
|
||||
}) cfg
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -19,11 +19,22 @@
|
||||
../common/features/wine.nix
|
||||
../common/features/gaming
|
||||
../common/features/appimage.nix
|
||||
../common/features/smb-mounts.nix
|
||||
../common/features/home
|
||||
];
|
||||
|
||||
networking.hostName = "konishi";
|
||||
|
||||
# NAS media share — reachable only over the wg-home VPN. Lazy automount, so it
|
||||
# never blocks boot and (re)mounts on first access once the VPN is up.
|
||||
custom.smbMounts = [
|
||||
{
|
||||
server = "10.6.10.45";
|
||||
share = "media";
|
||||
mountPoint = "/mnt/media";
|
||||
}
|
||||
];
|
||||
|
||||
# Arm Wake-on-LAN (magic packet) on the Intel igc NIC and re-apply it on every
|
||||
# boot — the driver resets WoL state otherwise. Lets Moonlight wake this box
|
||||
# from suspend to stream. NOTE: also needs "Wake on LAN" enabled in BIOS (and
|
||||
|
||||
Reference in New Issue
Block a user