🤖 Prompt for the AI Agent: Final Systemic Refactor
System Context:
We are finalizing the architectural migration of "Nomarchy" to NixOS 25.11. We need to address systemic issues regarding non-FHS pathing, orphaned Systemd services, script interpreter paths, and UWSM integration.

Please implement the following fixes across the system and home manager modules.

Task 1: Fix the FHS Trap (Polkit Agent)
The Hyprland autostart config relies on a hardcoded /usr/lib/ path, which breaks GUI authentication in NixOS.

Action 1: Instead of relying on autostart.conf to launch Polkit, create a native Home Manager systemd user service in a relevant module (e.g., modules/home/hyprland.nix or a new modules/home/security.nix).

Action 2: Define the service to execute ${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1. Ensure it belongs to the graphical-session.target.

Action 3: Remove the broken /usr/lib/... line from the legacy config/nomarchy/default/hypr/autostart.conf.

Task 2: Native Systemd Migration (Battery Monitor)
The battery monitor relies on static .service and .timer files that Home Manager does not automatically enable.

Action 1: Create a new module modules/home/battery-monitor.nix.

Action 2: Translate the logic from config/systemd/user/nomarchy-battery-monitor.service into systemd.user.services.nomarchy-battery-monitor = { ... };. Ensure the ExecStart path points correctly to the packaged nomarchy-battery-monitor script.

Action 3: Translate the timer into systemd.user.timers.nomarchy-battery-monitor = { ... }; and set WantedBy = [ "timers.target" ];.

Action 4: Delete the legacy config/systemd/user/ folder to prevent confusion. Ensure battery-monitor.nix is imported into modules/home/default.nix.

Task 3: Harden Custom Scripts (modules/home/scripts.nix)
The custom scripts in the bin/ directory will fail due to invalid #!/bin/bash shebangs and missing PATH dependencies.

Action 1: Audit modules/home/scripts.nix. If it currently uses a standard copy or symlink approach, rewrite the packaging logic.

Action 2: Use pkgs.stdenv.mkDerivation. In the installPhase, copy the bin/ folder, and crucially, run patchShebangs $out/bin to fix all interpreters natively.

Action 3: (Optional but recommended) If specific scripts heavily rely on external tools (like jq), consider using wrapProgram in a postFixup phase to prepend the required package binaries to the script's PATH.

Task 4: Enable Native UWSM (modules/system/sddm.nix or Hyprland config)
UWSM must be deeply integrated into the NixOS system layer to function correctly, not just mapped via dotfiles.

Action 1: In the system-level configuration where Hyprland is enabled (likely modules/system/default.nix or similar), ensure programs.hyprland.withUWSM = true; is set.

Action 2: Ensure any SDDM configurations are compatible with launching the UWSM wrapped session rather than standard Hyprland.

Please provide the updated code blocks for the affected Nix modules.
