-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ 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 = { | ||
enable = mkEnableOption "oh-my-posh, a prompt theme engine for any shell"; | ||
|
||
package = mkPackageOption pkgs "oh-my-posh" { }; | ||
|
||
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"))''; | ||
description = '' | ||
Configuration written to | ||
<filename>$XDG_CONFIG_HOME/oh-my-posh/config.json</filename>. See | ||
<link xlink:href="https://ohmyposh.dev/docs/configuration/overview"/> | ||
for details. The <literal>useTheme</literal> option is ignored when this | ||
option is used. | ||
''; | ||
}; | ||
|
||
useTheme = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
description = '' | ||
Use one of the official themes. This should be a name from this list: | ||
<link xlink:href="https://ohmyposh.dev/docs/themes"/>. Because a theme | ||
is essentially a configuration file, this option is not used when a | ||
<literal>configFile</literal> is set. | ||
''; | ||
}; | ||
|
||
enableBashIntegration = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether to enable Bash integration. | ||
''; | ||
}; | ||
|
||
enableZshIntegration = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether to enable Zsh integration. | ||
''; | ||
}; | ||
|
||
enableFishIntegration = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = '' | ||
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 | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ ... }: | ||
|
||
{ | ||
programs = { | ||
bash.enable = true; | ||
|
||
oh-my-posh = { | ||
enable = true; | ||
useTheme = "jandedobbeleer"; | ||
}; | ||
}; | ||
|
||
test.stubs.oh-my-posh = { }; | ||
|
||
nmt.script = '' | ||
assertFileExists home-files/.bashrc | ||
assertFileContains \ | ||
home-files/.bashrc \ | ||
'/bin/oh-my-posh init bash --config' | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
oh-my-posh-bash = ./bash.nix; | ||
oh-my-posh-zsh = ./zsh.nix; | ||
oh-my-posh-fish = ./fish.nix; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ lib, ... }: | ||
|
||
{ | ||
programs = { | ||
fish.enable = true; | ||
|
||
oh-my-posh = { | ||
enable = true; | ||
useTheme = "jandedobbeleer"; | ||
}; | ||
}; | ||
|
||
# Needed to avoid error with dummy fish package. | ||
xdg.dataFile."fish/home-manager_generated_completions".source = | ||
lib.mkForce (builtins.toFile "empty" ""); | ||
|
||
test.stubs = { | ||
oh-my-posh = { }; | ||
fish = { }; | ||
}; | ||
|
||
nmt.script = '' | ||
assertFileExists home-files/.config/fish/config.fish | ||
assertFileContains \ | ||
home-files/.config/fish/config.fish \ | ||
'/bin/oh-my-posh init fish --config' | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ ... }: | ||
|
||
{ | ||
programs = { | ||
zsh.enable = true; | ||
|
||
oh-my-posh = { | ||
enable = true; | ||
useTheme = "jandedobbeleer"; | ||
}; | ||
}; | ||
|
||
test.stubs = { | ||
oh-my-posh = { }; | ||
zsh = { }; | ||
}; | ||
|
||
nmt.script = '' | ||
assertFileExists home-files/.zshrc | ||
assertFileContains \ | ||
home-files/.zshrc \ | ||
'/bin/oh-my-posh init zsh --config' | ||
''; | ||
} |