initial commit

This commit is contained in:
Jakob Lechner 2025-07-17 00:45:59 +02:00
commit 1efde7694d
22 changed files with 1038 additions and 0 deletions

41
users/jalr/default.nix Normal file
View file

@ -0,0 +1,41 @@
{
config,
pkgs,
...
}: let
sshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3l+Yixrsjhze20CSjvUK4Qj/BNqbTNitgk20vuzPej cardno:25_750_479"
];
in {
users.users.jalr = {
isNormalUser = true;
extraGroups = [
"adbusers"
"audio"
"dialout"
"libvirtd"
"lp"
"networkmanager"
"scanner"
"video"
"wheel"
"wireshark"
];
shell = pkgs.fish;
openssh.authorizedKeys.keys = sshKeys;
};
users.users.root.openssh.authorizedKeys.keys = sshKeys;
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
users.jalr = {...}: {
imports = [./modules];
config = {
home.stateVersion = config.system.stateVersion;
};
};
};
}

View file

@ -0,0 +1,12 @@
{pkgs, ...}: {
home.packages = with pkgs; [
cached-nix-shell
file
htop
inetutils
jq
lsof
ncdu
ripgrep
];
}

View file

@ -0,0 +1,9 @@
{...}: {
imports = [
./cli.nix
./fish.nix
./neovim.nix
];
programs.nix-index.enable = true;
}

200
users/jalr/modules/fish.nix Normal file
View file

@ -0,0 +1,200 @@
{pkgs, ...}: {
home.packages = with pkgs; [
fzf
];
programs.fish = {
enable = true;
plugins = [
{
name = "theme-agnoster";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "theme-agnoster";
rev = "c142e802983bd1b34b4d91efac2126fc5913126d";
sha256 = "0PLx626BWoBp/L6wgkB4o+53q8PymiEE/rTu2mfzHhg=";
fetchSubmodules = true;
};
}
{
name = "fzf";
src = pkgs.fetchFromGitHub {
owner = "jethrokuan";
repo = "fzf";
rev = "479fa67d7439b23095e01b64987ae79a91a4e283";
sha256 = "0k6l21j192hrhy95092dm8029p52aakvzis7jiw48wnbckyidi6v";
fetchSubmodules = true;
};
}
];
shellAliases = {
ls = "ls --color=auto";
crontab = "crontab -i";
};
shellAbbrs = {
lessr = "less -R";
jqc = "jq -C";
};
#interactiveShellInit = ''
# echo "programs.fish.interactiveShellInit"
#'';
shellInit = ''
# key bindings
bind \cr '__fzf_reverse_isearch'
# PATH
set -U fish_user_paths $HOME/.local/bin $HOME/.local/bin/pio
# pass
#set -x PASSWORD_STORE_ENABLE_EXTENSIONS true
set -x AWS_VAULT_BACKEND pass
set -x AWS_VAULT_PASS_PREFIX aws
complete -c pw --no-files -a '(__fish_pass_print_entries)'
# colors
set -x GCC_COLORS 'error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
abbr --add v vim
#alias cal='ncal -b -M'
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
function hm -d 'merge history and delete failed commands'
history --merge
if test -z "$fish_private_mode" && test -e "$__fish_user_data_dir/successful_commands" && test -e "$__fish_user_data_dir/failed_commands"
while read line;
if ! grep -qFx $line "$__fish_user_data_dir/successful_commands"
set hist_command (echo $line | base64 -d)
echo "deleting command: $hist_command"
echo "."
history delete --exact --case-sensitive $hist_command
end
end < "$__fish_user_data_dir/failed_commands"
echo -n > "$__fish_user_data_dir/successful_commands"
echo -n > "$__fish_user_data_dir/failed_commands"
end
end
hm
# fancy tools
if which eza > /dev/null 2>&1
alias l=eza
alias ll='eza -l --time-style=long-iso --git'
alias la='eza -la --time-style=long-iso --git'
alias tree='eza --tree'
alias llt='eza -s modified -l'
else
alias l=ls
alias ll='ls -l'
alias la='ls -la'
alias llt='ls -trl'
end
if which rg > /dev/null 2>&1
alias g=rg
complete -c g -w rg
else if which ag > /dev/null 2>&1
alias g=ag
complete -c g -w ag
else
alias g='grep --color=auto'
complete -c g -w grep
end
function jqless -d 'jq -C [args] | less -R'
jq -C $argv | less -R
end
# NixOS direnv
if which direnv > /dev/null
eval (direnv hook fish)
end
function __cut_commandline -d 'cut commandline and paste it later'
set -g commandline_buffer (commandline)
commandline ""
end
function __postexec --on-event fish_postexec
if test $status -ne 0
if test -z "$hist_cmd"
if test -z "$fish_private_mode"
echo $argv[1] | base64 >> "$__fish_user_data_dir/failed_commands"
end
end
else
if test -z "$fish_private_mode"
echo $argv[1] | base64 >> "$__fish_user_data_dir/successful_commands"
end
commandline $commandline_buffer
set -e commandline_buffer
end
end
function dirh-nocolor --description "Print the current directory history (the prev and next lists)"
set -l options h/help
argparse -n dirh --max-args=0 $options -- $argv
or return
if set -q _flag_help
__fish_print_help dirh
return 0
end
set -l dirc (count $dirprev)
if test $dirc -gt 0
set -l dirprev_rev $dirprev[-1..1]
# This can't be (seq $dirc -1 1) because of BSD.
set -l dirnum (seq 1 $dirc)
for i in $dirnum[-1..1]
printf '%s\n' $dirprev_rev[$i]
end
end
echo $PWD
set -l dirc (count $dirnext)
if test $dirc -gt 0
set -l dirnext_rev $dirnext[-1..1]
for i in (seq $dirc)
printf '%s\n' $dirnext_rev[$i]
end
end
end
function dirh-fzf -d 'directory history fuzzy finder'
builtin cd (dirh-nocolor | uniq | fzf)
end
bind \ed 'dirh-fzf'
'';
};
xdg.configFile."fish/completions/mycli.fish".text = ''
complete -e -c mycli
complete -c mycli -f -s h -l host -d "Host address of the database."
complete -c mycli -f -s P -l port -d "Port number to use for connection."
complete -c mycli -f -s u -l user -d "User name to connect to the database."
complete -c mycli -f -s S -l socket -d "The socket file to use for connection."
complete -c mycli -f -s p -l pass \
-l password -d "Password to connect to the database."
complete -c mycli -f -s V -l version -d "Output mycli's version."
complete -c mycli -f -s v -l verbose -d "Verbose output."
complete -c mycli -f -s d -l dsn -d "Use DSN configured into the [alias_dsn] section of myclirc file."
complete -c mycli -f -l list-dsn -d "list of DSN configured into the [alias_dsn] section of myclirc file."
complete -c mycli -f -s t -l table -d "Display batch output in table format."
complete -c mycli -f -l csv -d "Display batch output in CSV format."
complete -c mycli -f -l warn \
-l no-warn -d "Warn before running a destructive query."
complete -c mycli -f -s e -l execute -d "Execute command and quit."
complete -c mycli -f -s h -l host -r -a '(__fish_print_hostnames)'
complete -c mycli -f -s d -l dsn -r -a '(mycli --list-dsn)'
'';
}

View file

@ -0,0 +1,9 @@
{
home.sessionVariables = {
EDITOR = "nvim";
};
programs.neovim = {
enable = true;
vimAlias = true;
};
}