Files
nixos/Droidnix/generated/modules/desktop/hyprland.nix
T
2026-03-20 09:01:52 +00:00

94 lines
2.5 KiB
Nix

{ lib, config, ... }:
let
# --- Module variables ---
moduleName = "hyprland";
username = config.defaultUser or "henrov";
# Assets directory
assetPath = ../../../assets/hyprland/conf/hypr;
# Read all files except main config
allFiles =
if builtins.pathExists assetPath
then builtins.readDir assetPath
else {};
otherFiles = lib.filter (name: name != "hyprland.conf") (builtins.attrNames allFiles);
files = lib.genAttrs otherFiles (name: {
src = "${assetPath}/${name}";
});
# Main config (inline)
mainConfigPath =
if builtins.pathExists "${assetPath}/hyprland.conf"
then "${assetPath}/hyprland.conf"
else null;
# Top-level toggle
enableProgram = config.enableHyprland or false;
in
{
# --- Option ---
options.enableHyprland = lib.mkEnableOption "Enable Hyprland desktop";
# --- Config ---
config = lib.mkIf enableProgram {
# Enable Hyprland programmatically
programs.hyprland.enable = true;
# --- Home Manager wiring ---
home-manager.users.${username} = {
home.stateVersion = "26.05";
home.username = username;
home.homeDirectory = "/home/${username}";
wayland.windowManager.hyprland = {
enable = true;
settings.general."col.active_border" = lib.mkForce "0xff97cbcd 0xff89b4fa";
};
# Deploy config files
xdg.configFile =
(lib.mapAttrs' (name: value: {
name = "hypr/${name}";
value.source = value.src;
}) files)
// (if mainConfigPath != null then {
"hypr/hyprland.conf".text = builtins.readFile mainConfigPath;
} else {})
// {
"hypr/.keep".text = "";
};
};
# --- Optional: systemd service to sync configs ---
systemd.services."${moduleName}-sync" = {
description = "Sync ${moduleName} configuration files";
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
if [ -f "${mainConfigPath}" ]; then
cp -u "${mainConfigPath}" "/home/${username}/.config/${moduleName}/hyprland.conf"
fi
'';
};
restartTriggers = [ assetPath ];
path = [];
};
};
}