2022-09-29 13:08:53 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.oh-my-posh;
|
|
|
|
|
|
|
|
jsonFormat = pkgs.formats.json { };
|
|
|
|
|
|
|
|
configArgument = if cfg.settings != { } then
|
|
|
|
"--config ${config.xdg.configHome}/oh-my-posh/config.json"
|
|
|
|
else if cfg.useTheme != null then
|
|
|
|
"--config ${cfg.package}/share/oh-my-posh/themes/${cfg.useTheme}.omp.json"
|
|
|
|
else
|
|
|
|
"";
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.arjan-s ];
|
|
|
|
|
|
|
|
options.programs.oh-my-posh = {
|
2023-07-01 01:30:13 +02:00
|
|
|
enable = mkEnableOption
|
|
|
|
(lib.mdDoc "oh-my-posh, a prompt theme engine for any shell");
|
2022-09-29 13:08:53 +02:00
|
|
|
|
2023-07-01 11:41:32 +02:00
|
|
|
package = mkPackageOptionMD pkgs "oh-my-posh" { };
|
2022-09-29 13:08:53 +02:00
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = jsonFormat.type;
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile "''${pkgs.oh-my-posh}/share/oh-my-posh/themes/space.omp.json"))'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-09-29 13:08:53 +02:00
|
|
|
Configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/oh-my-posh/config.json`. See
|
|
|
|
<https://ohmyposh.dev/docs/configuration/overview>
|
|
|
|
for details. The `useTheme` option is ignored when this
|
2022-09-29 13:08:53 +02:00
|
|
|
option is used.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
useTheme = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-09-29 13:08:53 +02:00
|
|
|
Use one of the official themes. This should be a name from this list:
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://ohmyposh.dev/docs/themes>. Because a theme
|
2022-09-29 13:08:53 +02:00
|
|
|
is essentially a configuration file, this option is not used when a
|
2023-07-01 01:30:13 +02:00
|
|
|
`configFile` is set.
|
2022-09-29 13:08:53 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableBashIntegration = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-09-29 13:08:53 +02:00
|
|
|
Whether to enable Bash integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableZshIntegration = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-09-29 13:08:53 +02:00
|
|
|
Whether to enable Zsh integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableFishIntegration = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-09-29 13:08:53 +02:00
|
|
|
Whether to enable Fish integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."oh-my-posh/config.json" = mkIf (cfg.settings != { }) {
|
|
|
|
source = jsonFormat.generate "oh-my-posh-settings" cfg.settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
|
|
eval "$(${cfg.package}/bin/oh-my-posh init bash ${configArgument})"
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
|
|
eval "$(${cfg.package}/bin/oh-my-posh init zsh ${configArgument})"
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
|
|
|
|
${cfg.package}/bin/oh-my-posh init fish ${configArgument} | source
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|