2024-03-27 15:42:15 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
2024-03-27 11:20:22 +03:00
|
|
|
let
|
2024-03-27 15:42:15 +03:00
|
|
|
inherit (import ../../lib/types.nix { inherit lib; }) basicSettingsType;
|
|
|
|
|
2024-03-27 11:20:22 +03:00
|
|
|
cfg = config.programs.konsole;
|
|
|
|
profilesSubmodule = {
|
|
|
|
options = {
|
2024-03-27 15:42:15 +03:00
|
|
|
name = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
2024-03-27 11:20:22 +03:00
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Name of the profile. Defaults to the attribute name.
|
|
|
|
'';
|
|
|
|
};
|
2024-03-27 15:42:15 +03:00
|
|
|
colorScheme = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
|
|
|
default = null;
|
2024-03-27 11:20:22 +03:00
|
|
|
example = "Catppuccin-Mocha";
|
|
|
|
description = ''
|
|
|
|
Color scheme the profile will use. You can check the files you can
|
|
|
|
use in ~/.local/share/konsole or /run/current-system/share/konsole
|
|
|
|
'';
|
|
|
|
};
|
2024-03-27 15:42:15 +03:00
|
|
|
command = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
|
|
|
default = null;
|
2024-03-27 11:20:22 +03:00
|
|
|
example = "''${pkgs.zsh}/bin/zsh";
|
|
|
|
description = ''
|
|
|
|
The command to run on new sessions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
font = {
|
2024-03-27 15:42:15 +03:00
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-03-27 11:20:22 +03:00
|
|
|
/*
|
|
|
|
TODO: Set default to null after adding an assertion
|
|
|
|
Konsole needs to have a font set to be able to change font size
|
|
|
|
Since I couldn't get that to work I'll just set a default font
|
|
|
|
Not ideal since IMO we should only write things that are set explicitly
|
|
|
|
by the user but ehh it is what it is
|
|
|
|
*/
|
|
|
|
default = "Hack";
|
|
|
|
example = "Hack";
|
|
|
|
description = ''
|
|
|
|
Name of the font the profile should use.
|
|
|
|
'';
|
|
|
|
};
|
2024-03-27 15:42:15 +03:00
|
|
|
size = lib.mkOption {
|
2024-03-27 11:20:22 +03:00
|
|
|
# The konsole ui gives you a limited range
|
2024-03-27 15:42:15 +03:00
|
|
|
type = (lib.types.ints.between 4 128);
|
2024-03-27 11:20:22 +03:00
|
|
|
default = 10;
|
|
|
|
example = 12;
|
|
|
|
description = ''
|
|
|
|
Size of the font.
|
|
|
|
Needs a font to be set due to konsole limitations.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2024-05-25 21:05:01 +03:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf (attrsOf basicSettingsType);
|
|
|
|
default = { };
|
|
|
|
example = { };
|
|
|
|
description = ''
|
|
|
|
Extra keys to manually add to the profile.
|
|
|
|
'';
|
|
|
|
};
|
2024-03-27 11:20:22 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.programs.konsole = {
|
2024-03-27 15:42:15 +03:00
|
|
|
enable = lib.mkEnableOption ''
|
2024-03-27 11:20:22 +03:00
|
|
|
Enable configuration management for Konsole.
|
|
|
|
'';
|
2024-03-27 15:42:15 +03:00
|
|
|
|
|
|
|
defaultProfile = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
2024-03-27 11:20:22 +03:00
|
|
|
default = null;
|
|
|
|
example = "Catppuccin";
|
|
|
|
description = ''
|
|
|
|
The name of the konsole profile file to use by default.
|
|
|
|
To see what options you have, just take a look at ~/.local/share/konsole/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-03-27 15:42:15 +03:00
|
|
|
profiles = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr (attrsOf (submodule profilesSubmodule));
|
|
|
|
default = { };
|
2024-03-27 11:20:22 +03:00
|
|
|
description = ''
|
|
|
|
Plasma profiles to generate.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-03-27 15:42:15 +03:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr (attrsOf (attrsOf (basicSettingsType)));
|
2024-03-27 11:20:22 +03:00
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Extra config to add to konsolerc.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-27 15:42:15 +03:00
|
|
|
config = lib.mkIf (cfg.enable) {
|
|
|
|
programs.plasma.configFile."konsolerc" = lib.mkMerge [
|
2024-03-27 11:20:22 +03:00
|
|
|
(
|
2024-03-27 15:42:15 +03:00
|
|
|
lib.mkIf (cfg.defaultProfile != null) {
|
2024-04-29 23:45:10 +03:00
|
|
|
"Desktop Entry"."DefaultProfile" = "${cfg.defaultProfile}.profile";
|
2024-03-27 11:20:22 +03:00
|
|
|
}
|
|
|
|
)
|
|
|
|
(
|
2024-03-27 15:42:15 +03:00
|
|
|
lib.mkIf (cfg.extraConfig != null) (lib.mapAttrs
|
|
|
|
(groupName: groupAttrs:
|
|
|
|
(lib.mapAttrs (keyName: keyAttrs: { value = keyAttrs; }) groupAttrs))
|
|
|
|
cfg.extraConfig)
|
2024-03-27 11:20:22 +03:00
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2024-03-27 15:42:15 +03:00
|
|
|
xdg.dataFile = lib.mkIf (cfg.profiles != { })
|
|
|
|
(
|
|
|
|
lib.mkMerge ([
|
|
|
|
(
|
|
|
|
lib.mkMerge (
|
|
|
|
lib.mapAttrsToList
|
|
|
|
(
|
|
|
|
attrName: profile:
|
|
|
|
let
|
|
|
|
# Use the name from the name option if it's set
|
|
|
|
profileName = if builtins.isString profile.name then profile.name else attrName;
|
|
|
|
fontString = lib.mkIf (profile.font.name != null) "${profile.font.name},${builtins.toString profile.font.size}";
|
|
|
|
in
|
|
|
|
{
|
2024-05-25 21:05:01 +03:00
|
|
|
"konsole/${profileName}.profile".text = lib.generators.toINI { }
|
|
|
|
(lib.recursiveUpdate
|
2024-03-27 15:42:15 +03:00
|
|
|
{
|
2024-05-25 21:05:01 +03:00
|
|
|
"General" = (
|
|
|
|
{
|
|
|
|
"Name" = profileName;
|
|
|
|
# Konsole generated profiles seem to always have this
|
|
|
|
"Parent" = "FALLBACK/";
|
|
|
|
} //
|
|
|
|
(lib.optionalAttrs (profile.command != null) { "Command" = profile.command; })
|
|
|
|
);
|
|
|
|
"Appearance" = (
|
|
|
|
{
|
|
|
|
# If the font size is not set we leave a comma a the end after the name
|
|
|
|
# We should fix this probs but konsole doesn't seem to care ¯\_(ツ)_/¯
|
|
|
|
"Font" = fontString.content;
|
|
|
|
} //
|
|
|
|
(lib.optionalAttrs (profile.colorScheme != null) { "ColorScheme" = profile.colorScheme; })
|
|
|
|
);
|
|
|
|
}
|
|
|
|
profile.extraConfig
|
2024-03-27 15:42:15 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
cfg.profiles
|
|
|
|
)
|
2024-03-27 11:20:22 +03:00
|
|
|
)
|
2024-03-27 15:42:15 +03:00
|
|
|
])
|
|
|
|
);
|
2024-03-27 11:20:22 +03:00
|
|
|
};
|
|
|
|
}
|