Switch to home manager and move off of ohmyzsh

This commit is contained in:
2024-12-03 20:55:46 -08:00
parent e73044a1ca
commit afcb55d5c4
14 changed files with 277 additions and 152 deletions

27
aliases
View File

@@ -1,27 +0,0 @@
# Git
alias gcl='git clone'
alias gp='git push'
alias gs='git status'
# ls
alias ll='ls -alh'
# System Utils
alias brewup='cl && brew update && brew upgrade && brew upgrade --cask && brew cleanup -s && brew doctor --verbose | grep -A 1 --color=never "Homebrew Version" && brew autoremove'
alias cl='clear'
alias ta="tmux a -t"
alias tn="tmux new-session -s"
alias gcc="gcc -g"
alias wthr='curl wttr.in/san_luis_obispo'
alias nf='cl && neofetch && shownetinfo && batt'
alias hekate='python3 /Users/smparkin/Development/fusee-launcher/fusee-launcher.py /Users/smparkin/Development/fusee-launcher/hekate/hekate.bin'
alias src='omz reload'
alias python='python3'
# Music
alias amp='python3 ~/Developer/abandoned/SSiTerm/music.py play'
alias amn='python3 ~/Developer/abandoned/SSiTerm/music.py next'
alias amr='python3 ~/Developer/abandoned/SSiTerm/music.py prev'
alias amv='python3 ~/Developer/abandoned/SSiTerm/music.py playback --volume '
alias fps='[[ $(launchctl getenv MTL_HUD_ENABLED) -eq 1 ]]&&launchctl unsetenv MTL_HUD_ENABLED||launchctl setenv MTL_HUD_ENABLED 1'

View File

@@ -1,65 +0,0 @@
function my_git_prompt() {
tester=$(git rev-parse --git-dir 2> /dev/null) || return
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
# is branch behind?
if $(echo "$(git log HEAD..origin/$(git_current_branch) 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
# is anything staged?
if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi
# is anything unstaged?
if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
# is anything untracked?
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
# is anything unmerged?
if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
if [[ -n $STATUS ]]; then
STATUS=" $STATUS"
fi
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function my_current_branch() {
echo $(git_current_branch || echo "(no branch)")
}
function ssh_connection() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%{$fg_bold[red]%}(ssh) "
fi
}
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
PROMPT=$'$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : $(shrink_path -f)\n[${ret_status}]  '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white] %{$fg_bold[yellow]%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg_bold[green]%}↓"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕"
ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]%{$reset_color%}"

33
nix/flake.lock generated
View File

@@ -35,6 +35,26 @@
"type": "github" "type": "github"
} }
}, },
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1733175814,
"narHash": "sha256-zFOtOaqjzZfPMsm1mwu98syv3y+jziAq5DfWygaMtLg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "bf23fe41082aa0289c209169302afd3397092f22",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -42,11 +62,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1732603785, "lastModified": 1733047432,
"narHash": "sha256-AEjWTJwOmSnVYsSJCojKgoguGfFfwel6z/6ud6UFMU8=", "narHash": "sha256-fQUKxgxAEHlL5bevRkdsQB7sSpAMhlvxf7Zw0KK8QIg=",
"owner": "LnL7", "owner": "LnL7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "6ab87b7c84d4ee873e937108c4ff80c015a40c7a", "rev": "e30a3622b606dffc622305b4bbe1cfe37e78fa40",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -125,11 +145,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1732238832, "lastModified": 1733024928,
"narHash": "sha256-sQxuJm8rHY20xq6Ah+GwIUkF95tWjGRd1X8xF+Pkk38=", "narHash": "sha256-n/DOfpKH1vkukuBnach91QBQId2dr5tkE7/7UrkV2zw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8edf06bea5bcbee082df1b7369ff973b91618b8d", "rev": "2c27ab2e60502d1ebb7cf38909de38663f762a79",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -141,6 +161,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-homebrew": "nix-homebrew", "nix-homebrew": "nix-homebrew",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"

View File

