diff --git a/README.md b/README.md index a5310648..98742eb8 100644 --- a/README.md +++ b/README.md @@ -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; }; } ``` diff --git a/example/home.nix b/example/home.nix index 4efaf144..4cad35c0 100644 --- a/example/home.nix +++ b/example/home.nix @@ -27,6 +27,6 @@ }; # A low-level setting: - files."baloofilerc"."Basic Settings"."Indexing-Enabled" = false; + configFile."baloofilerc"."Basic Settings"."Indexing-Enabled" = false; }; } diff --git a/lib/kwriteconfig.nix b/lib/kwriteconfig.nix index 1c3775be..712725f8 100644 --- a/lib/kwriteconfig.nix +++ b/lib/kwriteconfig.nix @@ -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} diff --git a/modules/files.nix b/modules/files.nix index 1070117b..d51bb68b 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -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} diff --git a/modules/hotkeys.nix b/modules/hotkeys.nix index a9da86f8..ead36745 100644 --- a/modules/hotkeys.nix +++ b/modules/hotkeys.nix @@ -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; }; } diff --git a/modules/shortcuts.nix b/modules/shortcuts.nix index 1d89624c..96fe35b8 100644 --- a/modules/shortcuts.nix +++ b/modules/shortcuts.nix @@ -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; }; } diff --git a/modules/windows.nix b/modules/windows.nix index cbde5b19..e4a53462 100644 --- a/modules/windows.nix +++ b/modules/windows.nix @@ -17,7 +17,7 @@ in }; config = lib.mkIf cfg.enable { - programs.plasma.files = { + programs.plasma.configFile = { kdeglobals = { General.AllowKDEAppsToRememberWindowPositions = lib.mkDefault cfg.windows.allowWindowsToRememberPositions; diff --git a/modules/workspace.nix b/modules/workspace.nix index 340bc8aa..fc356cd7 100644 --- a/modules/workspace.nix +++ b/modules/workspace.nix @@ -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"); }; }; diff --git a/script/rc2nix.rb b/script/rc2nix.rb index 4fc42b44..22d015b4 100755 --- a/script/rc2nix.rb +++ b/script/rc2nix.rb @@ -189,7 +189,7 @@ def run puts(" shortcuts = {") pp_shortcuts(settings["kglobalshortcutsrc"], 6) puts(" };") - puts(" files = {") + puts(" configFile = {") pp_settings(settings, 6) puts(" };") puts(" };")