Files
nixos/Droidnix/generated/modules/desktop/wayland.nix
T
2026-03-19 14:59:24 +00:00

97 lines
2.5 KiB
Nix

{ lib, config, ... }:
let
# --- Module variables ---
moduleName = "wayland";
username = config.defaultUser or "henrov";
# Assets directory (optional)
assetPath =
if builtins.pathExists ../../../assets/system/conf/${moduleName}
then ../../../assets/system/conf/${moduleName}
else null;
programFiles =
if assetPath != null
then builtins.readDir assetPath
else {};
files = lib.genAttrs (builtins.attrNames programFiles) (name: {
src = "${assetPath}/${name}";
});
# Top-level toggle for this module
enableProgram = config.enableWayland or true;
in
{
# --- Declare the top-level toggle ---
options.enableWayland = lib.mkEnableOption "Enable Wayland + portals";
# --- Only apply configuration if enabled ---
config = lib.mkIf enableProgram {
# Example dendritic container (flat, self-contained)
wayland = {
enable = true;
user = username;
assetsDir = assetPath;
files = files;
# Wayland-specific metadata
portals = [ "hyprland" ];
};
# Deploy assets to user's XDG config if they exist
home-manager.users.${username} = lib.mkIf assetPath != null {
xdg.configFile =
lib.mapAttrs' (name: value: {
name = "${moduleName}/${name}";
value.source = value.src;
}) files;
};
# Example portal + packages configuration
home-manager.users.${username} = {
xdg.portal = {
enable = true;
# Only reference pkgs if unavoidable
extraPortals = [
config.pkgs.xdg-desktop-portal-hyprland
];
config.hyprland = {
"org.freedesktop.impl.portal.Screencast" = [ "hyprland" ];
};
};
home.packages = [
config.pkgs.uwsm
];
};
# Optional systemd service to sync configs (if needed)
systemd.services."${moduleName}-sync" = {
description = "Sync ${moduleName} configuration";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = ''
set -euo pipefail
if [ -d "${assetPath}" ]; then
for f in ${lib.concatStringsSep " " (builtins.attrNames files)}; do
cp -u "${assetPath}/$f" "/home/${username}/.config/${moduleName}/$f"
done
fi
'';
};
restartTriggers = [ assetPath ];
path = [];
};
};
}