Skip to content

Commit

Permalink
pick kate package
Browse files Browse the repository at this point in the history
  • Loading branch information
blitter committed Mar 25, 2024
1 parent 2818d4b commit ccea903
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions modules/apps/kate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ in
Enable configuration management for kate.
'';

# ==================================
# INDENTATION
package = lib.mkPackageOption pkgs "kate" {
default = [ "kate" ];
example = "pkgs.libsForQt5.kate";
};

# ==================================
# INDENTATION
editor = {
tabWidth = lib.mkOption {
description = "The width of a single tab (''\t) sign (in number of spaces).";
Expand Down Expand Up @@ -84,10 +89,6 @@ in
assertion = cfg.editor.indent.undoByShiftTab || (!cfg.editor.indent.tabFromEverywhere);
message = "Kate does not support both 'undoByShiftTab' to be disabled and 'tabFromEverywhere' to be enabled at the same time.";
}
{
assertion = (! cfg.enable) || (builtins.elem pkgs.libsForQt5.kate config.home.packages);
message = "Kate cannot be managed with plasma-manager if it is not installed. Either install kate or disable `config.programs.kate.enabled";
}
];

config.programs.plasma.configFile."katerc" = lib.mkIf cfg.enable {
Expand Down Expand Up @@ -131,22 +132,27 @@ in
};

config.programs.kate.editor.theme = {
name = lib.mkIf (null != cfg.editor.theme.src) (lib.mkForce (builtins.fromJSON (builtins.readFile cfg.editor.theme.src))."metadata"."name");
name = lib.mkIf (cfg.enable && null != cfg.editor.theme.src) (lib.mkForce (builtins.fromJSON (builtins.readFile cfg.editor.theme.src))."metadata"."name");
# kate's naming scheme is ${themename}.theme
# which is why we use the same naming scheme here
};

# This won't override existing files since the home-manager activation fails in that case
config.xdg.dataFile."${cfg.editor.theme.name}.theme" = lib.mkIf (null != cfg.editor.theme.src)
config.xdg.dataFile."${cfg.editor.theme.name}.theme" = lib.mkIf (cfg.enable && null != cfg.editor.theme.src)
{
source = cfg.editor.theme.src;
target = "org.kde.syntax-highlighting/themes/${cfg.editor.theme.name}.theme";
};

config = {
home.activation.checkKateTheme = lib.mkIf (cfg.enable && config.programs.kate.editor.theme.src != null) (lib.hm.dag.entryBefore [ "writeBoundary" ]
home.packages = lib.mkIf (cfg.enable && cfg.package != null) [ cfg.package ];

# In case of using a custom theme, check that there is no name collision
home.activation.checkKateTheme = lib.mkIf (cfg.enable && cfg.editor.theme.src != null) (lib.hm.dag.entryBefore [ "writeBoundary" ]
''
$DRY_RUN_CMD ${./check-theme-name-free.sh} ${cfg.editor.theme.name} ${pkgs.jq}/bin/jq
${./check-theme-name-free.sh} ${cfg.editor.theme.name} ${pkgs.jq}/bin/jq
'');

# In case of using a system theme, there should be a check that there exists such a theme
};
}

0 comments on commit ccea903

Please sign in to comment.