diff --git a/hosts/tuxcomp/default.nix b/hosts/tuxcomp/default.nix index 588c97b..7f451f4 100644 --- a/hosts/tuxcomp/default.nix +++ b/hosts/tuxcomp/default.nix @@ -19,6 +19,7 @@ }; hardware.tuxedo-drivers.enable = true; + # FIXME: this patch does not work # adds a `stretch_aspect` scaler (Valve/gamescope#927) and lets `--rt` use the # rtprio limit from modules/gaming.nix instead of CAP_SYS_NICE. # nixpkgs.overlays = [ diff --git a/modules/apps.nix b/modules/apps.nix index 78e65c7..94ff47c 100644 --- a/modules/apps.nix +++ b/modules/apps.nix @@ -59,6 +59,7 @@ yad brightnessctl grim + file tree ]; diff --git a/modules/base.nix b/modules/base.nix index a041885..04ad48b 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -53,22 +53,35 @@ vim ]; - # TODO: switch to home manager - # home-manager = { - # useGlobalPkgs = true; - # useUserPackages = true; - # extraSpecialArgs = { inherit inputs; }; - # # Move a file home-manager would overwrite aside instead of failing. - # backupFileExtension = "backup"; - # - # users.djai = { - # home.stateVersion = "26.05"; - # programs.home-manager.enable = true; - # - # # TODO: unified ssh-config secret - # home.file.".ssh/config".text = '' - # Include ${config.sops.secrets."ssh-config".path} - # ''; - # }; - # }; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { inherit inputs; }; + backupFileExtension = "bck"; + + users."djai" = { + programs.home-manager.enable = true; + + home.file.".ssh/config".text = '' + Include ${config.sops.secrets."ssh-config".path} + ''; + + home = { + stateVersion = "26.05"; + sessionPath = [ + "$HOME/bin" + "$HOME/.local/bin" + "$HOME/.cargo/bin" + "$HOME/Scripts" + ]; + + sessionVariables = { + NEWT_COLORS_FILE = "$HOME/.newtColours"; + BROWSER = "librewolf"; + EDITOR = "nvim"; + STARSHIP_LOG = "error"; + }; + }; + }; + }; } diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 56930e2..f2c5312 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -64,6 +64,7 @@ hyprpicker hyprsunset wf-recorder + grimblast wmctrl hyprprop hyprlandPlugins.hypr-darkwindow diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix index 93e4c00..59988c0 100644 --- a/modules/terminal/default.nix +++ b/modules/terminal/default.nix @@ -1,13 +1,18 @@ { pkgs, ... }: { + imports = [ + ./fish.nix + ./kitty.nix + ]; + environment.defaultPackages = with pkgs; [ fbterm kitty starship ]; - # TODO: switch to home manager + # keeping these here so root also benefits programs.fish.enable = true; programs.tmux = { enable = true; @@ -18,19 +23,4 @@ resurrect ]; }; - - # home-manager.users.djai = { - # programs.fish.enable = true; - # programs.tmux.enable = true; - # - # programs.kitty = { - # enable = true; - # settings = { - # shell = "${pkgs.tmux}/bin/tmux"; - # font_family = "Iosevka Nerd Font"; - # }; - # extraConfig = ""; # TODO theming - # }; - # - # }; } diff --git a/modules/terminal/fish-config/bulkpaste.fish b/modules/terminal/fish-config/bulkpaste.fish new file mode 100644 index 0000000..ce2404d --- /dev/null +++ b/modules/terminal/fish-config/bulkpaste.fish @@ -0,0 +1,8 @@ + case Hyprland + hyprctl dispatch 'hl.dsp.focus({ direction = "left" })' + for i in (ls | grep "$argv[1]") + sleep 0.05 + copy "$i" + sleep 0.05 + hyprctl dispatch 'hl.dsp.send_shortcut({ mods = "CTRL", key = "v" })' + end diff --git a/modules/terminal/fish-config/copy.fish b/modules/terminal/fish-config/copy.fish new file mode 100644 index 0000000..0d0cc9a --- /dev/null +++ b/modules/terminal/fish-config/copy.fish @@ -0,0 +1,6 @@ +switch "$XDG_SESSION_TYPE" + case wayland + echo "file://$(realpath -- "$argv")" | wl-copy -t text/uri-list + case x11 + echo "file://$(realpath -- "$argv")" | xclip -i -selection clipboard -t text/uri-list +end diff --git a/modules/terminal/fish-config/files.fish b/modules/terminal/fish-config/files.fish new file mode 100644 index 0000000..e81f031 --- /dev/null +++ b/modules/terminal/fish-config/files.fish @@ -0,0 +1,9 @@ +if test -z "$argv[1]" + set dir '.' +else + set dir "$argv[1]" +end +for i in (find "$dir" -maxdepth 1 -type d ) + set b (find "$i" -type f| wc -l) + printf "%d/%s\n" $b (basename "$i") +end | sort -nr | column -ts/ diff --git a/modules/terminal/fish-config/fmf.fish b/modules/terminal/fish-config/fmf.fish new file mode 100644 index 0000000..2f4b1d0 --- /dev/null +++ b/modules/terminal/fish-config/fmf.fish @@ -0,0 +1,4 @@ +set dest "$(fzf)" +if test $status -eq 0 + cd "$(realpath (dirname "$dest"))" +end diff --git a/modules/terminal/fish-config/histdelete.fish b/modules/terminal/fish-config/histdelete.fish new file mode 100644 index 0000000..8824e1e --- /dev/null +++ b/modules/terminal/fish-config/histdelete.fish @@ -0,0 +1,3 @@ +string match -qr '^(exit|ls$|clear)' -- $argv +and history delete --exact --case-sensitive -- (string trim -r $argv) + diff --git a/modules/terminal/fish-config/move.fish b/modules/terminal/fish-config/move.fish new file mode 100644 index 0000000..c34267d --- /dev/null +++ b/modules/terminal/fish-config/move.fish @@ -0,0 +1 @@ +rename.sh "$argv" diff --git a/modules/terminal/fish-config/nshell.fish b/modules/terminal/fish-config/nshell.fish new file mode 100644 index 0000000..cc6cf08 --- /dev/null +++ b/modules/terminal/fish-config/nshell.fish @@ -0,0 +1,5 @@ +if test -n "$argv" + eval "nix-shell --run fish -p" (string join -- " -p " $argv) +else + nix-shell --run fish +end diff --git a/modules/terminal/fish-config/ranger.fish b/modules/terminal/fish-config/ranger.fish new file mode 100644 index 0000000..3ff72eb --- /dev/null +++ b/modules/terminal/fish-config/ranger.fish @@ -0,0 +1,12 @@ + +set tempfile '/tmp/chosendir' +command ranger --choosedir=$tempfile (pwd) $argv + +if test -f $tempfile + if [ (cat $tempfile) != (pwd) ] + cd (cat $tempfile) + end +end + +rm -f $tempfile + diff --git a/modules/terminal/fish-config/run.fish b/modules/terminal/fish-config/run.fish new file mode 100644 index 0000000..5f088d5 --- /dev/null +++ b/modules/terminal/fish-config/run.fish @@ -0,0 +1,2 @@ +echo (cat -- "$argv") +fish -c (cat -- "$argv") diff --git a/modules/terminal/fish-config/runl.fish b/modules/terminal/fish-config/runl.fish new file mode 100644 index 0000000..c6ddd90 --- /dev/null +++ b/modules/terminal/fish-config/runl.fish @@ -0,0 +1,6 @@ +if test -n "$argv[2]" + echo (cat -- "$argv[1]" | sed -n $argv[2]p) + fish -c (cat -- "$argv[1]" | sed -n $argv[2]p) +else + cat -n -- "$argv[1]" +end diff --git a/modules/terminal/fish-config/secret.fish b/modules/terminal/fish-config/secret.fish new file mode 100644 index 0000000..005ed34 --- /dev/null +++ b/modules/terminal/fish-config/secret.fish @@ -0,0 +1,2 @@ +tr -dc A-Za-z0-9 /dev/null + end +end diff --git a/modules/terminal/fish-config/yazi.fish b/modules/terminal/fish-config/yazi.fish new file mode 100644 index 0000000..e524fba --- /dev/null +++ b/modules/terminal/fish-config/yazi.fish @@ -0,0 +1,10 @@ +set tempfile /tmp/chosendir +command yazi cwd-file=$tempfile (pwd) $argv + +if test -f $tempfile + if [ (cat $tempfile) != (pwd) ] + cd (cat $tempfile) + end +end + +rm -f $tempfile diff --git a/modules/terminal/fish.nix b/modules/terminal/fish.nix new file mode 100644 index 0000000..f8f0464 --- /dev/null +++ b/modules/terminal/fish.nix @@ -0,0 +1,87 @@ +{ config, lib, ... }: + +let + # automatically discover functions in the relative fish functions directory + fishFuncDir = ./fish-config/functions; + fishFuncs = lib.attrsets.mapAttrs' + (name: _: lib.nameValuePair (lib.strings.removeSuffix ".fish" "${name}") ({ + body = builtins.readFile (fishFuncDir + "/${name}"); + })) + (lib.attrsets.filterAttrs + (name: type: type == "regular") + (builtins.readDir fishFuncDir) + ); +in +{ + home-manager.users.djai.programs.fish = { + enable = true; + binds = { + "\cf" = { + command = "forward-char"; + mode = "insert"; + }; + "\ef" = { + command = "forward-word"; + mode = "insert"; + }; + }; + shellInit = '' + # start fbterm if in raw tty + if string match -qr "/dev/tty[2-9]" (tty) + fbterm -- env TERM=fbterm tmux new + end + + [ -d "$HOME/.cargo/env.fish" ] && source "$HOME/.cargo/env.fish" + ''; + + interactiveShellInit = '' + fish_vi_key_bindings + starship init fish | source + fish_config theme choose "Catppuccin Macchiato" + + if test -n "$TMUX" + ascii.sh + else + if test "$TERM" != "linux" + tmux new + end + end + + # make clear also remove scrollback on kitty + [ "(set -q TERM)" -a "$TERM" = "xterm-kitty" ] && alias clear "printf '\033[2J\033[3J\033[1;1H'" + ''; + + loginShellInit = '' + ~/Scripts/diaryEntry.sh > /dev/null # TODO: move to somewhere + ''; + + shellAbbrs = { + "webcam" = "mpv av://v4l2:/dev/video0 --profile=low-latency --untimed"; + "venv" = ". .venv/bin/activate.fish"; + "rug" = "sudo openconnect --protocol=gp safenet.vpn.rug.nl"; + "dia" = "nvim (date +%F)"; + + "rm" = "rm -I"; + "mv" = "mv -vn"; + "make" = "make -j8"; + + "ll" = "ls -hlav --ignore=.."; + "l" = "ls -lav --ignore=.\?\*"; + "la" = "ls -A"; + + "lg" = "lazygit"; + "fih" = "fish"; + "twi" = "twitch"; + "keh" = "kitten icat"; + }; + + # discovered functions + overrides + functions = fishFuncs // { + tmux-updater = fishFuncs.tmux-updater // {onEvent = "fish_preexec";}; + histdelete = fishFuncs.histdelete // {onEvent = "fish_postexec";}; + }; + }; + home-manager.users."djai".home.shell.enableFishIntegration = true; + + home.file.".config/fish/themes".source = config.lib.file.mkOutOfStoreSymLink ./fish-config/themes/; +} diff --git a/modules/terminal/kitty.nix b/modules/terminal/kitty.nix new file mode 100644 index 0000000..0132941 --- /dev/null +++ b/modules/terminal/kitty.nix @@ -0,0 +1,46 @@ +{ pkgs, ... }: + +{ + home-manager.users."djai".programs.kitty = { + enable = true; + keybindings = { + "ctrl+shift+t" = "new_tab_with_cwd"; + "ctrl+shift+enter" = "new_window_with_cwd"; + "ctrl+shift+b" = "detach_window"; + + "ctrl+j" = "neighboring_window down"; + "ctrl+k" = "neighboring_window up"; + "ctrl+h" = "neighboring_window left"; + "ctrl+l" = "neighboring_window right"; + + "ctrl+shift+n" = "new_os_window_with_cwd"; + }; + themeFile = "Catppuccin-Macchiato"; + + settings = { + shell = "${pkgs.fish}/bin/fish"; + font_family = "CaskaydiaCove Nerd Font Mono"; + close_on_child_death = true; + enable_audio_bell = false; + + window_padding_width = 6; + tab_bar_min_tabs = 1; + tab_bar_edge = "bottom"; + tab_bar_style = "powerline"; + tab_powerline_style = "slanted"; + tab_title_template = "{title}{' - {}'.format(num_windows) if num_windows > 1 else ''}"; + + allow_remote_control = "password"; + listen_on = "unix:@kitty"; + remote_control_password = " \"\" allow_safe.py"; # FIXME: seems to be borked on nixos + }; + }; + + home-manager.users."djai".home.file.".config/kitty/allow_safe.py".text = '' + #!/usr/bin/env python3 + def is_cmd_allowed(pcmd, window, from_socket, extra_data): + if pcmd['cmd'] == "launch": + return 'args' not in pcmd['payload'] + return False + ''; +}