dotfiles/nixos/hosts/trailblazer/default.nix
Kate Temkin 5f845ea0c6 pushflake.lock: Update
Flake lock file updates:

• Updated input 'darwin':
    'github:lnl7/nix-darwin/44a7d0e687a87b73facfe94fba78d323a6686a90' (2025-05-27)
  → 'github:lnl7/nix-darwin/19346808c445f23b08652971be198b9df6c33edc' (2025-06-06)
• Updated input 'home-manager':
    'github:nix-community/home-manager/cb809ec1ff15cf3237c6592af9bbc7e4d983e98c' (2025-06-03)
  → 'github:nix-community/home-manager/96482a538e6103579d254b139759d0536177370b' (2025-06-06)
• Updated input 'lix':
    'git+https://git@git.lix.systems/lix-project/lix?ref=refs/heads/main&rev=019b17f4e93c098f99a9bc691be1f1c4df026c7d' (2025-06-02)
  → 'git+https://git@git.lix.systems/lix-project/lix?ref=refs/heads/main&rev=fca0a30470b7040489feeb2a86bad05bf9b1aa95' (2025-06-02)
• Updated input 'niri':
    'github:sodiboo/niri-flake/b6084ca94d7be6aa9c3165fbdced16efc5b8247e' (2025-06-03)
  → 'github:sodiboo/niri-flake/32d49ef427be377c82d32ce74ff3082c2c992199' (2025-06-05)
• Updated input 'niri/niri-unstable':
    'github:YaLTeR/niri/1911cf3f55ac3d9d24c8692434a93214dcbde9ba' (2025-06-01)
  → 'github:YaLTeR/niri/242ebf294514cc22f4f9d83c0566c8ffe1cb8d8a' (2025-06-05)
• Updated input 'niri/nixpkgs':
    'github:NixOS/nixpkgs/910796cabe436259a29a72e8d3f5e180fc6dfacc' (2025-05-31)
  → 'github:NixOS/nixpkgs/c2a03962b8e24e669fb37b7df10e7c79531ff1a4' (2025-06-03)
• Updated input 'niri/nixpkgs-stable':
    'github:NixOS/nixpkgs/10d7f8d34e5eb9c0f9a0485186c1ca691d2c5922' (2025-06-02)
  → 'github:NixOS/nixpkgs/4792576cb003c994bd7cc1edada3129def20b27d' (2025-06-05)
• Updated input 'nix-hardware':
    'github:nixos/nixos-hardware/fc7c4714125cfaa19b048e8aaf86b9c53e04d853' (2025-06-03)
  → 'github:nixos/nixos-hardware/4602f7e1d3f197b3cb540d5accf5669121629628' (2025-06-06)
• Updated input 'nixos-hardware':
    'github:NixOS/nixos-hardware/fc7c4714125cfaa19b048e8aaf86b9c53e04d853' (2025-06-03)
  → 'github:NixOS/nixos-hardware/4602f7e1d3f197b3cb540d5accf5669121629628' (2025-06-06)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/910796cabe436259a29a72e8d3f5e180fc6dfacc' (2025-05-31)
  → 'github:NixOS/nixpkgs/c2a03962b8e24e669fb37b7df10e7c79531ff1a4' (2025-06-03)
• Updated input 'stylix':
    'github:danth/stylix/3ca2c4478a1e984d2007c57467c6986bcdcb2629' (2025-06-02)
  → 'github:danth/stylix/8456dfa7f60e6b4499b0498fc88e9b8b57d4d7d7' (2025-06-05)
• Updated input 'waveforms/nixpkgs':
    'path:/nix/store/p893dkrzm5rxvhnqh092prgi1a7dzmcy-source?lastModified=1747744144&narHash=sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q%3D&rev=2795c506fe8fb7b03c36ccb51f75b6df0ab2553f' (2025-05-20)
  → 'path:/nix/store/dax78flrvcdir20swzlcm64va09nh5x8-source?lastModified=1748693115&narHash=sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8%3D&rev=910796cabe436259a29a72e8d3f5e180fc6dfacc' (2025-05-31)