@@ -6,9 +6,11 @@
nix-darwin.url = "github:LnL7/nix-darwin"; nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew }: outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager }:
let let
configuration = { pkgs, config, ... }: { configuration = { pkgs, config, ... }: {
@@ -20,8 +22,14 @@
[ [
pkgs.fastfetch pkgs.fastfetch
pkgs.coreutils pkgs.coreutils
pkgs.nmap
pkgs.openjdk17 pkgs.openjdk17
pkgs.openjdk21 pkgs.openjdk21
pkgs.tree
pkgs.zstd
# zsh plugins
pkgs.zsh-autosuggestions
pkgs.zsh-syntax-highlighting
]; ];
homebrew = { homebrew = {
@@ -49,6 +57,7 @@
"scroll-reverser" "scroll-reverser"
"sf-symbols" "sf-symbols"
"steam" "steam"
"utm"
"visual-studio-code" "visual-studio-code"
]; ];
brews = [ brews = [
@@ -69,7 +78,7 @@
"TheUnarchiver" = 425424353; "TheUnarchiver" = 425424353;
"Unread" = 1363637349; "Unread" = 1363637349;
"WiFiMan" = 1385561119; "WiFiMan" = 1385561119;
"Wipr" = 1320666476; "Wipr2" = 1662217862;
"WireGuard" = 1451685025; "WireGuard" = 1451685025;
"Xcode" = 497799835; "Xcode" = 497799835;
}; };
@@ -85,6 +94,8 @@
# Necessary for using flakes on this system. # Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes"; nix.settings.experimental-features = "nix-command flakes";
# Defaults
security.pam.enableSudoTouchIdAuth = true;
system.defaults = { system.defaults = {
dock.autohide = true; dock.autohide = true;
trackpad.Clicking = true; trackpad.Clicking = true;
@@ -100,6 +111,12 @@
# The platform the configuration will be used on. # The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin"; nixpkgs.hostPlatform = "aarch64-darwin";
programs.zsh.enable = true;
# Home Manager
users.users.smparkin.home = "/Users/smparkin";
nix.configureBuildUsers = true;
nix.useDaemon = true;
}; };
in in
{ {
@@ -114,13 +131,39 @@
enable = true; enable = true;
enableRosetta = true; enableRosetta = true;
user = "smparkin"; user = "smparkin";
autoMigrate = true; };
}
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.smparkin = import ./home.nix;
}; };
} }
]; ];
}; };
# Expose the package set, including overlays, for convenience. darwinConfigurations."workbook" = nix-darwin.lib.darwinSystem {
darwinPackages = self.darwinConfigurations."macbook".pkgs; modules = [
configuration
nix-homebrew.darwinModules.nix-homebrew
{
nix-homebrew = {
enable = true;
enableRosetta = true;
user = "parkist";
};
}
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.parkist = import ./work.nix;
};
}
];
};
}; };
} }

33
nix/home.nix Normal file
View File

@@ -0,0 +1,33 @@
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "smparkin";
home.homeDirectory = "/Users/smparkin";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "24.11";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# Home dir
home.file = {
".zshrc".source = ../zsh/zshrc;
".zsh.d/aliases".source = ../zsh/aliases;
".zsh.d/functions".source = ../zsh/functions;
".zsh.d/theme".source = ../zsh/theme;
".gitconfig".source = ../git/gitconfig;
".gitignore_global".source = ../git/gitignore_global;
".tmux.conf".source = ../tmux/tmux.conf;
".vimrc".source = ../vim/vimrc;
};
}

View File

21
zsh/aliases Normal file
View File

@@ -0,0 +1,21 @@
# Git
alias gcl='git clone'
alias gp='git push'
alias gs='git status'
# ls
alias ll='ls -lah'
alias l='ls -CF'
# System Utils
alias rebuild='darwin-rebuild switch --flake ~/dotfiles/nix#macbook'
alias cl='clear'
alias wthr='curl wttr.in/san_luis_obispo'
alias nf='cl && fastfetch && shownetinfo && batt'
alias src='source ~/.zshrc'
alias fps='if [[ $(launchctl getenv MTL_HUD_ENABLED) -eq 1 ]]; then
launchctl unsetenv MTL_HUD_ENABLED && echo "Metal FPS disabled"
else
launchctl setenv MTL_HUD_ENABLED 1 && echo "Metal FPS enabled"
fi'

72
zsh/theme Normal file
View File

