Commit 7edc85175e73

Vincent Demeester <vincent@sbr.pm>
2026-06-10 23:36:18
fix(home): use osConfig for NixOS detection
Replaced builtins.pathExists "/etc/NIXOS" with osConfig null check. The pathExists approach evaluated at Nix build time in a sandbox where /etc/NIXOS doesn't exist, causing kitty, swaylock, and poweralertd to use non-NixOS fallbacks on NixOS hosts. Also disabled PSR on okinawa (amdgpu.dcdebugmask=0x10) to prevent DMCUB firmware hangs.
1 parent cdd1ec5
Changed files (4)
home
systems
okinawa
home/common/desktop/sway/swayidle.nix
@@ -2,9 +2,11 @@
   pkgs,
   lib,
   desktop,
+  osConfig ? null,
   ...
 }:
 let
+  isNixOS = osConfig != null;
   powerOffCmd =
     if desktop == "niri" then
       "${niriPowerOffScript}"
@@ -18,7 +20,7 @@ let
   # Dynamically detect the eDP output name (eDP-1, eDP-2, etc.) since it
   # varies across laptops.
   # On NixOS, use the nix-built niri; on non-NixOS (Fedora CSB), use system niri
-  niriCmd = if builtins.pathExists "/etc/NIXOS" then "${pkgs.niri}/bin/niri" else "niri";
+  niriCmd = if isNixOS then "${pkgs.niri}/bin/niri" else "niri";
   niriPowerOffScript = pkgs.writeShellScript "niri-power-off-monitors" ''
     edp=$(${niriCmd} msg outputs | ${pkgs.gnugrep}/bin/grep -oP 'eDP-\d+')
     if [ -n "$edp" ]; then
@@ -42,8 +44,7 @@ let
   # (Fedora CSB), the nix-built swaylock is NOT setuid and cannot validate the
   # password against /etc/shadow, resulting in a red screen that never unlocks.
   # Use the system-provided swaylock there instead.
-  swaylockCmd =
-    if builtins.pathExists "/etc/NIXOS" then "${pkgs.swaylock}/bin/swaylock" else "/usr/bin/swaylock";
+  swaylockCmd = if isNixOS then "${pkgs.swaylock}/bin/swaylock" else "/usr/bin/swaylock";
 in
 {
   home.packages =
@@ -53,7 +54,7 @@ in
     ]
     # On non-NixOS (Fedora CSB), use the system swaylock (setuid + PAM-wired);
     # the nix-built one can't validate passwords and shows a red lock screen.
-    ++ lib.optionals (builtins.pathExists "/etc/NIXOS") [ swaylock ];
+    ++ lib.optionals isNixOS [ swaylock ];
   services.swayidle = {
     enable = true;
     events = {
home/common/desktop/default.nix
@@ -2,6 +2,7 @@
   config,
   pkgs,
   desktop,
+  osConfig ? null,
   ...
 }:
 {
@@ -75,7 +76,7 @@
 
   services = {
     udiskie.enable = true;
-    poweralertd.enable = builtins.pathExists "/etc/NIXOS";
+    poweralertd.enable = osConfig != null;
     gnome-keyring.enable = true;
   };
 
home/common/desktop/kitty.nix
@@ -1,9 +1,13 @@
-{ pkgs, ... }:
+{
+  pkgs,
+  osConfig ? null,
+  ...
+}:
 {
   programs.kitty = {
     enable = true;
     # On non-NixOS (Fedora CSB), use system kitty to avoid GPU driver issues
-    package = if builtins.pathExists "/etc/NIXOS" then pkgs.kitty else pkgs.emptyDirectory;
+    package = if osConfig != null then pkgs.kitty else pkgs.emptyDirectory;
     shellIntegration.enableZshIntegration = false; # handled in dots/config/zsh/tools/kitty.zsh
     settings = {
       close_on_child_death = "yes";
systems/okinawa/boot.nix
@@ -45,6 +45,9 @@
       # allocator crashes in __alloc_tagging_slab_alloc_hook (CVE-2025-37774)
       # https://www.cve.org/CVERecord?id=CVE-2025-37774
       "sysctl.vm.mem_profiling=0"
+
+      # Disable PSR (Panel Self Refresh) to prevent DMCUB firmware hangs
+      "amdgpu.dcdebugmask=0x10"
     ];
 
     # Blacklist unnecessary wireless modules