80 lines
2.2 KiB
Nix
80 lines
2.2 KiB
Nix
{ lib, config, flakeRoot, ... }:
|
|
|
|
let
|
|
# --- Module-specific variables ---
|
|
moduleName = "kitty";
|
|
username = config.defaultUser or "henrov";
|
|
assetPath = "${flakeRoot}/assets/system/conf/${moduleName}";
|
|
|
|
# Read all files in the asset directory
|
|
programFiles = builtins.readDir assetPath;
|
|
files = lib.genAttrs (builtins.attrNames programFiles) (name: {
|
|
src = "${assetPath}/${name}";
|
|
});
|
|
|
|
# Top-level enable toggle
|
|
enableProgram = config.enableKitty or true;
|
|
in
|
|
{
|
|
# --- Declare the top-level toggle for this module ---
|
|
options.enableKitty = lib.mkEnableOption "Enable Kitty terminal integration";
|
|
|
|
# --- Actual configuration applied only if enabled ---
|
|
config = lib.mkIf enableProgram {
|
|
|
|
# Dendritic container for this program
|
|
myApps.${moduleName} = {
|
|
enable = true;
|
|
user = username;
|
|
assetsDir = assetPath;
|
|
files = files;
|
|
|
|
# Example program-specific metadata
|
|
theme = "Catppuccin-Mocha";
|
|
};
|
|
|
|
# Deploy config files to user's ~/.config
|
|
home-manager.users.${username} = {
|
|
programs.kitty.enable = true;
|
|
|
|
xdg.configFile =
|
|
lib.mapAttrs' (name: value: {
|
|
name = "${moduleName}/${name}";
|
|
value.source = value.src;
|
|
}) files;
|
|
};
|
|
|
|
# Optional: systemd service to sync / deploy configuration
|
|
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}"
|
|
|
|
# Copy all asset files into user's config directory
|
|
for f in ${lib.concatStringsSep " " (builtins.attrNames files)}; do
|
|
cp -u "$CONF/$f" "$USER_HOME/.config/${moduleName}/$f"
|
|
done
|
|
'';
|
|
};
|
|
|
|
# Restart service if assets change
|
|
restartTriggers = [ assetPath ];
|
|
|
|
# Minimal PATH for the service
|
|
path = [
|
|
# Use symbolic references if needed, e.g., coreutils binaries
|
|
# pkgs.coreutils
|
|
# pkgs.gnugrep
|
|
];
|
|
};
|
|
};
|
|
}
|