refactor core into cli so it can be used from hm as well

this gives me portable shellAliases and direnv
This commit is contained in:
Anish L 2022-05-22 21:10:29 +10:00
parent 89ee328bbd
commit 285e319681
7 changed files with 156 additions and 249 deletions

View file

@ -139,7 +139,7 @@
importables = rec { importables = rec {
profiles = digga.lib.rakeLeaves ./users/profiles; profiles = digga.lib.rakeLeaves ./users/profiles;
suites = with profiles; rec { suites = with profiles; rec {
hmBase = [ direnv git nvim ]; hmBase = [ direnv git nvim cli ];
gui = [ hmBase firefox desktop email cal ]; gui = [ hmBase firefox desktop email cal ];
work = [ hmBase firefox ]; work = [ hmBase firefox ];
}; };

View file

@ -6,65 +6,57 @@ in
nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
fonts = {
fonts = with pkgs; [ powerline-fonts dejavu_fonts ];
fontconfig.defaultFonts = {
monospace = [ "DejaVu Sans Mono for Powerline" ];
sansSerif = [ "DejaVu Sans" ];
};
};
nix = {
autoOptimiseStore = true;
gc.automatic = true;
optimise.automatic = true;
useSandbox = true;
allowedUsers = [ "@wheel" ];
trustedUsers = [ "root" "@wheel" ];
extraOptions = ''
min-free = 536870912
keep-outputs = true
keep-derivations = true
fallback = true
'';
};
#programs.bash = {
# promptInit = ''
# eval "$(starship init bash)"
# '';
# interactiveShellInit = ''
# flakify() {
# if [ ! -e flake.nix ]; then
# nix flake new -t github:nix-community/nix-direnv .
# elif [ ! -e .envrc ]; then
# echo "use flake" > .envrc
# direnv allow
# fi
# vim flake.nix
# }
# export STARSHIP_CONFIG=${
# pkgs.writeText "starship.toml"
# (builtins.readFile ./starship.toml)
# }
# eval "$(${pkgs.direnv}/bin/direnv hook bash)"
# '';
# enableCompletion = true;
#};
programs.zsh.enable = true;
environment = { environment = {
systemPackages = with pkgs; [
binutils
coreutils
dnsutils
dosfstools
git
bottom
gptfdisk
iputils
jq
manix
moreutils
nix-index
cached-nix-shell
nmap
ripgrep
skim
tealdeer
usbutils
utillinux
whois
iftop
wget
curl
exa
bat
fd
ag
tcpdump
mtr
file
lsof
atool
inotify-tools
strace
zip
unzip
rsync
tmux
pwgen
glow
gitAndTools.gitFull
pinentry_gnome
pass
less
gdb
xxd
kitty
taskwarrior
gnupg
syncthing
dijo
#kdeconnect
#ssb-patchwork
libreoffice
fontconfig
pandoc
];
shellInit = '' shellInit = ''
export STARSHIP_CONFIG=${ export STARSHIP_CONFIG=${
@ -77,40 +69,6 @@ in
let ifSudo = lib.mkIf config.security.sudo.enable; let ifSudo = lib.mkIf config.security.sudo.enable;
in in
{ {
# quick cd
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
# modern cli tools
ls = "exa";
l = "ls";
tree = "ls --tree";
cat = "bat";
unzip = "aunpack";
copy = "xclip -selection clipboard";
paste = "xclip -selection clipboard -o";
# task warrior
t = "task";
ta = "task add";
tm = "task modify";
te = "task edit";
ts = "task sync";
scrot = "scrot ~/screenshots/%b%d::%H%M%S.png";
# git
g = "git";
# grep
grep = "rg";
gi = "grep -i";
# internet ip
myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
# nix # nix
n = "nix"; n = "nix";
np = "n profile"; np = "n profile";
@ -128,7 +86,6 @@ in
mn = '' mn = ''
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
''; '';
# fix nixos-option # fix nixos-option
nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
@ -158,49 +115,6 @@ in
}; };
}; };
fonts = {
fonts = with pkgs; [ powerline-fonts dejavu_fonts ];
fontconfig.defaultFonts = {
monospace = [ "DejaVu Sans Mono for Powerline" ];
sansSerif = [ "DejaVu Sans" ];
};
};
nix = {
autoOptimiseStore = true;
gc.automatic = true;
optimise.automatic = true;
useSandbox = true;
allowedUsers = [ "@wheel" ];
trustedUsers = [ "root" "@wheel" ];
extraOptions = ''
min-free = 536870912
keep-outputs = true
keep-derivations = true
fallback = true
'';
};
programs.bash = {
promptInit = ''
eval "$(${pkgs.starship}/bin/starship init bash)"
'';
interactiveShellInit = ''
flakify() {
if [ ! -e flake.nix ]; then
nix flake new -t github:nix-community/nix-direnv .
elif [ ! -e .envrc ]; then
echo "use flake" > .envrc
direnv allow
fi
vim flake.nix
}
eval "$(${pkgs.direnv}/bin/direnv hook bash)"
'';
enableCompletion = true;
};
services.devmon.enable = true; services.devmon.enable = true;
# For rage encryption, all hosts need a ssh key pair # For rage encryption, all hosts need a ssh key pair

View file

@ -1,4 +1,4 @@
{ hmUsers, ... }: { hmUsers, pkgs, ... }:
{ {
#home-manager.users = { inherit (hmUsers) anish; }; #home-manager.users = { inherit (hmUsers) anish; };
@ -6,16 +6,17 @@
users.users.anish = { users.users.anish = {
description = "Personal user for Anish"; description = "Personal user for Anish";
hashedPassword = "MVHHpy9gbe3ow"; hashedPassword = "MVHHpy9gbe3ow";
shell = pkgs.zsh;
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" "audio" ]; extraGroups = [ "wheel" "audio" ];
openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDM0Zvei46x/yZl/IeBCq6+IYQQ0avulzVyBysF9cPigZMCybWRV7IEU+E3k9t6JrbdbdGfJkcZIWmsWDdKS8W8mBnZpVoT0ffLynu8JQ/TKdGm4Qv6bgUeKNrGsNv0ZPs2CDaGSLj0oJfRF7Ko10tcLP0vW+yujrh+y6TH/vVzJioaV4TGvtCUpn+wEQah9ROwPQLUUofsSWdnRsDJ/gp37zXWs4l5wyjSKtP3O9RZUP7kBekbSqEgSXiTk0oUQSVqIWl9NDiP6onk/gSOjXsR/JPqsSN/XI/c/yj6gyY0f51Ru2D7iBxuMJIJcWV+rU6coIj+ULcQWLzt/7TI8jq5AOOzI/ll4zbL24Eo84Rz+TP9tvMMhDZ0VaMN22AJ8qQEjc5P09tWKsX7Jg39XelyV1jHXncE4yvIE9F4RSCHzWCeKeXakizQNuzSaxTxIExRFYHjNW5bR6+3MTGwVrEIXU+qML+0yFTR86MT+tdY5AreAJQLwbog79O1NupeXJE= anish@curve" ]; openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDM0Zvei46x/yZl/IeBCq6+IYQQ0avulzVyBysF9cPigZMCybWRV7IEU+E3k9t6JrbdbdGfJkcZIWmsWDdKS8W8mBnZpVoT0ffLynu8JQ/TKdGm4Qv6bgUeKNrGsNv0ZPs2CDaGSLj0oJfRF7Ko10tcLP0vW+yujrh+y6TH/vVzJioaV4TGvtCUpn+wEQah9ROwPQLUUofsSWdnRsDJ/gp37zXWs4l5wyjSKtP3O9RZUP7kBekbSqEgSXiTk0oUQSVqIWl9NDiP6onk/gSOjXsR/JPqsSN/XI/c/yj6gyY0f51Ru2D7iBxuMJIJcWV+rU6coIj+ULcQWLzt/7TI8jq5AOOzI/ll4zbL24Eo84Rz+TP9tvMMhDZ0VaMN22AJ8qQEjc5P09tWKsX7Jg39XelyV1jHXncE4yvIE9F4RSCHzWCeKeXakizQNuzSaxTxIExRFYHjNW5bR6+3MTGwVrEIXU+qML+0yFTR86MT+tdY5AreAJQLwbog79O1NupeXJE= anish@curve" ];
}; };
home-manager.users.anish.programs.git = { # home-manager.users.anish.programs.git = {
userName = "Anish Lakhwara"; # userName = "Anish Lakhwara";
userEmail = "anish+git@lakhwara.com"; # userEmail = "anish+git@lakhwara.com";
delta.enable = true; # delta.enable = true;
}; # };
#home-manager.users.anish = { suites, ... }: { #home-manager.users.anish = { suites, ... }: {
# imports = suites.gui; # imports = suites.gui;

View file

@ -9,6 +9,7 @@
#git #git
bottom bottom
gptfdisk gptfdisk
starship
iputils iputils
jq jq
manix manix
@ -28,6 +29,8 @@
exa exa
bat bat
fd fd
trash-cli
nix-index
ag ag
tcpdump tcpdump
mtr mtr
@ -42,7 +45,6 @@
tmux tmux
pwgen pwgen
glow glow
gitAndTools.gitFull
pinentry_gnome pinentry_gnome
pass pass
less less
@ -60,113 +62,69 @@
pandoc pandoc
]; ];
programs.bash = { programs.starship = {
promptInit = '' enable = true;
eval "$(${pkgs.starship}/bin/starship init bash)" enableZshIntegration = true;
''; };
interactiveShellInit = ''
flakify() {
if [ ! -e flake.nix ]; then
nix flake new -t github:nix-community/nix-direnv .
elif [ ! -e .envrc ]; then
echo "use flake" > .envrc
direnv allow
fi
vim flake.nix
}
eval "$(${pkgs.direnv}/bin/direnv hook bash)" programs.zsh = {
''; enable = true;
# interactiveShellInit = ''
# flakify() {
# if [ ! -e flake.nix ]; then
# nix flake new -t github:nix-community/nix-direnv .
# elif [ ! -e .envrc ]; then
# echo "use flake" > .envrc
# direnv allow
# fi
# vim flake.nix
# }
# '';
sessionVariables = {
EDITOR = "nvim";
};
enableCompletion = true; enableCompletion = true;
shellInit = '' };
export STARSHIP_CONFIG=${
pkgs.writeText "starship.toml"
(fileContents ./starship.toml)
}
'';
shellAliases = programs.direnv = {
let ifSudo = lib.mkIf config.security.sudo.enable; enable = true;
in enableZshIntegration = true;
{ };
# quick cd
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
# modern cli tools home.shellAliases = {
ls = "exa"; # quick cd
l = "ls"; ".." = "cd ..";
tree = "ls --tree"; "..." = "cd ../..";
cat = "bat"; "...." = "cd ../../..";
unzip = "aunpack"; "....." = "cd ../../../..";
copy = "xclip -selection clipboard";
paste = "xclip -selection clipboard -o";
# task warrior # modern cli tools
t = "task"; ls = "exa";
ta = "task add"; l = "ls";
tm = "task modify"; tree = "ls --tree";
te = "task edit"; cat = "bat";
ts = "task sync"; unzip = "aunpack";
copy = "xclip -selection clipboard";
paste = "xclip -selection clipboard -o";
scrot = "scrot ~/screenshots/%b%d::%H%M%S.png"; # task warrior
t = "task";
ta = "task add";
tm = "task modify";
te = "task edit";
ts = "task sync";
# git scrot = "scrot ~/screenshots/%b%d::%H%M%S.png";
g = "git";
# grep # git
grep = "rg"; g = "git";
gi = "grep -i";
# internet ip # grep
myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; grep = "rg";
gi = "grep -i";
# nix # internet ip
n = "nix"; myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
np = "n profile";
ni = "np install";
nr = "np remove";
ns = "n search --no-update-lock-file";
nf = "n flake";
nepl = "n repl '<nixpkgs>'";
srch = "ns nixos";
orch = "ns override";
nrb = ifSudo "cd /tmp; sudo nixos-rebuild switch --flake '/etc/nixos/#curve'; cd $OLDPWD";
nrt = ifSudo "sudo nixos-rebuild test --flake '/etc/nixos/#curve'";
nedit = "cd /etc/nixos; vim";
ncd = "cd /etc/nixos";
mn = ''
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
'';
# fix nixos-option
nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
# sudo
s = ifSudo "sudo -E ";
pls = ifSudo "s";
si = ifSudo "sudo -i";
se = ifSudo "sudoedit";
# top
top = "btm";
# systemd
ctl = "systemctl";
stl = ifSudo "s systemctl";
utl = "systemctl --user";
ut = "systemctl --user start";
un = "systemctl --user stop";
up = ifSudo "s systemctl start";
dn = ifSudo "s systemctl stop";
jtl = "journalctl";
# quick ssh
sm = "ssh 10.0.69.4";
ss = "ssh sealight.xyz";
sc = "ssh lakhwara.com"; # cube
};
}; };
} }