2025-06-07 16:06:37 +02:00

296 lines
8.2 KiB
Nix

#
# Per-system configuration for Trailblazer.
#
# vim: et:ts=2:sw=2:
#
{
config,
lib,
pkgs,
modulesPath,
deprekages,
...
}:
let
ledOffScript = pkgs.writeScriptBin "ledsoff" ''
#!${pkgs.bash}/bin/bash
openrgb -d 0 -m off -b 0
openrgb -d 1 -m off -b 0
openrgb -d 2 -m off -b 0
openrgb -d 3 -m off -b 0
openrgb -d 4 -m off -b 0
openrgb -d "Corsair Lighting Node Pro" -m direct -z 0 -s 100 -b 0 -c black
openrgb -d "Corsair Lighting Node Pro" -m direct -z 1 -s 100 -b 0 -c black
'';
ledOnScript = pkgs.writeScriptBin "ledson" ''
#!${pkgs.bash}/bin/bash
openrgb -d 0 -m direct -c $1 -b 100
openrgb -d 1 -m direct -c $1 -b 100
openrgb -d 2 -m direct -c $1 -b 100
openrgb -d 3 -m direct -c $1 -b 100
openrgb -d 4 -m direct -c $1 -b 100
openrgb -d "Corsair Lighting Node Pro" -m direct -z 0 -s 100 -b 100 -c $1
openrgb -d "Corsair Lighting Node Pro" -m direct -z 1 -s 100 -b 100 -c $1
'';
#mqttServer = "fuuka"
mqttServer = "mitsuru";
commandScript = pkgs.writeScriptBin "trailblazer-command-daemon" ''
#!${pkgs.xonsh}/bin/xonsh
print("[I] Trailblazer command service started. Waiting for command.")
print("----------------------------")
for verb in !(${pkgs.mosquitto}/bin/mosquitto_sub -h ${mqttServer} -t trailblazer/command):
verb = verb.strip()
if verb == "lights/off":
print("[I] Got a 'lights out' request. Making things quiet.")
# Turn off monitors for any X11 anything.
for auth in g`/tmp/xauth_*`:
print(f"[I] Turning off monitors on X instance with auth file {auth}.")
!(env DISPLAY=:0 XAUTHORITY=@(auth) xset dpms force off)
# Turn off monitors on each niri session,
sockets = g`/var/run/user/1000/niri*.sock`
for socket in sockets:
print(f"[I] Turning off monitors on niri instance {socket}.")
!(env NIRI_SOCKET=@(socket) niri msg action power-off-monitors)
print("[I] Turning off RGB leds.")
!(${ledOffScript}/bin/ledsoff)
print("[I] Everything should be... well, not-shiny, captain!")
if verb == "lights/ledsoff":
print("[I] Turning off RGB leds.")
!(${ledOffScript}/bin/ledsoff)
elif verb == "lights/o":
print("[I] Setting lights to 'sight colors.")
!(${ledOnScript}/bin/ledson white)
elif verb == "lights/t":
print("[I] Setting lights to tsu colors.")
!(${ledOnScript}/bin/ledson blue)
elif verb == "lights/k":
print("[I] Setting lights to Kaye colors.")
!(${ledOnScript}/bin/ledson purple)
elif verb == "lights/w":
print("[I] Setting lights to Whim colors.")
!(${ledOnScript}/bin/ledson green)
elif verb == "lights/s":
print("[I] Setting lights to Scar colors.")
!(${ledOnScript}/bin/ledson red)
elif verb == "lights/e":
print("[I] Setting lights to Echo colors.")
!(${ledOnScript}/bin/ledson gray)
elif verb == "suspend":
print("[I] Going to sleep, as requested.")
!(systemctl suspend)
else:
print(f"[W] ignoring unknown verb '{verb}'")
print("----------------------------")
'';
in
{
system.stateVersion = "23.11";
imports = [
#./ups.nix
./scanner.nix
(modulesPath + "/installer/scan/not-detected.nix")
../../configs/build-machine-users.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Networking.
networking.hostName = "trailblazer";
networking.networkmanager.enable = true;
networking.firewall.enable = false;
# This is a local machine, rather than our typical network-accesed ones.
# Run an ssh-agent locally.
programs.ssh.startAgent = true;
# Let fuse run as our user and still mount with proper perms.
programs.fuse.userAllowOther = true;
# Optimize our system for virtualisation.
#boot.kernelPackages = pkgs.linuxPackages_zen;
# Disallow nouveau so the NVIDIA device is available for VFIO.
boot.blacklistedKernelModules = [ "nouveau" ];
# Allow IOMMU members to be sorted into their own groups for passthrough.
boot.kernelParams = [
"iommu=on"
"amd_iommu=on"
#"pcie_acs_override=downstream,multifunction"
];
# Enable fingerprint reader.
services.fprintd.enable = true;
# Enable steam.
programs.gamescope = {
enable = true;
capSysNice = true;
};
programs.steam = {
enable = true;
gamescopeSession.enable = true;
};
#
# Niri configuration for our monitors.
#
home-manager.users.deprekated = {
programs.niri.settings = {
# Center monitor.
outputs."LG Electronics LG ULTRAFINE 408NTYT4A658" = {
position = {
x = 0;
y = 0;
};
scale = 1.5;
transform.rotation = 270;
};
# Laptop screen.
outputs."Samsung Electric Company Odyssey G70B H1AK50000" = {
position = {
x = 1440;
y = 0;
};
scale = 1.5;
};
# Front panel display.
outputs."Shenzhen Soogeen Electronics Co., LTD. L01N8A 0x01348C5C" = {
scale = 1.0;
transform.rotation = 90;
};
};
# Also position waybar on only one monitor.
programs.waybar.settings.mainBar.output = "DP-1";
};
# Override stylix font sizes.
stylix.fonts.sizes.desktop = lib.mkForce 16;
# Use kwin for sddm instead of westin, to account for multi-monitor.
services.displayManager.sddm.wayland.compositor = "kwin";
# Use OpenRGB so we can silence our LEDs when appropriate.
services.hardware.openrgb = {
enable = true;
package = pkgs.openrgb-with-all-plugins;
motherboard = "amd";
};
# Provide docker for remote tasks.
virtualisation.docker.enable = true;
users.users.deprekated.extraGroups = [ "docker" ];
#
# Trailblazer remote service (allows trailblazer things to be controlled via Home Assistant.
#
systemd.services.trailblazer-commands = {
description = "trailblazer command service";
# Start once we're online.
wantedBy = [ "default.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
script = "${commandScript}/bin/trailblazer-command-daemon";
};
#
# Let trailblazer share its GPS with the house devices.
#
systemd.services.gps-share = {
description = "share our GPS with our other devices on the LAN";
# Start once we're online.
wantedBy = [ "default.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
script = "${deprekages.gps-share}/bin/gps-share /dev/ttyACM0";
};
#
# Hardware config.
#
boot.initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
"dm-raid"
];
boot.initrd.kernelModules = [ ];
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
boot.kernelModules = [
"kvm-amd"
"v4l2loopback"
];
fileSystems."/" = {
device = "/dev/disk/by-label/nix";
fsType = "xfs";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
fileSystems."/home" = {
device = "/dev/disk/by-label/home";
fsType = "xfs";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp26s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp25s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
boot.swraid.enable = true;
boot.swraid.mdadmConf = ''
MAILADDR kate@deprekated.net
ARRAY /dev/md/nixos:0 level=raid0 num-devices=2 metadata=1.2 UUID=325ee7dc:7fcc6062:635e902f:af2552dc
devices=/dev/nvme0n1p1,/dev/nvme1n1p1
'';
}