{ lib, config, ... }: let # --- Module variables --- moduleName = "kitty"; username = config.defaultUser or "henrov"; # Path to program assets (relative, self-contained) assetPath = ../../../assets/system/conf/${moduleName}; # Read all files in the assets directory programFiles = builtins.readDir assetPath; files = lib.genAttrs (builtins.attrNames programFiles) (name: { src = "${assetPath}/${name}"; }); # Top-level toggle for this module enableProgram = config.enableKitty or true; in { # --- Declare the top-level toggle --- options.enableKitty = lib.mkEnableOption "Enable Kitty terminal integration"; # --- Only apply configuration if enabled --- config = lib.mkIf enableProgram { # Kitty program configuration programs.kitty.enable = true; programs.kitty.extraConfig = '' # 1) Theme first include themes/Catppuccin-Mocha.conf # 2) Force transparency last #background_opacity 0.60 #dynamic_background_opacity yes ''; # Deploy configuration files to user's XDG config home-manager.users.${username} = { xdg.configFile = lib.mapAttrs' (name: value: { name = "${moduleName}/${name}"; value.source = value.src; }) files; }; # Example systemd service to sync assets to user's config directory 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 CONF="${assetPath}" USER_HOME="/home/${username}" for f in ${lib.concatStringsSep " " (builtins.attrNames files)}; do cp -u "$CONF/$f" "$USER_HOME/.config/${moduleName}/$f" done ''; }; restartTriggers = [ assetPath ]; # Minimal PATH (no pkgs references needed unless necessary) path = [ ]; }; }; }