Skip to content

Commit

Permalink
feat: darwin ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Nov 30, 2024
1 parent 8bb71b1 commit 55d205d
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,15 +26,17 @@ nix-darwin.lib.darwinSystem rec {
#
home-manager.darwinModules.home-manager
{
users.users.o = {
name = "o";
home = "/Users/o";
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.o = {
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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
system
nixpkgs
ghostty
overlays
zjstatus
overlays
catppuccin
nix-darwin
home-manager
Expand Down
33 changes: 33 additions & 0 deletions home-modules/darwin.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
26 changes: 20 additions & 6 deletions home-modules/ghostty/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
}
16 changes: 8 additions & 8 deletions home-modules/shells/fish/functions/mkcd.fish
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion home-modules/shells/fish/functions/nurlol.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 14 additions & 14 deletions home-modules/shells/fish/functions/ssh_agent_start.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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
end
8 changes: 0 additions & 8 deletions home-modules/shells/fish/functions/yazi.fish

This file was deleted.

5 changes: 5 additions & 0 deletions home-modules/shells/fish/init.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ lint:
fmt:
just --fmt --unstable
yamlfmt . --formatter
fish_indent --write **/*.fish
nixfmt *.nix **/*.nix **/**/*.nix --width=100

fml: fmt lint
Expand Down
3 changes: 3 additions & 0 deletions modules/openssh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ _: {
'';
authorizedKeysFiles = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJNMtRVUTD0g9VNsHXK3EpDrgyndSAFbLqNmTEtJRfJI"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJweyVEQv8a6t9p4magdhQcah9yqADTxkkG5+svwSkBL"

"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNyROH/lWSYGnwkMmmDqsjIFjo4zv/N4HHQS9GVxPLn"
];
settings = {
X11Forwarding = true;
Expand Down
2 changes: 2 additions & 0 deletions modules/users.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
};
Expand Down

0 comments on commit 55d205d

Please sign in to comment.