From c1c077dc698d8eaad9f825cccc690dfac1c9806c Mon Sep 17 00:00:00 2001 From: NeilClack Date: Wed, 25 Mar 2026 19:56:41 -0500 Subject: [PATCH] Update asset locations and permissions --- flake.nix | 10 +++- nixos/module.nix | 116 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 94 insertions(+), 32 deletions(-) diff --git a/flake.nix b/flake.nix index faebc3b..86b1712 100644 --- a/flake.nix +++ b/flake.nix @@ -69,11 +69,17 @@ ]; postInstall = '' - cp -r share $out/share + # Create the destination + mkdir -p $out/share/rhemawave + + # Copy everything from your local share/rhemawave/* into the store + cp -r share/rhemawave/* $out/share/rhemawave/ + + # Add the fetched audio file specifically mkdir -p $out/share/rhemawave/audio cp ${audioFile} $out/share/rhemawave/audio/audio.wav ''; - + meta = with pkgs.lib; { description = "RhemaWave kiosk application"; license = licenses.unfree; diff --git a/nixos/module.nix b/nixos/module.nix index 6da3ba5..f52f852 100644 --- a/nixos/module.nix +++ b/nixos/module.nix @@ -15,22 +15,12 @@ in description = "The RhemaWave package to use."; }; - # There should not be a "kioskUser" defined in the program - # That should be defined by the system, so everything kioskUser related - # has been commented out. - user = lib.mkOption { type = lib.types.str; default = "kiosk"; description = "User account that runs the kiosk session."; }; - # extraGroups = lib.mkOption { - # type = lib.types.listOf lib.types.str; - # default = []; - # description = "Additional groups for the kiosk user."; - # }; - autoVolume = lib.mkOption { type = lib.types.bool; default = true; @@ -39,24 +29,87 @@ in }; config = lib.mkIf cfg.enable { - # # --- Kiosk user --- - # users.users.${cfg.kioskUser} = { - # isNormalUser = true; - # group = cfg.kioskUser; - # extraGroups = [ "audio" "video" "input" "networkmanager" ] ++ cfg.extraGroups; - # }; - # users.groups.${cfg.kioskUser} = {}; - # --- Display: agetty + cage --- - + # --- 1. Environment & Desktop setup --- + environment.sessionVariables = { + SDL_VIDEODRIVER = "wayland"; + QT_QPA_PLATFORM = "wayland"; + GDK_BACKEND = "wayland"; + CLUTTER_BACKEND = "wayland"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + }; - # --- Environment --- - environment.variables.SDL_VIDEODRIVER = "wayland"; + # --- 2. Asset Management & Runtime Dirs --- + systemd.tmpfiles.rules = [ + # User Runtime Directory for Wayland + "d /run/user/1000 0700 ${cfg.user} kiosk -" - # --- Networking --- + # Asset directory for the kiosk user + "d /home/${cfg.user}/.local/share/rhemawave 0700 ${cfg.user} kiosk -" + + # Symlinks for assets + "L+ /home/${cfg.user}/.local/share/rhemawave/shaders - - - ${cfg.package}/share/rhemawave/shaders" + "L+ /home/${cfg.user}/.local/share/rhemawave/fonts - - - ${cfg.package}/share/rhemawave/fonts" + "L+ /home/${cfg.user}/.local/share/rhemawave/tos - - - ${cfg.package}/share/rhemawave/tos" + "L+ /home/${cfg.user}/.local/share/rhemawave/audio - - - ${cfg.package}/share/rhemawave/audio" + "L+ /home/${cfg.user}/.local/share/rhemawave/proclamations - - - ${cfg.package}/share/rhemawave/proclamations" + ]; + + # --- 3. The Kiosk Service --- + systemd.services."getty@tty1".enable = false; + + systemd.services.rhemawave-kiosk = { + description = "RhemaWave Kiosk Cage Session"; + after = [ "network.target" "systemd-user-sessions.service" "seatd.service" ]; + wants = [ "seatd.service" ]; + conflicts = [ "getty@tty1.service" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Type = "simple"; + StandardInput = "tty"; + StandardOutput = "journal"; + StandardError = "journal"; + TTYPath = "/dev/tty1"; + UtmpIdentifier = "tty1"; + TTYReset = "yes"; + TTYVHangup = "yes"; + TTYVTDisallocate = "yes"; + + ExecStart = pkgs.writeShellScript "launch-rhemawave" '' + # Take over the physical terminal + ${pkgs.util-linux}/bin/chvt 1 || true + + # Detect GPU + if [ -e /dev/dri/card1 ]; then + export WLR_DRM_DEVICES=/dev/dri/card1 + else + export WLR_DRM_DEVICES=/dev/dri/card0 + fi + + export XDG_RUNTIME_DIR="/run/user/1000" + export LIBSEAT_BACKEND=seatd + export WLR_LIBINPUT_NO_DEVICES=1 + + # Audio Volume Setup + ${lib.optionalString cfg.autoVolume '' + ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 2>/dev/null || true + ''} + + # Launch Cage with XWayland disabled + exec ${pkgs.util-linux}/bin/runuser -u ${cfg.user} -- \ + ${pkgs.cage}/bin/cage -d -s -- ${cfg.package}/bin/rhemawave + ''; + + Restart = "always"; + RestartSec = "3s"; + }; + }; + + # --- 4. System Services & Hardware --- networking.networkmanager.enable = true; - - # --- Audio: PipeWire + WirePlumber --- + services.seatd.enable = true; + services.pipewire = { enable = true; alsa.enable = true; @@ -64,20 +117,23 @@ in wireplumber.enable = true; }; - # --- Polkit rules --- + services.udev.extraRules = '' + SUBSYSTEM=="drm", KERNEL=="card[0-9]*", GROUP="video", MODE="0660" + SUBSYSTEM=="input", KERNEL=="event[0-9]*", GROUP="input", MODE="0660" + ''; + + # --- 5. Polkit rules --- security.polkit.extraConfig = '' polkit.addRule(function(action, subject) { - // Allow restarting getty@tty1 if (action.id == "org.freedesktop.systemd1.manage-units") { var unit = action.lookup("unit"); - if (unit == "getty@tty1.service") { + if (unit == "rhemawave-update.service" || unit == "rhemawave-kiosk.service") { return polkit.Result.YES; } } }); ''; - # --- Make the package available system-wide --- - environment.systemPackages = [ cfg.package ]; + environment.systemPackages = [ cfg.package pkgs.cage ]; }; -} +} \ No newline at end of file