feat(home): add shell module
This commit is contained in:
75
home/modules/shell/bash.nix
Normal file
75
home/modules/shell/bash.nix
Normal file
@@ -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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
7
home/modules/shell/default.nix
Normal file
7
home/modules/shell/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./bash.nix
|
||||||
|
./utils.nix
|
||||||
|
./prompt.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
17
home/modules/shell/prompt.nix
Normal file
17
home/modules/shell/prompt.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.starship = {
|
||||||
|
enable = lib.mkEnableOption "starship prompt";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.starship.enable {
|
||||||
|
programs.starship = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
26
home/modules/shell/utils.nix
Normal file
26
home/modules/shell/utils.nix
Normal file
@@ -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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user