nix/home/scripts.nix
2026-03-20 15:37:34 -04:00

36 lines
1.2 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
customScripts = import ../scripts {inherit config lib pkgs;};
in {
home.packages = builtins.attrValues customScripts.packages;
home.activation.initializeThemeState = lib.hm.dag.entryAfter ["writeBoundary"] ''
mkdir -p "${customScripts.theme.paths.stateDir}" "${customScripts.theme.paths.ghosttyDir}" "${customScripts.theme.paths.tmuxDir}"
if [[ -f "${customScripts.theme.paths.stateFile}" ]]; then
mode=$(tr -d '[:space:]' < "${customScripts.theme.paths.stateFile}")
else
mode="${customScripts.theme.defaultMode}"
printf '%s\n' "$mode" > "${customScripts.theme.paths.stateFile}"
fi
case "$mode" in
light)
ghostty_target="${customScripts.theme.paths.ghosttyDir}/cozybox-light"
tmux_target="${customScripts.tmuxConfigs.light}"
;;
*)
printf '%s\n' "${customScripts.theme.defaultMode}" > "${customScripts.theme.paths.stateFile}"
ghostty_target="${customScripts.theme.paths.ghosttyDir}/cozybox-dark"
tmux_target="${customScripts.tmuxConfigs.dark}"
;;
esac
ln -sfn "$ghostty_target" "${customScripts.theme.paths.ghosttyCurrentFile}"
ln -sfn "$tmux_target" "${customScripts.theme.paths.tmuxCurrentFile}"
'';
}