Add support for matugen output directories in DMS configuration
This commit is contained in:
@@ -3,11 +3,36 @@
|
|||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
osConfig ? { },
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
home = config.home.homeDirectory;
|
home = config.home.homeDirectory;
|
||||||
cfg = config.dms;
|
cfg = config.dms;
|
||||||
gpuTempEnabled = cfg.enableGpuTemp;
|
gpuTempEnabled = cfg.enableGpuTemp;
|
||||||
|
hyprlandEnabled = lib.attrByPath [ "chiasson" "desktop" "hyprland" "enable" ] false osConfig;
|
||||||
|
discordEnabled = lib.attrByPath [ "chiasson" "home" "apps" "discord" "enable" ] false config;
|
||||||
|
ohMyPoshEnabled = config.programs.oh-my-posh.enable or false;
|
||||||
|
matugenOutputDirs =
|
||||||
|
lib.optionals hyprlandEnabled [ "${home}/.config/hypr" ]
|
||||||
|
++ lib.optionals ohMyPoshEnabled [ "${home}/.config/oh-my-posh" ]
|
||||||
|
++ lib.optionals discordEnabled [ "${home}/.config/vesktop/themes" ];
|
||||||
|
ensureMatugenOutputDirsScript = pkgs.writeShellScript "dms-ensure-matugen-output-dirs" ''
|
||||||
|
set -euo pipefail
|
||||||
|
${lib.concatStringsSep "\n" (map (dir: "mkdir -p ${lib.escapeShellArg dir}") matugenOutputDirs)}
|
||||||
|
${lib.optionalString ohMyPoshEnabled ''
|
||||||
|
dest="$HOME/.config/oh-my-posh/theme.omp.json"
|
||||||
|
template="$HOME/.config/matugen/templates/ohmyposh-theme.omp.json"
|
||||||
|
# matugen writes output_path in place; HM symlinks into the store are read-only and go stale.
|
||||||
|
if [ -L "$dest" ] || { [ -e "$dest" ] && ! [ -f "$dest" ]; }; then
|
||||||
|
rm -f "$dest"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$dest" ]; then
|
||||||
|
# Seed from our matugen template (same generation closure), not programs.oh-my-posh.package
|
||||||
|
# which can reference a GC'd store path after profile churn.
|
||||||
|
cp -L "$template" "$dest"
|
||||||
|
fi
|
||||||
|
''}
|
||||||
|
'';
|
||||||
obsidianSnippetsDir = cfg.obsidianSnippetsDir; # legacy single path
|
obsidianSnippetsDir = cfg.obsidianSnippetsDir; # legacy single path
|
||||||
obsidianSnippetDirs =
|
obsidianSnippetDirs =
|
||||||
let
|
let
|
||||||
@@ -541,29 +566,40 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# matugen won't create missing output_path parents; run before DMS theme generation.
|
||||||
|
systemd.user.services.dms.serviceConfig.ExecStartPre =
|
||||||
|
lib.mkOrder 100 "${ensureMatugenOutputDirsScript}";
|
||||||
|
|
||||||
# DMS / matugen custom templates.
|
# DMS / matugen custom templates.
|
||||||
#
|
#
|
||||||
# DMS docs (custom templates): https://danklinux.com/docs/dankmaterialshell/application-themes#custom-matugen-templates
|
# DMS docs (custom templates): https://danklinux.com/docs/dankmaterialshell/application-themes#custom-matugen-templates
|
||||||
xdg.configFile."matugen/config.toml".text =
|
xdg.configFile."matugen/config.toml".text =
|
||||||
''
|
''
|
||||||
[config]
|
[config]
|
||||||
|
''
|
||||||
|
+ lib.optionalString hyprlandEnabled ''
|
||||||
[templates.hyprland]
|
[templates.hyprland]
|
||||||
input_path = '${home}/.config/matugen/templates/hyprland-colors.conf'
|
input_path = '${home}/.config/matugen/templates/hyprland-colors.conf'
|
||||||
output_path = '${home}/.config/hypr/colors.conf'
|
output_path = '${home}/.config/hypr/colors.conf'
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
|
||||||
[templates.kdeglobals]
|
[templates.kdeglobals]
|
||||||
input_path = '${home}/.config/matugen/templates/kdeglobals.conf'
|
input_path = '${home}/.config/matugen/templates/kdeglobals.conf'
|
||||||
output_path = '${home}/.config/kdeglobals'
|
output_path = '${home}/.config/kdeglobals'
|
||||||
|
''
|
||||||
|
+ lib.optionalString ohMyPoshEnabled ''
|
||||||
|
|
||||||
[templates.ohmyposh]
|
[templates.ohmyposh]
|
||||||
input_path = '${home}/.config/matugen/templates/ohmyposh-theme.omp.json'
|
input_path = '${home}/.config/matugen/templates/ohmyposh-theme.omp.json'
|
||||||
output_path = '${home}/.config/oh-my-posh/theme.omp.json'
|
output_path = '${home}/.config/oh-my-posh/theme.omp.json'
|
||||||
|
''
|
||||||
|
+ lib.optionalString discordEnabled ''
|
||||||
|
|
||||||
[templates.dank-discord]
|
[templates.dank-discord]
|
||||||
input_path = '${home}/.config/matugen/templates/dank-discord.css'
|
input_path = '${home}/.config/matugen/templates/dank-discord.css'
|
||||||
output_path = '${home}/.config/vesktop/themes/dank-discord.css'
|
output_path = '${home}/.config/vesktop/themes/dank-discord.css'
|
||||||
''
|
''
|
||||||
+ lib.optionalString (obsidianSnippetDirs != []) (
|
+ lib.optionalString (obsidianSnippetDirs != []) (
|
||||||
lib.concatStringsSep "\n" (
|
lib.concatStringsSep "\n" (
|
||||||
lib.lists.imap0 (i: snippetDir: ''
|
lib.lists.imap0 (i: snippetDir: ''
|
||||||
@@ -576,6 +612,10 @@ in {
|
|||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
home.activation.dmsEnsureMatugenOutputDirs = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
|
${ensureMatugenOutputDirsScript}
|
||||||
|
'';
|
||||||
|
|
||||||
# Obsidian snippet dirs for matugen: mkdir here instead of tmpfiles (no chmod fights on weird mounts).
|
# Obsidian snippet dirs for matugen: mkdir here instead of tmpfiles (no chmod fights on weird mounts).
|
||||||
home.activation.dmsEnsureObsidianSnippetDirs = lib.hm.dag.entryAfter ["writeBoundary"] (
|
home.activation.dmsEnsureObsidianSnippetDirs = lib.hm.dag.entryAfter ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
@@ -1107,14 +1147,8 @@ in {
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
(lib.mkIf (lib.attrByPath [ "chiasson" "home" "shell" "ohMyPosh" "enable" ] false config) {
|
(lib.mkIf ohMyPoshEnabled {
|
||||||
# Matugen overwrites this at runtime; seed a stock theme so `oh-my-posh init fish` works before DMS runs matugen.
|
# Same path as matugen `[templates.ohmyposh]`; seeded as a real file by `ensureMatugenOutputDirsScript`.
|
||||||
xdg.configFile."oh-my-posh/theme.omp.json".source =
|
|
||||||
let
|
|
||||||
ompTheme = config.chiasson.home.shell.ohMyPosh.builtinTheme or "jandedobbeleer";
|
|
||||||
in
|
|
||||||
"${config.programs.oh-my-posh.package}/themes/${ompTheme}.omp.json";
|
|
||||||
# Same path as matugen `[templates.ohmyposh]` output in `programs.dank-material-shell` config.
|
|
||||||
programs.oh-my-posh = {
|
programs.oh-my-posh = {
|
||||||
useTheme = lib.mkForce null;
|
useTheme = lib.mkForce null;
|
||||||
configFile = lib.mkForce "${config.xdg.configHome}/oh-my-posh/theme.omp.json";
|
configFile = lib.mkForce "${config.xdg.configHome}/oh-my-posh/theme.omp.json";
|
||||||
|
|||||||
Reference in New Issue
Block a user