diff options
author | Masanori Ogino <167209+omasanori@users.noreply.github.com> | 2022-12-26 13:59:20 +0900 |
---|---|---|
committer | Masanori Ogino <167209+omasanori@users.noreply.github.com> | 2022-12-27 03:06:29 +0900 |
commit | 93224c214eb3340e2c7c9cb9f063c2220cd9ab74 (patch) | |
tree | a02396ff12e4642689fec67113d40df5819f6f10 /nixos/modules/programs | |
parent | 710d6ce361dacb962f132da67d4092c138f9b7cf (diff) |
nixos/iay: add module; iay: add myself as a maintainer
Signed-off-by: Masanori Ogino <167209+omasanori@users.noreply.github.com>
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r-- | nixos/modules/programs/iay.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/nixos/modules/programs/iay.nix b/nixos/modules/programs/iay.nix new file mode 100644 index 0000000000000..1fa00e43795ad --- /dev/null +++ b/nixos/modules/programs/iay.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.iay; + inherit (lib) mkEnableOption mkIf mkOption mkPackageOption optionalString types; +in { + options.programs.iay = { + enable = mkEnableOption (lib.mdDoc "iay"); + package = mkPackageOption pkgs "iay" {}; + + minimalPrompt = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc "Use minimal one-liner prompt."; + }; + }; + + config = mkIf cfg.enable { + programs.bash.promptInit = '' + if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then + PS1='$(iay ${optionalString cfg.minimalPrompt "-m"})' + fi + ''; + + programs.zsh.promptInit = '' + if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then + autoload -Uz add-zsh-hook + _iay_prompt() { + PROMPT="$(iay -z ${optionalString cfg.minimalPrompt "-m"})" + } + add-zsh-hook precmd _iay_prompt + fi + ''; + }; + + meta.maintainers = pkgs.iay.meta.maintainers; +} |