1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

nix: update home-manager module to remove default*, add clsettings (#1233)

* nix: update home-manager module, add clsettings

* nix: resolve message and rename clsettings->clipboardSettings.

* nix: fix home-manager plugin_settings management. add option for whether plugin settings should be managed by nix.
This commit is contained in:
Ethan Todd
2026-01-04 09:18:28 -05:00
committed by GitHub
parent f163b97c17
commit 2e1bed5fb5
2 changed files with 69 additions and 29 deletions

View File

@@ -16,6 +16,12 @@ let
dmsPkgs dmsPkgs
; ;
}; };
hasPluginSettings = lib.any (plugin: plugin.settings != { }) (
lib.attrValues (lib.filterAttrs (n: v: v.enable) cfg.plugins)
);
pluginSettings = lib.mapAttrs (name: plugin: { enabled = plugin.enable; } // plugin.settings) (
lib.filterAttrs (n: v: v.enable) cfg.plugins
);
in in
{ {
imports = [ imports = [
@@ -24,25 +30,48 @@ in
"programs" "programs"
"dank-material-shell" "dank-material-shell"
"enableNightMode" "enableNightMode"
] "Night mode is now always available.") ] "Night mode is now always available")
(lib.mkRemovedOptionModule [
"programs"
"dank-material-shell"
"default"
"settings"
] "Default settings have been removed and been replaced with programs.dank-material-shell.settings")
(lib.mkRemovedOptionModule [
"programs"
"dank-material-shell"
"default"
"session"
] "Default session has been removed and been replaced with programs.dank-material-shell.session")
(lib.mkRenamedOptionModule (lib.mkRenamedOptionModule
[ "programs" "dank-material-shell" "enableSystemd" ] [ "programs" "dank-material-shell" "enableSystemd" ]
[ "programs" "dank-material-shell" "systemd" "enable" ] [ "programs" "dank-material-shell" "systemd" "enable" ]
) )
]; ];
options.programs.dank-material-shell = with lib.types; { options.programs.dank-material-shell = {
default = { settings = lib.mkOption {
settings = lib.mkOption { type = jsonFormat.type;
type = jsonFormat.type; default = { };
default = { }; description = "DankMaterialShell configuration settings as an attribute set, to be written to ~/.config/DankMaterialShell/settings.json.";
description = "The default settings are only read if the settings.json file don't exist"; };
};
session = lib.mkOption { clipboardSettings = lib.mkOption {
type = jsonFormat.type; type = jsonFormat.type;
default = { }; default = { };
description = "The default session are only read if the session.json file don't exist"; description = "DankMaterialShell clipboard settings as an attribute set, to be written to ~/.config/DankMaterialShell/clsettings.json.";
}; };
session = lib.mkOption {
type = jsonFormat.type;
default = { };
description = "DankMaterialShell session settings as an attribute set, to be written to ~/.local/state/DankMaterialShell/session.json.";
};
managePluginSettings = lib.mkOption {
type = lib.types.bool;
default = hasPluginSettings;
description = ''Whether to manage plugin settings. Automatically enabled if any plugins have settings configured.'';
}; };
}; };
@@ -67,22 +96,28 @@ in
Install.WantedBy = [ config.wayland.systemd.target ]; Install.WantedBy = [ config.wayland.systemd.target ];
}; };
xdg.stateFile."DankMaterialShell/default-session.json" = lib.mkIf (cfg.default.session != { }) { xdg.stateFile."DankMaterialShell/session.json" = lib.mkIf (cfg.session != { }) {
source = jsonFormat.generate "default-session.json" cfg.default.session; source = jsonFormat.generate "session.json" cfg.session;
}; };
xdg.configFile = lib.mkMerge [ xdg.configFile = {
(lib.mapAttrs' (name: value: { "DankMaterialShell/settings.json" = lib.mkIf (cfg.settings != { }) {
name = "DankMaterialShell/plugins/${name}"; source = jsonFormat.generate "settings.json" cfg.settings;
inherit value; };
}) common.plugins) "DankMaterialShell/clsettings.json" = lib.mkIf (cfg.clipboardSettings != { }) {
{ source = jsonFormat.generate "clsettings.json" cfg.clipboardSettings;
"DankMaterialShell/default-settings.json" = lib.mkIf (cfg.default.settings != { }) { };
source = jsonFormat.generate "default-settings.json" cfg.default.settings; "DankMaterialShell/plugin_settings.json" = lib.mkIf cfg.managePluginSettings {
}; source = jsonFormat.generate "plugin_settings.json" pluginSettings;
} };
]; }
// (lib.mapAttrs' (name: value: {
name = "DankMaterialShell/plugins/${name}";
inherit value;
}) common.plugins);
warnings =
lib.optional (!cfg.managePluginSettings && hasPluginSettings)
"You have disabled managePluginSettings but provided plugin settings. These settings will be ignored.";
home.packages = common.packages; home.packages = common.packages;
}; };
} }

View File

@@ -10,7 +10,7 @@ let
"programs" "programs"
"dank-material-shell" "dank-material-shell"
]; ];
jsonFormat = pkgs.formats.json { };
builtInRemovedMsg = "This is now built-in in DMS and doesn't need additional dependencies."; builtInRemovedMsg = "This is now built-in in DMS and doesn't need additional dependencies.";
in in
{ {
@@ -37,7 +37,7 @@ in
}; };
dgop = { dgop = {
package = lib.mkPackageOption pkgs "dgop" {}; package = lib.mkPackageOption pkgs "dgop" { };
}; };
enableSystemMonitoring = lib.mkOption { enableSystemMonitoring = lib.mkOption {
@@ -89,6 +89,11 @@ in
type = types.either types.package types.path; type = types.either types.package types.path;
description = "Source of the plugin package or path"; description = "Source of the plugin package or path";
}; };
settings = lib.mkOption {
type = jsonFormat.type;
default = { };
description = "Plugin settings as an attribute set";
};
}; };
} }
); );