View file

@ -22,7 +22,7 @@
emails = !git log --format="%aE" | sort -u emails = !git log --format="%aE" | sort -u
email-domains = !git log --format="%aE" | awk -F'@' '{print $2}' | sort -u email-domains = !git log --format="%aE" | awk -F'@' '{print $2}' | sort -u
# pretty log # pretty log
ls = log --graph --abbrev-commit --decorate --color=always --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) - %C(dim red)%an%C(reset)%C(bold yellow)%d%C(reset)' --all ls = !git log --graph --abbrev-commit --decorate --color=always --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) - %C(dim red)%an%C(reset)%C(bold yellow)%d%C(reset)' --all
[filter "lfs"] [filter "lfs"]
required = true required = true
smudge = git-lfs smudge -- %f smudge = git-lfs smudge -- %f

View file

@ -1,14 +1,45 @@
{ {
xdg.configFile = { #xdg.configFile = {
"git/config".source = ./config; # "git/config".source = ./config;
"git/ignore".source = ./ignore; # "git/ignore".source = ./ignore;
"git/attributes".source = ./attributes; # "git/attributes".source = ./attributes;
}; #};
programs.lazygit.enable = true; programs.lazygit.enable = true;
programs.git = { programs.git = {
enable = true; enable = true;
userName = "Anish Lakhwara";
userEmail = "anish+git@lakhwara.com";
delta.enable = true;
ignores = [
"*~"
"*.*~"
"\\#*"
".\\#*"
"*.swp"
".*.sw[a-z]"
"*.un~"
".netrwhist"
".vim/*"
".DS_Store?"
".DS_Store"
".CFUserTextEncoding"
".Trash"
".Xauthority"
"thumbs.db"
"Thumbs.db"
"Icon?"
".ccls-cache/"
".sass-cache/"
"__pycache__/"
"*.class"
"*.exe"
"*.o"
"*.pyc"
"*.elc"
];
extraConfig = { extraConfig = {
pull.rebase = false; pull.rebase = false;
@ -19,7 +50,7 @@
co = "checkout"; co = "checkout";
cob = "checkout -b"; cob = "checkout -b";
f = "fetch -p"; f = "fetch -p";
c = "commit"; c = "commit -v";
p = "push"; p = "push";
ba = "branch -a"; ba = "branch -a";
bd = "branch -d"; bd = "branch -d";
@ -45,6 +76,8 @@
tlog = tlog =
"log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative"; "log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative";
rank = "shortlog -sn --no-merges"; rank = "shortlog -sn --no-merges";
authors = "authors | sort | uniq -c | sort -n";
ls = "log --graph --abbrev-commit --decorate --color=always --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) - %C(dim red)%an%C(reset)%C(bold yellow)%d%C(reset)' --all";
# delete merged branches # delete merged branches
bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"; bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d";

View file

@ -180,6 +180,7 @@ in
map <leader>q :q<CR> map <leader>q :q<CR>
map <leader>r :RainbowParenthesesToggleAll<CR> map <leader>r :RainbowParenthesesToggleAll<CR>
map <leader><BS> :noh<CR> map <leader><BS> :noh<CR>
map Q <Nop>
nnoremap Y y$ nnoremap Y y$
" center moving " center moving
nnoremap n nzzzv nnoremap n nzzzv