From 93224c214eb3340e2c7c9cb9f063c2220cd9ab74 Mon Sep 17 00:00:00 2001 From: Masanori Ogino <167209+omasanori@users.noreply.github.com> Date: Mon, 26 Dec 2022 13:59:20 +0900 Subject: [PATCH] nixos/iay: add module; iay: add myself as a maintainer Signed-off-by: Masanori Ogino <167209+omasanori@users.noreply.github.com> --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/iay.nix | 37 +++++++++++++++++++++++++++++++++ pkgs/tools/misc/iay/default.nix | 5 ++--- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 nixos/modules/programs/iay.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index af7fd4f712ca..4ae918567a4b 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -179,6 +179,7 @@ ./programs/haguichi.nix ./programs/hamster.nix ./programs/htop.nix + ./programs/iay.nix ./programs/iftop.nix ./programs/i3lock.nix ./programs/iotop.nix diff --git a/nixos/modules/programs/iay.nix b/nixos/modules/programs/iay.nix new file mode 100644 index 000000000000..1fa00e43795a --- /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; +} diff --git a/pkgs/tools/misc/iay/default.nix b/pkgs/tools/misc/iay/default.nix index 9c8b0a47ab86..88e14f582394 100644 --- a/pkgs/tools/misc/iay/default.nix +++ b/pkgs/tools/misc/iay/default.nix @@ -38,10 +38,9 @@ rustPlatform.buildRustPackage rec { NIX_LDFLAGS = lib.optionals stdenv.isDarwin [ "-framework" "AppKit" ]; meta = with lib; { - description = - "Minimalistic, blazing-fast, and extendable prompt for bash and zsh"; + description = "Minimalistic, blazing-fast, and extendable prompt for bash and zsh"; homepage = "https://github.com/aaqaishtyaq/iay"; license = licenses.mit; - maintainers = with maintainers; [ aaqaishtyaq ]; + maintainers = with maintainers; [ aaqaishtyaq omasanori ]; }; }