Skip to content

Commit

Permalink
nix: add cli-tool modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sbulav committed Jan 31, 2024
1 parent ce47b59 commit c067c99
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 5 deletions.
23 changes: 23 additions & 0 deletions nix/modules/nixos/cli-apps/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
inputs @ {
options,
config,
lib,
pkgs,
...
}:
with lib;
with lib.custom; let
cfg = config.custom.cli-apps.neovim;
in {
options.custom.cli-apps.neovim = with types; {
enable = mkBoolOpt false "Whether or not to enable neovim.";
};

config = mkIf cfg.enable {
programs.neovim = {
enable = true;
defaultEditor = true;
vimAlias = true;
};
};
}
21 changes: 21 additions & 0 deletions nix/modules/nixos/cli-apps/tmux/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
lib,
config,
pkgs,
...
}:
with lib;
with lib.custom; let
cfg = config.custom.cli-apps.tmux;
in {
options.custom.cli-apps.tmux = {
enable = mkEnableOption "Tmux";
};

config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
tmux
];
home.file.".tmux.conf".source = ./tmux.conf;
};
}
101 changes: 101 additions & 0 deletions nix/modules/nixos/cli-apps/tmux/tmux.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#####################################################
# THEME
#####################################################
# Status tuning
set -g status on
set -g status-bg black
set -g status-fg white
set -g window-status-current-style fg=white,bg=black,bold
set -g status-interval 1
set-option -g focus-events on
set -g default-shell /run/current-system/sw/bin/fish

# Set window title string
# # #H Hostname of local host
# # #I Current window index
# # #P Current pane index
# # #S Session name
# # #T Current window title
# # #W Current window name
# # # A literal ‘#’

# Set up left status
set -g status-left-length 50
set -g status-left '#[fg=red,bg=black][#h]#[fg=white,bold] W#I:P#P |#[default]'

# Set up right status
set -g status-right-length 60
set -g status-right "| #(/usr/bin/env bash $HOME/dotfiles/tmux/plugins/kube-tmux/kube.tmux 250 magenta cyan) #[fg=white]| #[fg=red] [%R]"
# set -g status-right '| #[fg=red]#(whoami) - [%R] '
# set -g status-right '| #[fg=red] [%R] '

# Set up automatic pane rename
set-option -g automatic-rename-format '#(id -u)@#h #{?#{==:#{pane_current_command},#{b:SHELL}},#{b:pane_current_path}/,#{pane_current_command}}'

# Highlight active window
set-window-option -g window-status-current-style bg=green,fg=black

# Aauto renumber windows on close
setw -g renumber-windows on

# Try to improve TERM colorscheme
# set -g default-terminal "screen-256color"
#set-option -ga terminal-overrides ',screen-256color:Tc'

# tmux display things in 256 colors
#set -g default-terminal "tmux-256color-italic"
#set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
# set -g default-terminal "xterm-24bit"
# set -g terminal-overrides ',xterm-24bit:Tc'
# set -g default-terminal 'xterm-256color'
# set -sa terminal-overrides ',xterm-256color:Tc'
set-option -g default-terminal "screen-256color"
set-option -ga terminal-overrides "screen-256color:Tc"

set -as terminal-features ',screen-256color:clipboard'
#set -s copy-command 'pbcopy'
set -g allow-passthrough on
set -g set-clipboard on
# enable terminal compability
#set-option -ga terminal-overrides ",tmux-256color-italic:Tc,xterm-256color-italic:T"

# Highlight windows where something changed with white
setw -g monitor-activity on

# Automatically set window title
set-window-option -g automatic-rename on
set-window-option -g allow-rename on

# Start indexing windows from 1
set -g base-index 1
set -g pane-base-index 1
#####################################################
# KEYS
#####################################################
# Use VI key bindings in the status line
set -g status-keys vi
# Use VI key bindings in copy and choice modes
setw -g mode-keys vi
# Use <PREFIX>+[,v for begin copy, y copy and <PREFIX>+P to paste current buffer
unbind P
bind P paste-buffer
# Keybinding for tmux >=2.6
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# No delay for escape key press
set -sg escape-time 0
# Set history size
set -g history-limit 50000
# # Reload tmux config using r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Toggle synchronization
bind e setw synchronize-panes on
bind E setw synchronize-panes off
6 changes: 6 additions & 0 deletions nix/modules/nixos/suites/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ in {

custom.tools = {
git.enable = true;
http.enable = true;
misc.enable = true;
};
custom.cli-apps = {
neovim.enable = true;
tmux.enable = true;
};
};
}
101 changes: 101 additions & 0 deletions nix/modules/nixos/system/security/gpg/tmux.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#####################################################
# THEME
#####################################################
# Status tuning
set -g status on
set -g status-bg black
set -g status-fg white
set -g window-status-current-style fg=white,bg=black,bold
set -g status-interval 1
set-option -g focus-events on
set -g default-shell /run/current-system/sw/bin/fish