@@ -0,0 +1,72 @@
git_branch_info() {
local git_status_full=$(git status --porcelain=v2 --branch -z 2>/dev/null)
[[ -n "$git_status_full" ]] || return
local branch=""
local status_indicators=""
local line
local -a status_lines=("${(0)git_status_full}")
for line in $status_lines; do
case $line in
\#' 'branch.head' '*) branch=${line##* }; continue ;;
\#' 'branch.ab' '*)
local -a counts=("${(s: :)line}")
[[ ${counts[3]#+} -gt 0 ]] && status_indicators+="%B%F{magenta}↑%f%b"
[[ ${counts[4]#+} -gt 0 ]] && status_indicators+="%B%F{green}↓%f%b"
;;
'?'*) ((untracked)) || { untracked=1; status_indicators+="%B%F{white}●%f%b" } ;;
'u'*) ((unmerged)) || { unmerged=1; status_indicators+="%B%F{red}✕%f%b" } ;;
[12]' '*)
if [[ ${line[3]} != "." && $staged -eq 0 ]]; then
staged=1
status_indicators+="%B%F{green}●%f%b"
fi
if [[ ${line[4]} != "." && $unstaged -eq 0 ]]; then
unstaged=1
status_indicators+="%B%F{red}●%f%b"
fi
;;
esac
done
[[ -n "$branch" ]] && echo " %B%F{white} %B%F{yellow}${branch}%f${status_indicators:+ $status_indicators}%B%F{white}%f "
}
local CACHED_PWD=""
local CACHED_SHORT_PWD=""
shrink_path() {
if [[ $CACHED_PWD != $PWD ]]; then
CACHED_PWD=$PWD
local directory=${PWD/#$HOME/\~}
if [[ $directory == '~' || $directory == '/' ]]; then
CACHED_SHORT_PWD=$directory
echo $CACHED_SHORT_PWD
return
fi
local parts=("${(@s:/:)directory}")
local output=()
for part in $parts[1,-2]; do
if [[ -n $part && $part != "~" ]]; then
output+=$part[1]
else
output+=$part
fi
done
output+=$parts[-1]
CACHED_SHORT_PWD=${(j:/:)output}
fi
echo $CACHED_SHORT_PWD
}
# SSH connection indicator
ssh_connection() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%B%F{red}(ssh)%f%b "
fi
}
# Prompt configuration
PROMPT='$(ssh_connection)%B%F{green}%n@%m%f%b$(git_branch_info) %f%b: $(shrink_path)
[%(?:%B%F{green}%?%f%b:%B%F{red}%?%f%b)]  '
setopt PROMPT_SUBST

76
zsh/zshrc Normal file
View File

@@ -0,0 +1,76 @@
# Get basic stuff out of the way
source ~/.zsh.d/theme
source ~/.zsh.d/functions
source ~/.zsh.d/aliases
# History search with started text
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search # Up arrow
bindkey "^[[B" down-line-or-beginning-search # Down arrow
# Initialize completion system
autoload -U compinit && compinit
# Case insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# Menu selection for completion
zstyle ':completion:*' menu select
zstyle ':completion:*' file-sort name
zstyle ':completion:*' list-colors ''
bindkey '^[[Z' reverse-menu-complete
# Configure history to be longer
HISTSIZE=10000000
SAVEHIST=10000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
# Use vim as editor
export EDITOR=vim
export VISUAL=vim
# Enable colors in ls
export CLICOLOR=1
# For Linux/BSD ls colors
if whence dircolors >/dev/null; then
eval "$(dircolors -b)"
alias ls='ls --color=auto'
else
# For macOS ls colors
export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd
alias ls='ls -G'
fi
shownetinfo
if [ "$OSTYPE" = "Linux" ]; then
echo ""
elif [ "$OSTYPE" = "Darwin" ]; then
# set up iterm integration
source ~/.iterm2_shell_integration.zsh
# set up auto suggestions and syntax highlighting
source /nix/store/*zsh-autosuggestions*/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /nix/store/*zsh-syntax-highlighting*/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ssh-add -K ~/.ssh/id_rsa 2>/dev/null
LAPTOP=$(system_profiler SPHardwareDataType | grep "Model Name" | grep "Book")
if [ "$LAPTOP" != "" ]; then
batt
else
echo ""
fi
fi

49
zshrc
View File

@@ -1,49 +0,0 @@
# Path to your oh-my-zsh installation.
OSTYPE=$(uname -s)
if [ "$OSTYPE" = "Linux" ]; then
export ZSH="/home/smparkin/.oh-my-zsh"
elif [ "$OSTYPE" = "Darwin" ]; then
export ZSH="/Users/smparkin/.oh-my-zsh"
fi
# Set name of the theme to load
ZSH_THEME="newstephen"
# Hyphen-insensitive completion
HYPHEN_INSENSITIVE="true"
# Disable marking untracked files under git as dirty
DISABLE_UNTRACKED_FILES_DIRTY="true"
# Which plugins would you like to load?
plugins=(
colored-man-pages
iterm2
zsh-navigation-tools
shrink-path
)
source $ZSH/oh-my-zsh.sh
source ~/.zsh.d/functions
source ~/.zsh.d/aliases
if [ "$OSTYPE" = "Darwin" ]; then
source ~/.iterm2_shell_integration.zsh
fi
if [ "$OSTYPE" = "Darwin" ]; then
export EDITOR="/usr/bin/vim"
fi
shownetinfo
if [ "$OSTYPE" = "Linux" ]; then
echo ""
elif [ "$OSTYPE" = "Darwin" ]; then
ssh-add -K ~/.ssh/id_rsa 2>/dev/null
LAPTOP=$(system_profiler SPHardwareDataType | grep "Model Name" | grep "Book")
if [ "$LAPTOP" != "" ]; then
batt
else
echo ""
fi
fi