From 313e623ec4fb0a249b5db8fe69245819018c7546 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Thu, 15 Jan 2026 13:41:09 +0100 Subject: [PATCH] feat(home): add shell module --- home/modules/shell/bash.nix | 75 ++++++++++++++++++++++++++++++++++ home/modules/shell/default.nix | 7 ++++ home/modules/shell/prompt.nix | 17 ++++++++ home/modules/shell/utils.nix | 26 ++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 home/modules/shell/bash.nix create mode 100644 home/modules/shell/default.nix create mode 100644 home/modules/shell/prompt.nix create mode 100644 home/modules/shell/utils.nix diff --git a/home/modules/shell/bash.nix b/home/modules/shell/bash.nix new file mode 100644 index 0000000..9ea714c --- /dev/null +++ b/home/modules/shell/bash.nix @@ -0,0 +1,75 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.shell.bash; + username = config.home.username; + dotsPath = ../../../dots; +in +{ + options.shell.bash = { + enable = lib.mkEnableOption "bash configuration"; + + aliases = { + all = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable common aliases"; + }; + lang-js = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable JavaScript/Node.js aliases"; + }; + }; + + addBinToPath = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Add dots .bin directory to PATH"; + }; + + extraInit = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional bash initialization"; + }; + }; + + config = lib.mkIf cfg.enable { + shell-utils.enable = lib.mkDefault true; + + programs.bash = { + enable = true; + enableCompletion = true; + initExtra = '' + for f in /home/${username}/.bashrc.d/*; do + [ -f "$f" ] && source "$f" + done + + ${lib.optionalString cfg.aliases.all "source /home/${username}/.bash_aliases/all"} + ${lib.optionalString cfg.aliases.lang-js "source /home/${username}/.bash_aliases/lang-js"} + + ${lib.optionalString cfg.addBinToPath "export PATH=${dotsPath}/.bin:$PATH"} + + ${cfg.extraInit} + ''; + }; + + home.file = + { + ".inputrc".source = dotsPath + "/.inputrc"; + ".bashrc.d/prompt".source = dotsPath + "/.bashrc.d/prompt"; + ".bashrc.d/editor".source = dotsPath + "/.bashrc.d/editor"; + } + // lib.optionalAttrs cfg.aliases.all { + ".bash_aliases/all".source = dotsPath + "/.bash_aliases/all"; + } + // lib.optionalAttrs cfg.aliases.lang-js { + ".bash_aliases/lang-js".source = dotsPath + "/.bash_aliases/lang-js"; + }; + }; +} diff --git a/home/modules/shell/default.nix b/home/modules/shell/default.nix new file mode 100644 index 0000000..874a7f9 --- /dev/null +++ b/home/modules/shell/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ./bash.nix + ./utils.nix + ./prompt.nix + ]; +} diff --git a/home/modules/shell/prompt.nix b/home/modules/shell/prompt.nix new file mode 100644 index 0000000..f65b4fd --- /dev/null +++ b/home/modules/shell/prompt.nix @@ -0,0 +1,17 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + options.starship = { + enable = lib.mkEnableOption "starship prompt"; + }; + + config = lib.mkIf config.starship.enable { + programs.starship = { + enable = true; + }; + }; +} diff --git a/home/modules/shell/utils.nix b/home/modules/shell/utils.nix new file mode 100644 index 0000000..68cee31 --- /dev/null +++ b/home/modules/shell/utils.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + options.shell-utils = { + enable = lib.mkEnableOption "shell utilities"; + }; + + config = lib.mkIf config.shell-utils.enable { + programs.fzf = { + enable = true; + enableBashIntegration = lib.mkDefault true; + }; + + home.packages = with pkgs; [ + ripgrep + bat + jq + entr + parallel + ]; + }; +}