Regenerated
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
# --- Module variables ---
|
||||
moduleName = "waybar";
|
||||
username = config.defaultUser or "henrov";
|
||||
|
||||
# Assets directory
|
||||
assetPath =
|
||||
if builtins.pathExists ../../../assets/system/conf/${moduleName}
|
||||
then ../../../assets/system/conf/${moduleName}
|
||||
else null;
|
||||
|
||||
# Read all files if assets exist
|
||||
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.enableWaybar or false;
|
||||
in
|
||||
{
|
||||
# --- Top-level toggle option ---
|
||||
options.enableWaybar = lib.mkEnableOption "Enable Waybar status bar";
|
||||
|
||||
# --- Only apply configuration if enabled ---
|
||||
config = lib.mkIf enableProgram {
|
||||
|
||||
# --- Dendritic container ---
|
||||
waybar = {
|
||||
enable = true;
|
||||
user = username;
|
||||
assetsDir = assetPath;
|
||||
files = files;
|
||||
};
|
||||
|
||||
# --- Deploy configuration to ~/.config/waybar ---
|
||||
home-manager.users.${username} = lib.mkIf assetPath != null {
|
||||
xdg.configFile =
|
||||
lib.mapAttrs' (name: value: {
|
||||
name = "${moduleName}/${name}";
|
||||
value.source = value.src;
|
||||
}) files;
|
||||
};
|
||||
|
||||
# --- Optional systemd service to sync configs ---
|
||||
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 = [];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user