diff --git a/.editorconfig b/.editorconfig index 91626bc..e84b7cb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,13 +1,13 @@ root = true [*] -indent_style = space indent_size = 2 -max_line_length = 100 -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_style = space +max_line_length = 100 insert_final_newline = false +trim_trailing_whitespace = true [*.{md}] trim_trailing_whitespace = false diff --git a/darwin.nix b/darwin.nix index 5d01be6..8338871 100644 --- a/darwin.nix +++ b/darwin.nix @@ -17,6 +17,7 @@ nix-darwin.lib.darwinSystem rec { inherit system; modules = [ ./modules/1password.nix + ./modules/openssh.nix ./modules/darwin.nix ./modules/fonts.nix ./modules/nix.nix @@ -25,6 +26,10 @@ nix-darwin.lib.darwinSystem rec { # home-manager.darwinModules.home-manager { + users.users.o = { + name = "o"; + home = "/Users/o"; + }; home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -32,8 +37,6 @@ nix-darwin.lib.darwinSystem rec { name = "o"; home = "/Users/o"; imports = [ - # TODO: check do I need this - { home.stateVersion = "23.11"; } ./home-modules/tmux ./home-modules/kitty ./home-modules/helix @@ -44,6 +47,7 @@ nix-darwin.lib.darwinSystem rec { ./home-modules/home.nix ./home-modules/fonts.nix ./home-modules/direnv.nix + ./home-modules/darwin.nix ./home-modules/shells/bash ./home-modules/shells/fish ./home-modules/lazygit.nix diff --git a/flake.nix b/flake.nix index 2d92539..e636152 100644 --- a/flake.nix +++ b/flake.nix @@ -111,8 +111,8 @@ system nixpkgs ghostty - overlays zjstatus + overlays catppuccin nix-darwin home-manager diff --git a/home-modules/darwin.nix b/home-modules/darwin.nix new file mode 100644 index 0000000..8f37886 --- /dev/null +++ b/home-modules/darwin.nix @@ -0,0 +1,33 @@ +{ + lib, + pkgs, + config, + inputs, + ... +}: +{ + home = { + stateVersion = "22.05"; + + packages = with pkgs; [ + jq + fd + gh + fzf + git + tree + btop + ripgrep + ]; + + # Hide "last login" message on new terminal. + file.".hushlogin".text = ""; + + # programs.ssh doesn't work well for darwin. + file.".ssh/config".text = '' + Host * + AddKeysToAgent yes + Include ~/.orbstack/ssh/config + ''; + }; +} diff --git a/home-modules/ghostty/default.nix b/home-modules/ghostty/default.nix index 6395655..f23133e 100644 --- a/home-modules/ghostty/default.nix +++ b/home-modules/ghostty/default.nix @@ -5,18 +5,32 @@ in { home.file."${ghosttyPath}/config".text = '' title = " " + macos-titlebar-proxy-icon = hidden + + auto-update = download + font-size = "18" - theme = tokyonight - window-padding-x = 16 + font-family = "BlexMono Nerd Font Mono" + + + foreground = ffffff + theme = "tokyonight" + + window-padding-x = 12 window-padding-y = 16 + keybind = super+t=ignore + + keybind = cmd+t=new_tab + keybind = cmd+k=clear_screen + shell-integration = fish - font-family = "BlexMono Nerd Font Mono" - keybind = ctrl+z=close_surface - mouse-hide-while-typing = true + macos-option-as-alt = true shell-integration-features = sudo,no-title + + keybind = ctrl+z=close_surface mouse-hide-while-typing = false + macos-non-native-fullscreen = true keybind = ctrl+super+f=toggle_fullscreen - term = xterm-ghostty ''; } diff --git a/home-modules/shells/fish/functions/mkcd.fish b/home-modules/shells/fish/functions/mkcd.fish index 0277dd6..d60d484 100644 --- a/home-modules/shells/fish/functions/mkcd.fish +++ b/home-modules/shells/fish/functions/mkcd.fish @@ -1,11 +1,11 @@ function mkdir -d "Create a directory and set CWD" - command mkdir $argv - if test $status = 0 - switch $argv[(count $argv)] - case '-*' - case '*' - cd $argv[(count $argv)] - return + command mkdir $argv + if test $status = 0 + switch $argv[(count $argv)] + case '-*' + case '*' + cd $argv[(count $argv)] + return + end end - end end diff --git a/home-modules/shells/fish/functions/nurlol.fish b/home-modules/shells/fish/functions/nurlol.fish index da2d5b0..dc40e6e 100644 --- a/home-modules/shells/fish/functions/nurlol.fish +++ b/home-modules/shells/fish/functions/nurlol.fish @@ -11,5 +11,7 @@ function nurlol --description "Get the nurl output and copy to clipboard. Usage: # set the command to a variable: "nurl https://github.com/$user/$repo 2>/dev/null" set -l nurlol_command "nurl https://github.com/$user/$repo 2>/dev/null" # Execute the command, copy to clipboard using pbcopy, and print the command - set -l nurlol_output (eval $nurlol_command); echo $nurlol_output | pbcopy; echo $nurlol_output + set -l nurlol_output (eval $nurlol_command) + echo $nurlol_output | pbcopy + echo $nurlol_output end diff --git a/home-modules/shells/fish/functions/ssh_agent_start.fish b/home-modules/shells/fish/functions/ssh_agent_start.fish index 6f6f1e8..d726808 100644 --- a/home-modules/shells/fish/functions/ssh_agent_start.fish +++ b/home-modules/shells/fish/functions/ssh_agent_start.fish @@ -2,17 +2,17 @@ # if it does not exist, create the file setenv SSH_ENV $HOME/.ssh/environment -function start_agent +function start_agent echo "Initializing new SSH agent ..." - ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV - echo "succeeded" - chmod 600 $SSH_ENV - . $SSH_ENV > /dev/null + ssh-agent -c | sed 's/^echo/#echo/' >$SSH_ENV + echo succeeded + chmod 600 $SSH_ENV + . $SSH_ENV >/dev/null ssh-add end -function test_identities - ssh-add -l | grep "The agent has no identities" > /dev/null +function test_identities + ssh-add -l | grep "The agent has no identities" >/dev/null if [ $status -eq 0 ] ssh-add if [ $status -eq 2 ] @@ -21,19 +21,19 @@ function test_identities end end -if [ -n "$SSH_AGENT_PID" ] - ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null +if [ -n "$SSH_AGENT_PID" ] + ps -ef | grep $SSH_AGENT_PID | grep ssh-agent >/dev/null if [ $status -eq 0 ] test_identities - end + end else if test -f $SSH_ENV - source $SSH_ENV > /dev/null + source $SSH_ENV >/dev/null end - ps -ef | string match -e $SSH_AGENT_PID | string match -v grep | string match -e ssh-agent > /dev/null + ps -ef | string match -e $SSH_AGENT_PID | string match -v grep | string match -e ssh-agent >/dev/null if test $status -eq 0 test_identities - else + else start_agent end -end \ No newline at end of file +end diff --git a/home-modules/shells/fish/functions/yazi.fish b/home-modules/shells/fish/functions/yazi.fish deleted file mode 100644 index 7fa8a80..0000000 --- a/home-modules/shells/fish/functions/yazi.fish +++ /dev/null @@ -1,8 +0,0 @@ -function yy - set tmp (mktemp -t "yazi-cwd.XXXXXX") - yazi $argv --cwd-file="$tmp" - if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] - builtin cd -- "$cwd" - end - rm -f -- "$tmp" -end diff --git a/home-modules/shells/fish/init.fish b/home-modules/shells/fish/init.fish index 8ba3e56..e9ee2de 100644 --- a/home-modules/shells/fish/init.fish +++ b/home-modules/shells/fish/init.fish @@ -48,3 +48,8 @@ set -Ux BAT_THEME 1337 # forgit set -x PATH $PATH $FORGIT_INSTALL_DIR/bin set -Ux FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS '--sort=-committerdate' + +# if `uname -r` result contains `orbstack`, add alias `xdg-open` to `open` +if uname -r | rga --quiet orbstack + alias xdg-open open +end diff --git a/justfile b/justfile index b5f5640..ce3d852 100644 --- a/justfile +++ b/justfile @@ -48,6 +48,7 @@ lint: fmt: just --fmt --unstable yamlfmt . --formatter + fish_indent --write **/*.fish nixfmt *.nix **/*.nix **/**/*.nix --width=100 fml: fmt lint diff --git a/modules/openssh.nix b/modules/openssh.nix index ca22261..7021334 100644 --- a/modules/openssh.nix +++ b/modules/openssh.nix @@ -8,6 +8,9 @@ _: { ''; authorizedKeysFiles = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJNMtRVUTD0g9VNsHXK3EpDrgyndSAFbLqNmTEtJRfJI" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJweyVEQv8a6t9p4magdhQcah9yqADTxkkG5+svwSkBL" + + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNyROH/lWSYGnwkMmmDqsjIFjo4zv/N4HHQS9GVxPLn" ]; settings = { X11Forwarding = true; diff --git a/modules/users.nix b/modules/users.nix index b79c92f..159fda9 100644 --- a/modules/users.nix +++ b/modules/users.nix @@ -22,6 +22,8 @@ hashedPassword = "$y$j9T$dHqYv21jcB7S3jBrqffWx1$xUqbav37bG7iWc2A1bFUvPrwTB8.wCUXCZdm1QNb5n2"; openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJNMtRVUTD0g9VNsHXK3EpDrgyndSAFbLqNmTEtJRfJI" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJweyVEQv8a6t9p4magdhQcah9yqADTxkkG5+svwSkBL" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNyROH/lWSYGnwkMmmDqsjIFjo4zv/N4HHQS9GVxPLn" ]; };