mirror of
https://github.com/nix-community/plasma-manager.git
synced 2025-01-05 21:46:53 +03:00
module: add options for configs in HOME, XDG_CONFIG_HOME, XDG_DATA_HOME
This commit is contained in:
parent
16c437e43a
commit
b6241a2f7c
@ -44,7 +44,7 @@ Configuration is broken down into three layers:
|
||||
```nix
|
||||
{
|
||||
programs.plasma = {
|
||||
files."baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
|
||||
configFile."baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
@ -27,6 +27,6 @@
|
||||
};
|
||||
|
||||
# A low-level setting:
|
||||
files."baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
|
||||
configFile."baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
|
||||
};
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ let
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||
(key: value: ''
|
||||
${pkgs.libsForQt5.kconfig}/bin/kwriteconfig5 \
|
||||
--file ''${XDG_CONFIG_HOME:-$HOME/.config}/${lib.escapeShellArg file} \
|
||||
--file ${lib.escapeShellArg file} \
|
||||
${lib.concatMapStringsSep " " (g: "--group " + lib.escapeShellArg g) groups} \
|
||||
--key ${lib.escapeShellArg key} \
|
||||
${toKdeValue value}
|
||||
|
@ -5,7 +5,16 @@ let
|
||||
inherit (import ../lib/kwriteconfig.nix { inherit lib pkgs; })
|
||||
kWriteConfig;
|
||||
|
||||
cfg = config.programs.plasma.files;
|
||||
# Helper function to prepend the appropriate path prefix (e.g. XDG_CONFIG_HOME) to file
|
||||
prependPath = prefix: attrset:
|
||||
lib.attrsets.mapAttrs'
|
||||
(path: config: { name = "${prefix}/${path}"; value = config; })
|
||||
attrset;
|
||||
plasmaCfg = config.programs.plasma;
|
||||
cfg =
|
||||
(prependPath config.home.homeDirectory plasmaCfg.file) //
|
||||
(prependPath config.xdg.configHome plasmaCfg.configFile) //
|
||||
(prependPath config.xdg.dataHome plasmaCfg.dataFile);
|
||||
|
||||
##############################################################################
|
||||
# A module for storing settings.
|
||||
@ -41,16 +50,40 @@ let
|
||||
cfg));
|
||||
in
|
||||
{
|
||||
options.programs.plasma.files = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf (submodule settingType));
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set where the keys are file names (relative to
|
||||
XDG_CONFIG_HOME) and the values are attribute sets that
|
||||
represent configuration groups and settings inside those groups.
|
||||
'';
|
||||
options.programs.plasma = {
|
||||
file = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf (submodule settingType));
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set where the keys are file names (relative to
|
||||
HOME) and the values are attribute sets that represent
|
||||
configuration groups and settings inside those groups.
|
||||
'';
|
||||
};
|
||||
configFile = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf (submodule settingType));
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set where the keys are file names (relative to
|
||||
XDG_CONFIG_HOME) and the values are attribute sets that
|
||||
represent configuration groups and settings inside those groups.
|
||||
'';
|
||||
};
|
||||
dataFile = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf (submodule settingType));
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set where the keys are file names (relative to
|
||||
XDG_DATA_HOME) and the values are attribute sets that
|
||||
represent configuration groups and settings inside those groups.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule [ "programs" "plasma" "files" ] [ "programs" "plasma" "configFile" ])
|
||||
];
|
||||
|
||||
config = lib.mkIf (builtins.length (builtins.attrNames cfg) > 0) {
|
||||
home.activation.configure-plasma = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$DRY_RUN_CMD ${script}
|
||||
|
@ -105,6 +105,6 @@ in
|
||||
config = lib.mkIf
|
||||
(cfg.enable && builtins.length (builtins.attrNames cfg.hotkeys.commands) != 0)
|
||||
{
|
||||
programs.plasma.files.khotkeysrc = hotkeys;
|
||||
programs.plasma.configFile.khotkeysrc = hotkeys;
|
||||
};
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.enable && builtins.attrNames cfg.shortcuts != 0) {
|
||||
programs.plasma.files."kglobalshortcutsrc" =
|
||||
programs.plasma.configFile."kglobalshortcutsrc" =
|
||||
shortcutsToSettings cfg.shortcuts;
|
||||
};
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.plasma.files = {
|
||||
programs.plasma.configFile = {
|
||||
kdeglobals = {
|
||||
General.AllowKDEAppsToRememberWindowPositions =
|
||||
lib.mkDefault cfg.windows.allowWindowsToRememberPositions;
|
||||
|
@ -16,7 +16,7 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.plasma.files.kdeglobals = {
|
||||
programs.plasma.configFile.kdeglobals = {
|
||||
KDE.SingleClick = lib.mkDefault (cfg.workspace.clickItemTo == "open");
|
||||
};
|
||||
};
|
||||
|
@ -189,7 +189,7 @@ module Rc2Nix
|
||||
puts(" shortcuts = {")
|
||||
pp_shortcuts(settings["kglobalshortcutsrc"], 6)
|
||||
puts(" };")
|
||||
puts(" files = {")
|
||||
puts(" configFile = {")
|
||||
pp_settings(settings, 6)
|
||||
puts(" };")
|
||||
puts(" };")
|
||||
|
Loading…
Reference in New Issue
Block a user