# Set window title string
# # #H Hostname of local host
# # #I Current window index
# # #P Current pane index
# # #S Session name
# # #T Current window title
# # #W Current window name
# # # A literal ‘#’

# Set up left status
set -g status-left-length 50
set -g status-left '#[fg=red,bg=black][#h]#[fg=white,bold] W#I:P#P |#[default]'

# Set up right status
set -g status-right-length 60
set -g status-right "| #(/usr/bin/env bash $HOME/dotfiles/tmux/plugins/kube-tmux/kube.tmux 250 magenta cyan) #[fg=white]| #[fg=red] [%R]"
# set -g status-right '| #[fg=red]#(whoami) - [%R] '
# set -g status-right '| #[fg=red] [%R] '

# Set up automatic pane rename
set-option -g automatic-rename-format '#(id -u)@#h #{?#{==:#{pane_current_command},#{b:SHELL}},#{b:pane_current_path}/,#{pane_current_command}}'

# Highlight active window
set-window-option -g window-status-current-style bg=green,fg=black

# Aauto renumber windows on close
setw -g renumber-windows on

# Try to improve TERM colorscheme
# set -g default-terminal "screen-256color"
#set-option -ga terminal-overrides ',screen-256color:Tc'

# tmux display things in 256 colors
#set -g default-terminal "tmux-256color-italic"
#set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
# set -g default-terminal "xterm-24bit"
# set -g terminal-overrides ',xterm-24bit:Tc'
# set -g default-terminal 'xterm-256color'
# set -sa terminal-overrides ',xterm-256color:Tc'
set-option -g default-terminal "screen-256color"
set-option -ga terminal-overrides "screen-256color:Tc"

set -as terminal-features ',screen-256color:clipboard'
#set -s copy-command 'pbcopy'
set -g allow-passthrough on
set -g set-clipboard on
# enable terminal compability
#set-option -ga terminal-overrides ",tmux-256color-italic:Tc,xterm-256color-italic:T"

# Highlight windows where something changed with white
setw -g monitor-activity on

# Automatically set window title
set-window-option -g automatic-rename on
set-window-option -g allow-rename on

# Start indexing windows from 1
set -g base-index 1
set -g pane-base-index 1
#####################################################
# KEYS
#####################################################
# Use VI key bindings in the status line
set -g status-keys vi
# Use VI key bindings in copy and choice modes
setw -g mode-keys vi
# Use <PREFIX>+[,v for begin copy, y copy and <PREFIX>+P to paste current buffer
unbind P
bind P paste-buffer
# Keybinding for tmux >=2.6
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# No delay for escape key press
set -sg escape-time 0
# Set history size
set -g history-limit 50000
# # Reload tmux config using r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Toggle synchronization
bind e setw synchronize-panes on
bind E setw synchronize-panes off
8 changes: 8 additions & 0 deletions nix/modules/nixos/tools/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ in {
mergetool = {
prompt = false;
};
alias = {
st = "status -sb";
lga = "log --oneline --all --decorate --graph --color";
lg = "log --pretty=lg";
glg = "log --graph --pretty=lg";
slg = "stash list --pretty=reflg";
hist = "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short";
};
};
};
};
Expand Down
15 changes: 11 additions & 4 deletions nix/modules/nixos/tools/misc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ in {
home.configFile."wgetrc".text = "";

environment.systemPackages = with pkgs; [
fzf
killall
unzip
bat
dig
fd
file
fzf
iftop
ipfetch
jq
tree
killall
ripgrep
rsync
tree
unzip
yq
];
};
}
1 change: 0 additions & 1 deletion nix/modules/nixos/user/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ in {
};
interactiveShellInit = "source ~/dotfiles/fish/functions/l.fish";
};
tmux.enable = true;
};
users.users.${cfg.name} =
{
Expand Down

0 comments on commit c067c99

Please sign in to comment.