Regenerated
This commit is contained in:
+61
-43
@@ -650,88 +650,106 @@ Finally, it creates a systemd user service (wpaperd.service) that automatically
|
||||
** =generated/modules/desktop/hyprland.nix=
|
||||
Setting up Hyprland
|
||||
#+BEGIN_SRC nix :tangle generated/modules/desktop/hyprland.nix :noweb tangle :mkdirp yes :eval never-html
|
||||
{ lib, config, flakeRoot, ... }:
|
||||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
# --- Program definition ---
|
||||
programName = "hyprland";
|
||||
# --- Module variables ---
|
||||
moduleName = "hyprland";
|
||||
username = config.defaultUser or "henrov";
|
||||
|
||||
# --- Assets ---
|
||||
programAssets = "${flakeRoot}/assets/hyprland/conf/hypr";
|
||||
# Assets directory
|
||||
assetPath = ../../../assets/hyprland/conf/hypr;
|
||||
|
||||
programFiles =
|
||||
if builtins.pathExists programAssets
|
||||
then builtins.readDir programAssets
|
||||
# Read all files except main config
|
||||
allFiles =
|
||||
if builtins.pathExists assetPath
|
||||
then builtins.readDir assetPath
|
||||
else {};
|
||||
|
||||
fileNames = builtins.attrNames programFiles;
|
||||
otherFiles = lib.filter (name: name != "hyprland.conf") (builtins.attrNames allFiles);
|
||||
|
||||
# Exclude main config (handled separately)
|
||||
otherFiles = lib.filter (name: name != "hyprland.conf") fileNames;
|
||||
|
||||
# Generate file mappings
|
||||
files = lib.genAttrs otherFiles (name: {
|
||||
src = "${programAssets}/${name}";
|
||||
src = "${assetPath}/${name}";
|
||||
});
|
||||
|
||||
# Main config (inline)
|
||||
mainConfigPath = "${programAssets}/hyprland.conf";
|
||||
mainConfigPath =
|
||||
if builtins.pathExists "${assetPath}/hyprland.conf"
|
||||
then "${assetPath}/hyprland.conf"
|
||||
else null;
|
||||
|
||||
# Enable toggle (must match option)
|
||||
enableProgram = config.enableHyprland or true;
|
||||
|
||||
# Resolve user safely
|
||||
user = config.defaultUser or "henrov";
|
||||
# Top-level toggle
|
||||
enableProgram = config.enableHyprland or false;
|
||||
in
|
||||
{
|
||||
# --- Option ---
|
||||
options.enableHyprland =
|
||||
lib.mkEnableOption "Enable Hyprland desktop";
|
||||
options.enableHyprland = lib.mkEnableOption "Enable Hyprland desktop";
|
||||
|
||||
# --- Config ---
|
||||
config = lib.mkIf enableProgram {
|
||||
|
||||
# --- Dendritic app definition ---
|
||||
mySystem.${programName} = {
|
||||
enable = true;
|
||||
assetsDir = programAssets;
|
||||
files = files;
|
||||
inherit user;
|
||||
|
||||
myApps.${moduleName} = {
|
||||
enable = true;
|
||||
assetsDir = assetPath;
|
||||
files = files;
|
||||
user = username;
|
||||
compositor = "hyprland";
|
||||
};
|
||||
|
||||
# --- System-level enable ---
|
||||
# Enable Hyprland programmatically
|
||||
programs.hyprland.enable = true;
|
||||
|
||||
# --- Home Manager wiring ---
|
||||
home-manager.users.${user} = {
|
||||
|
||||
home.stateVersion = "26.05";
|
||||
home.username = user;
|
||||
home.homeDirectory = "/home/${user}";
|
||||
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";
|
||||
};
|
||||
|
||||
# --- Config files ---
|
||||
# Deploy config files
|
||||
xdg.configFile =
|
||||
(lib.mapAttrs' (name: value: {
|
||||
name = "hypr/${name}";
|
||||
name = "hypr/${name}";
|
||||
value.source = value.src;
|
||||
}) files)
|
||||
// (if mainConfigPath != null then {
|
||||
"hypr/hyprland.conf".text = builtins.readFile mainConfigPath;
|
||||
} else {})
|
||||
// {
|
||||
"hypr/hyprland.conf".text =
|
||||
if builtins.pathExists mainConfigPath
|
||||
then builtins.readFile mainConfigPath
|
||||
else "";
|
||||
"hypr/.keep".text = "";
|
||||
};
|
||||
};
|
||||
|
||||
"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 = [];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user