Nix fish config

This commit is contained in:
Daniel Flanagan 2023-08-29 22:01:34 -05:00
parent e9c6588b7c
commit 3a9a7fb1dc
13 changed files with 469 additions and 110 deletions

1
common/broot/conf.toml Symbolic link
View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/conf.toml

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/dark-blue-skin.hjson

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/dark-gruvbox.hjson

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/dark-orange-skin.hjson

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/launcher/installed-v1

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/solarized-dark.hjson

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/solarized-light.hjson

View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/broot/white-skin.hjson

View file

@ -1,83 +0,0 @@
source (dirname (status --current-filename))/paths.fish
for s in $ENV_PATH/*/config.d.fish
source $s (dirname $s)
end
for f in vars colors functions
source $FISH_PATH/$f.fish
end
if has_command rtx
rtx activate fish | source
else if has_command brew && test -f (brew --prefix asdf)/libexec/asdf.fish
set --universal --export ASDF_DIR (brew --prefix asdf)
source (brew --prefix asdf)/libexec/asdf.fish
else if test -f $HOME/.asdf/asdf.fish
source $HOME/.asdf/asdf.fish
else if test -f /opt/asdf-vm/asdf.fish
source /opt/asdf-vm/asdf.fish
end
if test -f $HOME/.nix-profile/etc/profile.d/nix.fish
. $HOME/.nix-profile/etc/profile.d/nix.fish
end
if test -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
# for determinate systems install
set nix_profiles /nix/var/nix/profiles/default $HOME/.nix-profile
set --export --universal NIX_PROFILES "$nix_profiles"
if set -q NIX_SSL_CERT_FILE
:
else if test -e /etc/ssl/certs/ca-certificates.crt
set --export --universal NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
else
for p in (string split $NIX_PROFILES)
test -e $p/etc/ssl/certs/ca-bundle.crt && \
set --export --universal NIX_SSL_CERT_FILE $p/etc/ssl/certs/ca-bundle.crt
end
end
set --prepend --export --global fish_user_paths $HOME/.nix-profile/bin /nix/var/nix/profiles/default/bin
end
if has_command direnv
direnv hook fish | source
end
# everything after this is ONLY relevant to interactive shells
status --is-interactive || exit
if has_command nnn
source $DOTFILES_PATH/common/nnn/config.fish
end
for f in prompt key-bindings
source $FISH_PATH/$f.fish
end
if test -f /usr/share/password-store/extensions/otp.bash
source $FISH_PATH/pass-otp-completions.fish
end
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
test $PWD = $HOME && begin
cd $NICE_HOME || cd
end
# If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features
# Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij
if not set --query ZELLIJ && set --query FISH_START_ZELLIJ
# simulate auto attach
zellij attach -c
# simulate auto kill
kill $fish_pid
else if not set --query TMUX && set --query FISH_START_TMUX
tmux att -t default || tmux new -s default
end

1
common/fish/config.fish Symbolic link
View file

@ -0,0 +1 @@
/nix/store/vmfr3iw7kyh0l3a9lnw21dzarjlg1y4d-home-manager-files/.config/fish/config.fish

83
common/fish/old-config.fish Executable file
View file

@ -0,0 +1,83 @@
source (dirname (status --current-filename))/paths.fish
for s in $ENV_PATH/*/config.d.fish
source $s (dirname $s)
end
for f in vars colors functions
source $FISH_PATH/$f.fish
end
if has_command rtx
rtx activate fish | source
else if has_command brew && test -f (brew --prefix asdf)/libexec/asdf.fish
set --universal --export ASDF_DIR (brew --prefix asdf)
source (brew --prefix asdf)/libexec/asdf.fish
else if test -f $HOME/.asdf/asdf.fish
source $HOME/.asdf/asdf.fish
else if test -f /opt/asdf-vm/asdf.fish
source /opt/asdf-vm/asdf.fish
end
if test -f $HOME/.nix-profile/etc/profile.d/nix.fish
. $HOME/.nix-profile/etc/profile.d/nix.fish
end
if test -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
# for determinate systems install
set nix_profiles /nix/var/nix/profiles/default $HOME/.nix-profile
set --export --universal NIX_PROFILES "$nix_profiles"
if set -q NIX_SSL_CERT_FILE
:
else if test -e /etc/ssl/certs/ca-certificates.crt
set --export --universal NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
else
for p in (string split $NIX_PROFILES)
test -e $p/etc/ssl/certs/ca-bundle.crt && \
set --export --universal NIX_SSL_CERT_FILE $p/etc/ssl/certs/ca-bundle.crt
end
end
set --prepend --export --global fish_user_paths $HOME/.nix-profile/bin /nix/var/nix/profiles/default/bin
end
if has_command direnv
direnv hook fish | source
end
# everything after this is ONLY relevant to interactive shells
status --is-interactive || exit
if has_command nnn
source $DOTFILES_PATH/common/nnn/config.fish
end
for f in prompt key-bindings
source $FISH_PATH/$f.fish
end
if test -f /usr/share/password-store/extensions/otp.bash
source $FISH_PATH/pass-otp-completions.fish
end
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
test $PWD = $HOME && begin
cd $NICE_HOME || cd
end
# If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features
# Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij
if not set --query ZELLIJ && set --query FISH_START_ZELLIJ
# simulate auto attach
zellij attach -c
# simulate auto kill
kill $fish_pid
else if not set --query TMUX && set --query FISH_START_TMUX
tmux att -t default || tmux new -s default
end

