Refactor DMS configuration and introduce home-manager integration
- Simplified `default.nix` by removing legacy home-manager settings and delegating them to a new `_private/hm.nix` module for better organization. - Added a new script `dms-restart-once.sh` to handle service restarts and cache management for DMS plugins. - Updated the DMS configuration to streamline the integration of third-party plugins and improve overall modularity.
This commit is contained in:
@@ -207,7 +207,7 @@
|
|||||||
lib = inputs.nixpkgs.lib;
|
lib = inputs.nixpkgs.lib;
|
||||||
# import-tree default: only .nix, skip paths with /_/ (see
|
# import-tree default: only .nix, skip paths with /_/ (see
|
||||||
# https://import-tree.oeiuwq.com/guides/filtering/ ). filterNot composes AND with that.
|
# https://import-tree.oeiuwq.com/guides/filtering/ ). filterNot composes AND with that.
|
||||||
# Skip /package/, /packages/, and dms/home-manager/ (callPackage + DMS HM colocation).
|
# Skip /package/ and /packages/ (callPackage colocation).
|
||||||
# Avoid a global "/home-manager/" filter — it would drop modules/ssh/home-manager/.
|
# Avoid a global "/home-manager/" filter — it would drop modules/ssh/home-manager/.
|
||||||
modulesTree =
|
modulesTree =
|
||||||
lib.pipe inputs.import-tree [
|
lib.pipe inputs.import-tree [
|
||||||
@@ -217,7 +217,6 @@
|
|||||||
p:
|
p:
|
||||||
lib.hasInfix "/package/" p
|
lib.hasInfix "/package/" p
|
||||||
|| lib.hasInfix "/packages/" p
|
|| lib.hasInfix "/packages/" p
|
||||||
|| lib.hasInfix "dms/home-manager/" p
|
|
||||||
))
|
))
|
||||||
(it: it ./modules)
|
(it: it ./modules)
|
||||||
];
|
];
|
||||||
|
|||||||
+75
-91
@@ -1,3 +1,4 @@
|
|||||||
|
# Home Manager wiring for DMS (imported by default.nix; lives under _private/ for import-tree).
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
config,
|
config,
|
||||||
@@ -5,10 +6,17 @@
|
|||||||
lib,
|
lib,
|
||||||
osConfig ? { },
|
osConfig ? { },
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
home = config.home.homeDirectory;
|
home = config.home.homeDirectory;
|
||||||
dmsEnabled = lib.attrByPath [ "chiasson" "desktop" "shell" ] null osConfig == "dms";
|
dmsEnabled = lib.attrByPath [ "chiasson" "desktop" "shell" ] null osConfig == "dms";
|
||||||
dmsOs = lib.attrByPath [ "chiasson" "desktop" "shells" "dms" ] { } osConfig;
|
dmsOs = lib.attrByPath [ "chiasson" "desktop" "shells" "dms" ] { } osConfig;
|
||||||
|
hostName = lib.attrByPath [ "networking" "hostName" ] "nixos" osConfig;
|
||||||
|
rebuildCommand =
|
||||||
|
if (dmsOs.rebuildCommand or null) != null then
|
||||||
|
dmsOs.rebuildCommand
|
||||||
|
else
|
||||||
|
[ "sudo" "nixos-rebuild" "switch" "--flake" ".#${hostName}" ];
|
||||||
gpuTempEnabled = dmsOs.enableGpuTemp or true;
|
gpuTempEnabled = dmsOs.enableGpuTemp or true;
|
||||||
hyprlandEnabled = lib.attrByPath [ "chiasson" "desktop" "hyprland" "enable" ] false osConfig;
|
hyprlandEnabled = lib.attrByPath [ "chiasson" "desktop" "hyprland" "enable" ] false osConfig;
|
||||||
discordEnabled = lib.attrByPath [ "chiasson" "home" "apps" "discord" "enable" ] false config;
|
discordEnabled = lib.attrByPath [ "chiasson" "home" "apps" "discord" "enable" ] false config;
|
||||||
@@ -57,12 +65,12 @@
|
|||||||
"${pkgs.util-linux}/bin/flock"
|
"${pkgs.util-linux}/bin/flock"
|
||||||
"${pkgs.systemd}/bin/systemctl"
|
"${pkgs.systemd}/bin/systemctl"
|
||||||
]
|
]
|
||||||
(builtins.readFile ./scripts/dms-restart-once.sh)
|
(builtins.readFile ../scripts/dms-restart-once.sh)
|
||||||
);
|
);
|
||||||
|
|
||||||
jsonFormat = pkgs.formats.json { };
|
jsonFormat = pkgs.formats.json { };
|
||||||
dmsConfigDir = "${config.xdg.configHome}/DankMaterialShell";
|
dmsConfigDir = "${config.xdg.configHome}/DankMaterialShell";
|
||||||
defaultSeedDir = lib.attrByPath [ "chiasson" "desktop" "shells" "dms" "defaultSeedDir" ] null osConfig;
|
defaultSeedDir = dmsOs.defaultSeedDir or null;
|
||||||
|
|
||||||
dmsSeedSources =
|
dmsSeedSources =
|
||||||
if defaultSeedDir != null then
|
if defaultSeedDir != null then
|
||||||
@@ -75,7 +83,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
"settings.json" = jsonFormat.generate "dms-settings-seed.json" (
|
"settings.json" = jsonFormat.generate "dms-settings-seed.json" (
|
||||||
import ../_private/default-settings.nix {
|
import ./default-settings.nix {
|
||||||
inherit lib gpuTempEnabled;
|
inherit lib gpuTempEnabled;
|
||||||
extraRightBarWidgets = dmsOs.extraRightBarWidgets or [ ];
|
extraRightBarWidgets = dmsOs.extraRightBarWidgets or [ ];
|
||||||
}
|
}
|
||||||
@@ -105,7 +113,7 @@
|
|||||||
${dmsSeedBody}
|
${dmsSeedBody}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
matugenConfigText = import ../_private/matugen-config.nix {
|
matugenConfigText = import ./matugen-config.nix {
|
||||||
inherit
|
inherit
|
||||||
lib
|
lib
|
||||||
home
|
home
|
||||||
@@ -116,7 +124,6 @@
|
|||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Directory name must match each plugin's `id` in plugin.json.
|
|
||||||
thirdPartyPlugins = {
|
thirdPartyPlugins = {
|
||||||
dankVault = inputs.dms-plugin-dank-vault;
|
dankVault = inputs.dms-plugin-dank-vault;
|
||||||
calculator = inputs.dms-plugin-calculator;
|
calculator = inputs.dms-plugin-calculator;
|
||||||
@@ -138,14 +145,14 @@
|
|||||||
rbwLockToggle = inputs.dms-plugin-rbw-lock-toggle;
|
rbwLockToggle = inputs.dms-plugin-rbw-lock-toggle;
|
||||||
};
|
};
|
||||||
|
|
||||||
shipThirdPartyPlugin =
|
shipPlugin =
|
||||||
id: src:
|
_id: src:
|
||||||
{
|
{
|
||||||
source = src;
|
source = src;
|
||||||
onChange = "${dmsRestartOnceScript}";
|
onChange = "${dmsRestartOnceScript}";
|
||||||
};
|
};
|
||||||
|
in
|
||||||
in {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.dms.homeModules.dank-material-shell
|
inputs.dms.homeModules.dank-material-shell
|
||||||
inputs.nix-monitor.homeManagerModules.default
|
inputs.nix-monitor.homeManagerModules.default
|
||||||
@@ -153,93 +160,70 @@ in {
|
|||||||
|
|
||||||
config = lib.mkIf dmsEnabled (lib.mkMerge [
|
config = lib.mkIf dmsEnabled (lib.mkMerge [
|
||||||
(lib.mkIf (dmsOs.bundleThirdPartyPlugins or true) {
|
(lib.mkIf (dmsOs.bundleThirdPartyPlugins or true) {
|
||||||
xdg.configFile =
|
xdg.configFile = lib.mapAttrs (_id: src: shipPlugin _id src) thirdPartyPlugins;
|
||||||
lib.mapAttrs (id: src: shipThirdPartyPlugin id src) thirdPartyPlugins;
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
programs.nix-monitor = {
|
||||||
|
enable = true;
|
||||||
|
inherit rebuildCommand;
|
||||||
|
generationsCommand = [
|
||||||
|
"bash"
|
||||||
|
"-c"
|
||||||
|
"readlink /nix/var/nix/profiles/system | cut -d- -f2"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Nix rebuild widget used by DankMaterialShell (via nix-monitor).
|
home.packages = with pkgs; [
|
||||||
# Per-host `rebuildCommand` is set in `modules/hosts/<host>/configuration.nix` (`chiasson.desktop.shells.dms`).
|
kdePackages.qtdeclarative
|
||||||
programs.nix-monitor = {
|
kdePackages.kirigami.unwrapped
|
||||||
enable = true;
|
kdePackages.qtmultimedia
|
||||||
generationsCommand = [
|
kdePackages.sonnet
|
||||||
"bash"
|
tesseract
|
||||||
"-c"
|
mpv
|
||||||
"readlink /nix/var/nix/profiles/system | cut -d- -f2"
|
socat
|
||||||
];
|
wl-clipboard
|
||||||
};
|
jq
|
||||||
|
cava
|
||||||
|
curl
|
||||||
|
libsecret
|
||||||
|
];
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
programs.dank-material-shell = {
|
||||||
kdePackages.qtdeclarative
|
enable = true;
|
||||||
kdePackages.kirigami.unwrapped
|
package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.dms-shell.override {
|
||||||
kdePackages.qtmultimedia
|
extraQtPackages = with pkgs.kdePackages; [ qtwebsockets ];
|
||||||
kdePackages.sonnet
|
};
|
||||||
# ocrScanner DMS plugin — eng/fra/vie and 120+ langs ship in nixpkgs tessdata.
|
systemd = {
|
||||||
tesseract
|
enable = true;
|
||||||
# ambientSound DMS plugin — mpv playback + socat IPC to mpv socket.
|
restartIfChanged = true;
|
||||||
mpv
|
};
|
||||||
socat
|
enableSystemMonitoring = true;
|
||||||
# dankVault / emojiLauncher / ephemera — Wayland clipboard.
|
dgop.package = inputs.dgop.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||||
wl-clipboard
|
enableVPN = true;
|
||||||
# nixPackageRunner DMS plugin.
|
enableDynamicTheming = true;
|
||||||
jq
|
enableAudioWavelength = true;
|
||||||
# cavaVisualizer DMS plugin.
|
enableCalendarEvents = false;
|
||||||
cava
|
settings = { };
|
||||||
# ephemera DMS plugin — API requests + optional keyring storage.
|
session = { };
|
||||||
curl
|
};
|
||||||
libsecret
|
|
||||||
];
|
|
||||||
programs.dank-material-shell = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
# homeAssistantMonitor plugin (QtWebSockets) needs QML on DMS's import path, not just home.packages.
|
home.activation.dmsSeedConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] "${dmsSeedConfigScript}";
|
||||||
package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.dms-shell.override {
|
|
||||||
extraQtPackages = with pkgs.kdePackages; [ qtwebsockets ];
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd = {
|
systemd.user.services.dms.serviceConfig.ExecStartPre =
|
||||||
enable = true; # Systemd service for auto-start
|
lib.mkOrder 100 "${ensureMatugenOutputDirsScript}";
|
||||||
restartIfChanged = true; # Auto-restart dms.service when dankMaterialShell changes
|
|
||||||
};
|
|
||||||
|
|
||||||
# Core features
|
xdg.configFile."matugen/config.toml".text = matugenConfigText;
|
||||||
enableSystemMonitoring = true; # System monitoring widgets (dgop)
|
xdg.configFile."matugen/templates/dank-discord.css".source = ../templates/dank-discord.css;
|
||||||
dgop.package = inputs.dgop.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
xdg.configFile."matugen/templates/hyprland-colors.conf".source = ../templates/hyprland-colors.conf;
|
||||||
enableVPN = true; # VPN management widget
|
xdg.configFile."matugen/templates/ohmyposh-theme.omp.json".source = ../templates/ohmyposh-theme.omp.json;
|
||||||
enableDynamicTheming = true; # Wallpaper-based theming (matugen)
|
xdg.configFile."matugen/templates/obsidian-minimal-matugen-colors.css".source =
|
||||||
enableAudioWavelength = true; # Audio visualizer (cava)
|
../templates/obsidian-minimal-matugen-colors.css;
|
||||||
enableCalendarEvents = false; # Disable calendar integration (khal/ikhal)
|
}
|
||||||
|
(lib.mkIf ohMyPoshEnabled {
|
||||||
# Leave `session` at {} — non-empty makes HM rewrite session.json every switch and nukes wallpaper/session state.
|
programs.oh-my-posh = {
|
||||||
# Leave `settings` at {} — UI-owned settings.json is seeded once on first run (see home.activation below).
|
useTheme = lib.mkForce null;
|
||||||
settings = { };
|
configFile = lib.mkForce "${config.xdg.configHome}/oh-my-posh/theme.omp.json";
|
||||||
session = { };
|
};
|
||||||
};
|
})
|
||||||
|
|
||||||
# Detach store symlinks so UI edits survive rebuilds; seed defaults only on a fresh profile.
|
|
||||||
home.activation.dmsSeedConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] "${dmsSeedConfigScript}";
|
|
||||||
|
|
||||||
# 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 docs (custom templates): https://danklinux.com/docs/dankmaterialshell/application-themes#custom-matugen-templates
|
|
||||||
xdg.configFile."matugen/config.toml".text = matugenConfigText;
|
|
||||||
|
|
||||||
xdg.configFile."matugen/templates/dank-discord.css".source = ../templates/dank-discord.css;
|
|
||||||
xdg.configFile."matugen/templates/hyprland-colors.conf".source = ../templates/hyprland-colors.conf;
|
|
||||||
xdg.configFile."matugen/templates/ohmyposh-theme.omp.json".source = ../templates/ohmyposh-theme.omp.json;
|
|
||||||
xdg.configFile."matugen/templates/obsidian-minimal-matugen-colors.css".source =
|
|
||||||
../templates/obsidian-minimal-matugen-colors.css;
|
|
||||||
}
|
|
||||||
(lib.mkIf ohMyPoshEnabled {
|
|
||||||
# Same path as matugen `[templates.ohmyposh]`; seeded as a real file by `ensureMatugenOutputDirsScript`.
|
|
||||||
programs.oh-my-posh = {
|
|
||||||
useTheme = lib.mkForce null;
|
|
||||||
configFile = lib.mkForce "${config.xdg.configHome}/oh-my-posh/theme.omp.json";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ inputs, ... }: {
|
{ ... }: {
|
||||||
flake.nixosModules.desktopShellDmsOptions = { lib, ... }: {
|
flake.nixosModules.desktopShellDmsOptions = { lib, ... }: {
|
||||||
options.chiasson.desktop.shells.dms = {
|
options.chiasson.desktop.shells.dms = {
|
||||||
enableGpuTemp = lib.mkOption {
|
enableGpuTemp = lib.mkOption {
|
||||||
@@ -45,29 +45,5 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.homeManagerModules.desktopShellDms = {
|
flake.homeManagerModules.desktopShellDms = import ./_private/hm.nix;
|
||||||
lib,
|
|
||||||
osConfig ? { },
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
cfg = lib.attrByPath [ "chiasson" "desktop" "shells" "dms" ] { } osConfig;
|
|
||||||
selectedShell = lib.attrByPath [ "chiasson" "desktop" "shell" ] null osConfig;
|
|
||||||
dmsEnabled = selectedShell == "dms";
|
|
||||||
hostName = lib.attrByPath [ "networking" "hostName" ] "nixos" osConfig;
|
|
||||||
rebuildCommand =
|
|
||||||
if (cfg.rebuildCommand or null) != null then
|
|
||||||
cfg.rebuildCommand
|
|
||||||
else
|
|
||||||
[ "sudo" "nixos-rebuild" "switch" "--flake" ".#${hostName}" ];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./home-manager/default.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf dmsEnabled {
|
|
||||||
programs.nix-monitor.rebuildCommand = rebuildCommand;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user