summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2023-01-05 08:22:16 -0300
committerGitHub <noreply@github.com>2023-01-05 08:22:16 -0300
commit6124309e748a26489a99ac3c180eb32baddb6297 (patch)
tree5f987ca32a94e9f7e5b5d80be9af95d60388d070 /nixos
parent70acfaebf2b4c60081b74a68363db42a594d0846 (diff)
parent93224c214eb3340e2c7c9cb9f063c2220cd9ab74 (diff)
downloadnixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar.gz
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar.bz2
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar.lz
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar.xz
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.tar.zst
nixpkgs-6124309e748a26489a99ac3c180eb32baddb6297.zip
Merge pull request #207797 from omasanori/iay-module
nixos/iay: add module; iay: add myself as a maintainer
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/programs/iay.nix37
2 files changed, 38 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 41b953dc347..b2e80b10fc2 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 00000000000..1fa00e43795
--- /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;
+}