View file

@ -1,14 +1,358 @@
{ pkgs, ... }: {
# TODO: email access?
# accounts.email.accounts = {
# google = {
# address = "wraithx2@gmail.com";
# };
# };
home.username = "daniel";
home.homeDirectory = "/home/daniel/.home";
home.stateVersion = "23.05";
home.packages = [
];
programs.broot = {
enable = true;
enableFishIntegration = true;
};
programs.home-manager.enable = true;
programs.direnv.enable = true;
# programs.nix-direnv.enable = true;
programs.fish.enable = true;
programs.fish = {
enable = true;
shellInit = ''
# paths
if not set --query NICE_HOME
set --export --universal NICE_HOME $HOME
# if HOME ends with a dir called .home, assume that NICE_HOME is HOME's parent dir
test (basename $HOME) = .home \
&& set --export --universal NICE_HOME (realpath $HOME/..)
end
set --export --universal XDG_CONFIG_HOME $HOME/.config
set --export --universal XDG_CACHE_HOME $HOME/.cache
set --export --universal XDG_DATA_HOME $HOME/.local/share
set --export --universal XDG_STATE_HOME $HOME/.local/state
set --export --universal XDG_DESKTOP_DIR $HOME/desktop
set --export --universal XDG_PUBLICSHARE_DIR $HOME/public
set --export --universal XDG_TEMPLATES_DIR $HOME/templates
set --export --universal XDG_DOCUMENTS_DIR $NICE_HOME/doc
set --export --universal XDG_DOWNLOAD_DIR $NICE_HOME/dl
set --export --universal XDG_MUSIC_DIR $NICE_HOME/music
set --export --universal XDG_PICTURES_DIR $NICE_HOME/img
set --export --universal XDG_VIDEOS_DIR $NICE_HOME/video
set --export --universal XDG_GAMES_DIR $NICE_HOME/games
set --export --universal DOTFILES_PATH $XDG_CONFIG_HOME/lytedev-dotfiles
set --export --universal ENV_PATH $XDG_CONFIG_HOME/lytedev-env
set --export --universal FISH_PATH $XDG_CONFIG_HOME/fish
set --export --universal NOTES_PATH $NICE_HOME/doc/notes
set --export --universal SCROTS_PATH $NICE_HOME/img/scrots
set --export --universal USER_LOGS_PATH $NICE_HOME/doc/logs
for s in $ENV_PATH/*/config.d.fish
source $s (dirname $s)
end
# vars
set --export --universal LS_COLORS 'ow=01;36;40'
set --export --universal EXA_COLORS '*=0'
set --export --universal ERL_AFLAGS "-kernel shell_history enabled -kernel shell_history_file_bytes 1024000"
set --export --universal BROWSER firefox
set --export --universal EDITOR hx
set --export --universal VISUAL hx
# TODO: helix ($EDITOR) as man/pager
set --export --universal PAGER "less"
set --export --universal MANPAGER "less"
set --export --universal SOPS_AGE_KEY_FILE "$XDG_CONFIG_HOME/sops/age/keys.txt"
set --export --universal SKIM_ALT_C_COMMAND "fd --hidden --type directory"
set --export --universal SKIM_CTRL_T_COMMAND "fd --hidden"
# colors
set -U fish_color_normal normal # default color
set -U fish_color_command white # base command being run (>ls< -la)
set -U fish_color_param white # command's parameters
set -U fish_color_end green # command delimiter/separators (; and &)
set -U fish_color_error red # color of errors
set -U fish_color_escape yellow # color of escape codes (\n, \x2d, etc.)
set -U fish_color_operator blue # expansion operators (~, *)
set -U fish_color_quote yellow
set -U fish_color_redirection blue # redirection operators (|, >, etc.)
set -U fish_color_cancel 333 brblack # sigint at prompt (^C)
set -U fish_color_autosuggestion 666 brblack # as-you-type suggestions
set -U fish_color_match blue # matching parens and the like
set -U fish_color_search_match white\x1e\x2d\x2dbackground\x3d333 # selected pager item
set -U fish_color_selection blue # vi mode visual selection (only fg)
set -U fish_color_valid_path yellow # if an argument is a valid path (only -u?)
set -U fish_color_comment 666 brblack # comments like this one!
set -U fish_pager_color_completion white # main color for pager
set -U fish_pager_color_description magenta # color for meta description
set -U fish_pager_color_prefix blue # the string being completed
set -U fish_pager_color_progress white\x1e\x2d\x2dbackground\x3d333 # status indicator at the bottom
# set -U fish_pager_color_secondary \x2d\x2dbackground\x3d181818 # alternating rows
function has_command --wraps=command --description "Exits non-zero if the given command cannot be found"
command --quiet --search $argv[1]
end
'';
# TODO: load vars, colors, functions
# TODO: rtx?
# TODO: homebrew?
# TODO: asdf?
# TODO: direnv?
# TODO: prompt and key bindings
# TODO: pass and pass-otp
# TODO: kitty integration
# TODO: NICE_HOME?
# TODO: zellij and/or tmux?
functions = {
d = ''
# --wraps=cd --description "Quickly jump to NICE_HOME (or given relative or absolute path) and list files."
if count $argv > /dev/null
cd $argv
else
cd $NICE_HOME
end
la
'';
c = ''
if count $argv > /dev/null
cd $NICE_HOME && d $argv
else
d $NICE_HOME
end
'';
g = ''
if count $argv > /dev/null
git $argv
else
git status
end
'';
ltl = ''
set d $argv[1] .
set -l l ""
for f in $d[1]/*
if test -z $l; set l $f; continue; end
if command test $f -nt $l; and test ! -d $f
set l $f
end
end
echo $l
'';
};
interactiveShellInit = ''
# prompt
function get_hostname
if test (uname) = Linux || test (uname) = Darwin
has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname
else
# assume bsd
hostname | head -n 1 | cut -d. -f1
end
end
function fish_greeting
_prompt_prefix
printf "%s\n" (date)
end
function preprocess_pwd
test (pwd) = / && echo "/" && return 1
test (pwd) = $NICE_HOME && echo "~" && return 0
pwd \
| cut -c2- \
| gawk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.3s",p[i]}}}'
end
function _maybe_sudo_prefix
if set -q SUDO_USER
set_color -b yellow black
printf " SUDO "
set_color -b normal normal
printf " "
end
end
function _maybe_aws_profile
if set -q AWS_PROFILE && test $AWS_PROFILE = prd
printf " "
set_color -b yellow black
printf " AWS_PROFILE=prd "
set_color -b normal normal
end
end
function _user_and_host
if test $argv[1] -eq 0
set_color -b normal blue
else
set_color -b normal red
end
printf "%s@%s" $USER (get_hostname)
end
function _cur_work_dir
set_color -b normal magenta
printf " %s" (preprocess_pwd)
end
function _last_cmd_duration
set_color -b normal green
set -q CMD_DURATION && printf " %dms" $CMD_DURATION
end
function _maybe_jobs_summary
if jobs -q
set_color -b normal cyan
printf " &%d" (jobs -p | wc -l)
end
end
function _user_prompt
printf "\n"
set_color brblack
if test (id -u) -eq 0
printf '# '
else
printf '$ '
end
set_color -b normal normal
end
function _maybe_git_summary
set_color -b normal yellow
set cur_sha (git rev-parse --short HEAD 2>/dev/null)
if test $status = 0
set num_changes (git status --porcelain | wc -l | string trim)
if test $num_changes = 0
set num_changes ""
else
set num_changes "+$num_changes"
end
printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes
end
end
function _prompt_marker
printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c"
end
function _prompt_continuation_marker
printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c"
end
function cmd_marker --on-variable _
printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c"
end
function _prompt_prefix
set_color -b normal brblack
printf "# "
end
function fish_prompt
set last_cmd_status $status
_prompt_marker
_prompt_prefix
_maybe_sudo_prefix
_user_and_host $last_cmd_status
_cur_work_dir
_maybe_git_summary
_maybe_aws_profile
_last_cmd_duration
_maybe_jobs_summary
_user_prompt
end
function fish_mode_prompt; end
function fish_right_prompt; end
set normal_mode "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end"
bind -M insert \cg skim-cd-widget
bind -M insert jk $normal_mode
bind -M insert jK $normal_mode
bind -M insert Jk $normal_mode
bind -M insert JK $normal_mode
bind -M insert jj $normal_mode
bind -M insert jJ $normal_mode
bind -M insert Jj $normal_mode
bind -M insert JJ $normal_mode
bind -M insert \cp up-or-search
bind -M insert \cn down-or-search
bind -M insert \ce end-of-line
bind -M insert \ca beginning-of-line
bind -M insert \cv edit_command_buffer
bind -M default \cv edit_command_buffer
'';
loginShellInit = ''
'';
shellAbbrs = { };
shellAliases = {
l = "br";
ls = "exa --group-directories-first --classify";
la = "exa -la --group-directories-first --classify";
lA = "exa -la --all --group-directories-first --classify";
tree = "exa --tree --level=3";
lt = "exa -l --sort=modified";
lat = "exa -la --sort=modified";
lc = "lt --sort=accessed";
lT = "lt --reverse";
lC = "lc --reverse";
lD = "la --only-dirs";
"cd.." = "d ..";
"cdd" = "d $DOTFILES_PATH";
"cde" = "d $XDG_CONFIG_HOME/lytedev-env";
"cdc" = "d $XDG_CONFIG_HOME";
"cdn" = "d $NOTES_PATH";
"cdl" = "d $XDG_DOWNLOAD_DIR";
"cdg" = "d $XDG_GAMES_DIR";
".." = "d ..";
"..." = "d ../..";
"...." = "d ../../..";
"....." = "d ../../../..";
"......" = "d ../../../../..";
"......." = "d ../../../../../..";
"........" = "d ../../../../../../..";
"........." = "d ../../../../../../../..";
cat = "bat";
dc = "docker compose";
k = "kubectl";
kg = "kubectl get";
v = "$EDITOR";
sv = "sudo $EDITOR";
kssh = "kitty +kitten ssh";
};
};
programs.exa.enable = true;
# TODO: move all fish config into here so that this will work?
programs.skim = {
enable = true;
enableFishIntegration = true;
};
programs.nix-index = {
enable = true;
@ -38,27 +382,29 @@
};
extraConfig = ''
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref
("toolkit.legacyUserProfileCustomizations.stylesheets",
true);
// user_pref("full-screen-api.ignore-widgets", true);
user_pref("media.ffmpeg.vaapi.enabled", true);
user_pref("media.rdd-vpx.enabled", true);
'';
userChrome = ''
/* Remove close button*/ .titlebar-buttonbox-container{ display:none }
/* Remove close button*/ .titlebar-buttonbox-container{ display:none }
#webrtcIndicator {
display: none;
display: none;
}
#main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar>.toolbar-items {
opacity: 0;
pointer-events: none;
opacity: 0;
pointer-events: none;
}
#main-window:not([tabsintitlebar="true"]) #TabsToolbar {
visibility: collapse !important;
}
visibility: collapse !important;
}
'';
# userContent = ''

