improv: shells.nix module
parent
9161d088ef
commit
f1284ba35b
|
@ -1 +1,89 @@
|
|||
{}
|
||||
# Configurations for shell stuffs.
|
||||
# Should probably be decoupled even more
|
||||
{ config
|
||||
, proj_root
|
||||
, myLib
|
||||
, ...
|
||||
}:
|
||||
let cfg = config.base.shells;
|
||||
in
|
||||
{
|
||||
options.base.shells = {
|
||||
enable = myLib.mkOption {
|
||||
type = myLib.types.bool;
|
||||
description = "Enable umbrella shell configuration";
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
# TODO: Support shell-specific init
|
||||
shellInitExtra = myLib.mkOption {
|
||||
type = myLib.types.str;
|
||||
description = "Extra shell init. The syntax should be sh-compliant";
|
||||
default = "";
|
||||
example = ''
|
||||
# X11 support for WSL
|
||||
export DISPLAY=$(ip route list default | awk '{print $3}'):0
|
||||
export LIBGL_ALWAYS_INDIRECT=1
|
||||
'';
|
||||
};
|
||||
shellAliases = myLib.mkOption {
|
||||
type = myLib.types.attrs;
|
||||
description = "Shell command aliases";
|
||||
default = { };
|
||||
example = {
|
||||
nixGL = "nixGLIntel";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = myLib.mkIf cfg.enable {
|
||||
xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
|
||||
# nix: Propagates the environment with packages and vars when enter (children of)
|
||||
# a directory with shell.nix-compatible and .envrc
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
|
||||
};
|
||||
# z <path> as smarter cd
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf";
|
||||
};
|
||||
programs.exa = {
|
||||
enable = true;
|
||||
enableAliases = true;
|
||||
};
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
programs.fzf.enable = true;
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
initExtra = cfg.shellInitExtra or "";
|
||||
};
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
enableAutosuggestions = true;
|
||||
shellAliases = {
|
||||
nix-rebuild = "sudo nixos-rebuild switch";
|
||||
hm-switch = "home-manager switch --flake";
|
||||
} // (cfg.shellAliases or { });
|
||||
history = {
|
||||
size = 10000;
|
||||
path = "${config.xdg.dataHome}/zsh/history";
|
||||
};
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
plugins = [ "git" "sudo" "command-not-found" "gitignore" "ripgrep" "rust" ];
|
||||
};
|
||||
initExtra = cfg.shellInitExtra or "";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -60,6 +60,12 @@
|
|||
inherit pkgs;
|
||||
modules = [
|
||||
./home.nix
|
||||
{
|
||||
base.shells = {
|
||||
shellInitExtra = ''
|
||||
'' + x11_wsl;
|
||||
};
|
||||
}
|
||||
];
|
||||
# optionally pass inarguments to module
|
||||
# we migrate this from in-place modules to allow flexibility
|
||||
|
@ -69,8 +75,6 @@
|
|||
myHome = {
|
||||
username = "nixos";
|
||||
homeDirectory = "/home/nixos";
|
||||
shellInitExtra = ''
|
||||
'' + x11_wsl;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -98,6 +102,11 @@
|
|||
./home.nix
|
||||
{
|
||||
base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font";
|
||||
base.shells = {
|
||||
shellAliases = {
|
||||
nixGL = "nixGLIntel";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
extraSpecialArgs = mkModuleArgs {
|
||||
|
@ -109,9 +118,6 @@
|
|||
pkgs.nixgl.nixGLIntel
|
||||
pkgs.postman
|
||||
];
|
||||
shellAliases = {
|
||||
nixGL = "nixGLIntel";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -67,38 +67,12 @@ in
|
|||
|
||||
## Configs ##
|
||||
xdg.configFile."nvim/init.lua".source = "${proj_root}//neovim/init.lua";
|
||||
xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
|
||||
xdg.configFile."zk/config.toml".source = "${proj_root}//zk/config.toml";
|
||||
|
||||
## Programs ##
|
||||
programs.jq = {
|
||||
enable = true;
|
||||
};
|
||||
# nix: Propagates the environment with packages and vars when enter (children of)
|
||||
# a directory with shell.nix-compatible and .envrc
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
|
||||
};
|
||||
# z <path> as smarter cd
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf";
|
||||
};
|
||||
programs.exa = {
|
||||
enable = true;
|
||||
enableAliases = true;
|
||||
};
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
programs.fzf.enable = true;
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
|
@ -115,27 +89,4 @@ in
|
|||
# https://github.com/nix-community/home-manager/pull/3287
|
||||
# extraConfig = builtins.readFile "${proj_root}/neovim/init.lua";
|
||||
};
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
initExtra = myHome.shellInitExtra or "";
|
||||
};
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
enableAutosuggestions = true;
|
||||
shellAliases = {
|
||||
nix-rebuild = "sudo nixos-rebuild switch";
|
||||
hm-switch = "home-manager switch --flake";
|
||||
} // (myHome.shellAliases or { });
|
||||
history = {
|
||||
size = 10000;
|
||||
path = "${config.xdg.dataHome}/zsh/history";
|
||||
};
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
plugins = [ "git" "sudo" "command-not-found" "gitignore" "ripgrep" "rust" ];
|
||||
};
|
||||
initExtra = myHome.shellInitExtra or "";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue