1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00
Files
DankMaterialShell/distro/nix/home.nix
Ethan Todd 2e1bed5fb5 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.
2026-01-04 11:18:28 -03:00

124 lines
3.8 KiB
Nix

{
config,
pkgs,
lib,
dmsPkgs,
...
}@args:
let
cfg = config.programs.dank-material-shell;
jsonFormat = pkgs.formats.json { };
common = import ./common.nix {
inherit
config
pkgs
lib
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
{
imports = [
(import ./options.nix args)
(lib.mkRemovedOptionModule [
"programs"
"dank-material-shell"
"enableNightMode"
] "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
[ "programs" "dank-material-shell" "enableSystemd" ]
[ "programs" "dank-material-shell" "systemd" "enable" ]
)
];
options.programs.dank-material-shell = {
settings = lib.mkOption {
type = jsonFormat.type;
default = { };
description = "DankMaterialShell configuration settings as an attribute set, to be written to ~/.config/DankMaterialShell/settings.json.";
};
clipboardSettings = lib.mkOption {
type = jsonFormat.type;
default = { };
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.'';
};
};
config = lib.mkIf cfg.enable {
programs.quickshell = {
enable = true;
inherit (cfg.quickshell) package;
};
systemd.user.services.dms = lib.mkIf cfg.systemd.enable {
Unit = {
Description = "DankMaterialShell";
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
};
Service = {
ExecStart = lib.getExe dmsPkgs.dms-shell + " run --session";
Restart = "on-failure";
};
Install.WantedBy = [ config.wayland.systemd.target ];
};
xdg.stateFile."DankMaterialShell/session.json" = lib.mkIf (cfg.session != { }) {
source = jsonFormat.generate "session.json" cfg.session;
};
xdg.configFile = {
"DankMaterialShell/settings.json" = lib.mkIf (cfg.settings != { }) {
source = jsonFormat.generate "settings.json" cfg.settings;
};
"DankMaterialShell/clsettings.json" = lib.mkIf (cfg.clipboardSettings != { }) {
source = jsonFormat.generate "clsettings.json" cfg.clipboardSettings;
};
"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;
};
}