View file

@ -56,11 +56,11 @@
]
},
"locked": {
"lastModified": 1690739034,
"narHash": "sha256-roW02IaiQ3gnEEDMCDWL5YyN+C4nBf/te6vfL7rG0jk=",
"lastModified": 1692199161,
"narHash": "sha256-GqKApvQ1JCf5DzH/Q+P4nwuHb6MaQGaWTu41lYzveF4=",
"owner": "nix-community",
"repo": "disko",
"rev": "4015740375676402a2ee6adebc3c30ea625b9a94",
"rev": "4eed2457b053c4bbad7d90d2b3a1d539c2c9009c",
"type": "github"
},
"original": {
@ -152,11 +152,11 @@
]
},
"locked": {
"lastModified": 1687871164,
"narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=",
"lastModified": 1692099905,
"narHash": "sha256-/pSusGhmIdSdAaywQRFA5dVbfdIzlWQTecM+E46+cJ0=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38",
"rev": "2a6679aa9cc3872c29ba2a57fe1b71b3e3c5649f",
"type": "github"
},
"original": {
@ -184,11 +184,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1690066826,
"narHash": "sha256-6L2qb+Zc0BFkh72OS9uuX637gniOjzU6qCDBpjB2LGY=",
"lastModified": 1692492726,
"narHash": "sha256-rld5qm2B4oRkDwcPD+yOSyTrZQdfCR6mzJGGkecjvTs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ce45b591975d070044ca24e3003c830d26fea1c8",
"rev": "5e63e8bbc46bc4fc22254da1edaf42fc7549c18a",
"type": "github"
},
"original": {
@ -200,11 +200,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1691252436,
"narHash": "sha256-SKKPKYOnFcwqECehxoFBMLv29CZXC5qCDuETSuXd82g=",
"lastModified": 1692794066,
"narHash": "sha256-H0aG8r16dj0x/Wz6wQhQxc9V7AsObOiHPaKxQgH6Y08=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9607b9149c9d81fdf3dc4f3bcc278da146ffbd77",
"rev": "fc944919f743bb22379dddf18dcb72db6cff84aa",
"type": "github"
},
"original": {
@ -257,11 +257,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1690199016,
"narHash": "sha256-yTLL72q6aqGmzHq+C3rDp3rIjno7EJZkFLof6Ika7cE=",
"lastModified": 1692728678,
"narHash": "sha256-02MjG7Sb9k7eOi86CcC4GNWVOjT6gjmXFSqkRjZ8Xyk=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "c36df4fe4bf4bb87759b1891cab21e7a05219500",
"rev": "1b7b3a32d65dbcd69c217d7735fdf0a6b2184f45",
"type": "github"
},
"original": {

View file

@ -78,6 +78,11 @@ in
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
];
};
programs.sway = {
@ -213,7 +218,6 @@ in
ripgrep
rsync
sd
skim
slurp
sops
steam
@ -332,10 +336,10 @@ in
};
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 22 ];
networking.firewall.allowedUDPPorts = [ ];
# networking.firewall.allowedTCPPorts = [ 22 ];
# networking.firewall.allowedUDPPorts = [ ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions