mirror of
https://github.com/ryanccn/flake.git
synced 2025-12-06 08:10:43 +01:00
refactor: programs -> home
This commit is contained in:
parent
042cd345f9
commit
650542009d
21 changed files with 7 additions and 7 deletions
27
home/programs/aliases.nix
Normal file
27
home/programs/aliases.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"vim".command = "hx";
|
||||
"cat".command = "bat";
|
||||
"dig".command = "doggo";
|
||||
|
||||
"g".command = "git";
|
||||
"g".fishAlias = true;
|
||||
|
||||
"j".command = "just";
|
||||
"j".fishAlias = true;
|
||||
|
||||
"glol".command = "git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'";
|
||||
"glol".fishAlias = true;
|
||||
|
||||
"ghrvw".command = "gh repo view --web";
|
||||
|
||||
"opr".command = "op run --env-file=.env.1password --";
|
||||
"dr".command = "doppler run --";
|
||||
|
||||
"dequarantine".command = "xattr -d com.apple.quarantine";
|
||||
|
||||
"bcpa".command = "brew cleanup --prune=all";
|
||||
"puil".command = "pnpm update --interactive --latest";
|
||||
|
||||
"pip-upgrade-all".command = "pip --disable-pip-version-check list --outdated --format=json | python -c \"import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))\" | xargs -n1 pip install -U";
|
||||
"pip-upgrade-all".fishAlias = true;
|
||||
}
|
||||
10
home/programs/bat.nix
Normal file
10
home/programs/bat.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
_: {
|
||||
programs.bat = {
|
||||
enable = true;
|
||||
catppuccin.enable = true;
|
||||
|
||||
config = {
|
||||
style = "plain";
|
||||
};
|
||||
};
|
||||
}
|
||||
16
home/programs/eza.nix
Normal file
16
home/programs/eza.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{pkgs, ...}: let
|
||||
aliases = {
|
||||
eza = "eza --all --icons";
|
||||
ls = "eza";
|
||||
ll = "eza -l";
|
||||
la = "eza -a";
|
||||
lt = "eza --tree";
|
||||
lla = "eza -la";
|
||||
};
|
||||
in {
|
||||
home.packages = [pkgs.eza];
|
||||
|
||||
programs.bash.shellAliases = aliases;
|
||||
programs.zsh.shellAliases = aliases;
|
||||
programs.fish.shellAliases = aliases;
|
||||
}
|
||||
35
home/programs/fish.nix
Normal file
35
home/programs/fish.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{lib, ...}: let
|
||||
aliases = import ./aliases.nix;
|
||||
shellAbbrs = builtins.mapAttrs (_: a: a.command) (lib.filterAttrs (_: b: !(b.fishAlias or false)) aliases);
|
||||
shellAliases = builtins.mapAttrs (_: a: a.command) (lib.filterAttrs (_: b: builtins.hasAttr "fishAlias" b && b.fishAlias) aliases);
|
||||
in {
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
inherit shellAbbrs shellAliases;
|
||||
|
||||
functions = {
|
||||
take = ''
|
||||
set dir $argv[1]
|
||||
if test -z "$dir"
|
||||
return 1
|
||||
end
|
||||
|
||||
mkdir -p "$dir"
|
||||
cd "$dir"
|
||||
'';
|
||||
|
||||
code = ''
|
||||
if test -d "$argv[1]" -o -f "$argv[1]"
|
||||
open -a "Visual Studio Code" "$argv[1]"
|
||||
else
|
||||
command code $argv
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
home.file.".config/fish/conf.d" = {
|
||||
source = ./fish/conf.d;
|
||||
recursive = true;
|
||||
};
|
||||
}
|
||||
6
home/programs/fish/conf.d/01_basic_env.fish
Normal file
6
home/programs/fish/conf.d/01_basic_env.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# ls
|
||||
set -x LS_COLORS "$(vivid generate catppuccin-frappe)"
|
||||
|
||||
# nix path patches
|
||||
fish_add_path /run/current-system/sw/bin
|
||||
fish_add_path "/etc/profiles/per-user/$USER/bin"
|
||||
29
home/programs/fish/conf.d/02_tooling.fish
Normal file
29
home/programs/fish/conf.d/02_tooling.fish
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# 1Password SSH
|
||||
set -x SSH_AUTH_SOCK "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
|
||||
|
||||
# Homebrew shell
|
||||
/opt/homebrew/bin/brew shellenv | source
|
||||
|
||||
# fnm shell env
|
||||
fnm env --use-on-cd | source
|
||||
|
||||
# cargo
|
||||
fish_add_path "$HOME/.cargo/bin"
|
||||
# deno
|
||||
fish_add_path "$HOME/.deno/bin"
|
||||
|
||||
# pnpm
|
||||
set -x PNPM_HOME "$HOME/Library/pnpm"
|
||||
|
||||
# direnv
|
||||
set -x DIRENV_LOG_FORMAT ""
|
||||
|
||||
# docker
|
||||
fish_add_path "$HOME/.docker/bin"
|
||||
# local bin
|
||||
fish_add_path "$HOME/.local/bin"
|
||||
# nish
|
||||
fish_add_path "$HOME/dev/nish/bin"
|
||||
|
||||
# fish
|
||||
set fish_greeting
|
||||
19
home/programs/fish/conf.d/99_interactive.fish
Normal file
19
home/programs/fish/conf.d/99_interactive.fish
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
if status is-interactive
|
||||
# starship
|
||||
starship init fish | source
|
||||
# zoxide
|
||||
zoxide init fish | source
|
||||
# direnv
|
||||
direnv hook fish | source
|
||||
# nix-your-shell
|
||||
nix-your-shell fish | source
|
||||
|
||||
set -x FZF_DEFAULT_OPTS " \
|
||||
--color=bg+:#414559,bg:#303446,spinner:#f2d5cf,hl:#e78284 \
|
||||
--color=fg:#c6d0f5,header:#e78284,info:#ca9ee6,pointer:#f2d5cf \
|
||||
--color=marker:#f2d5cf,fg+:#c6d0f5,prompt:#ca9ee6,hl+:#e78284"
|
||||
|
||||
if test -e "$HOME/.iterm2_shell_integration.fish"
|
||||
source "$HOME/.iterm2_shell_integration.fish"
|
||||
end
|
||||
end
|
||||
31
home/programs/git.nix
Normal file
31
home/programs/git.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{pkgs, ...}: {
|
||||
programs.git = {
|
||||
enable = true;
|
||||
package = pkgs.gitAndTools.gitFull;
|
||||
|
||||
diff-so-fancy.enable = true;
|
||||
ignores = [
|
||||
".DS_Store"
|
||||
".direnv/"
|
||||
];
|
||||
|
||||
userName = "Ryan Cao";
|
||||
userEmail = "70191398+ryanccn@users.noreply.github.com";
|
||||
|
||||
extraConfig = {
|
||||
user.signingkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM4VfgP5+HdCmM/VpTcW8jLKLyR8s0qqoIDXv7iTnWlR";
|
||||
init.defaultBranch = "main";
|
||||
|
||||
commit.gpgsign = true;
|
||||
gpg.format = "ssh";
|
||||
"gpg \"ssh\"".program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
|
||||
|
||||
push.autoSetupRemote = true;
|
||||
};
|
||||
};
|
||||
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
gitCredentialHelper.enable = true;
|
||||
};
|
||||
}
|
||||
11
home/programs/go.nix
Normal file
11
home/programs/go.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
_: {
|
||||
programs.go = {
|
||||
enable = true;
|
||||
goPath = ".go";
|
||||
};
|
||||
|
||||
home.sessionVariables = {
|
||||
GOTOOLCHAIN = "path";
|
||||
GOPROXY = "direct";
|
||||
};
|
||||
}
|
||||
7
home/programs/helix.nix
Normal file
7
home/programs/helix.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
_: {
|
||||
programs.helix = {
|
||||
enable = true;
|
||||
catppuccin.enable = true;
|
||||
defaultEditor = true;
|
||||
};
|
||||
}
|
||||
8
home/programs/rust.nix
Normal file
8
home/programs/rust.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{pkgs, ...}: let
|
||||
inherit (pkgs) lib;
|
||||
toml = pkgs.formats.toml {};
|
||||
in {
|
||||
home.file.".cargo/config.toml".source = toml.generate "config.toml" {
|
||||
build.rustc-wrapper = lib.getExe' pkgs.sccache "sccache";
|
||||
};
|
||||
}
|
||||
89
home/programs/starship.nix
Normal file
89
home/programs/starship.nix
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
_: {
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
settings = {
|
||||
command_timeout = 1000;
|
||||
|
||||
character = {
|
||||
success_symbol = "[➜](bold green)";
|
||||
error_symbol = "[➜](bold red)";
|
||||
};
|
||||
|
||||
aws.symbol = " ";
|
||||
buf.symbol = " ";
|
||||
c.symbol = " ";
|
||||
conda.symbol = " ";
|
||||
dart.symbol = " ";
|
||||
directory.read_only = " ";
|
||||
docker_context.symbol = " ";
|
||||
elixir.symbol = " ";
|
||||
elm.symbol = " ";
|
||||
fossil_branch.symbol = " ";
|
||||
git_branch.symbol = " ";
|
||||
golang.symbol = " ";
|
||||
guix_shell.symbol = " ";
|
||||
haskell.symbol = " ";
|
||||
haxe.symbol = "⌘ ";
|
||||
hg_branch.symbol = " ";
|
||||
hostname.ssh_symbol = " ";
|
||||
java.symbol = " ";
|
||||
julia.symbol = " ";
|
||||
lua.symbol = " ";
|
||||
memory_usage.symbol = " ";
|
||||
meson.symbol = " ";
|
||||
nim.symbol = " ";
|
||||
nix_shell.symbol = " ";
|
||||
nodejs.symbol = " ";
|
||||
package.symbol = " ";
|
||||
pijul_channel.symbol = "🪺 ";
|
||||
python.symbol = " ";
|
||||
rlang.symbol = " ";
|
||||
ruby.symbol = " ";
|
||||
rust.symbol = " ";
|
||||
scala.symbol = " ";
|
||||
spack.symbol = "🅢 ";
|
||||
|
||||
os.symbols = {
|
||||
Alpaquita = " ";
|
||||
Alpine = " ";
|
||||
Amazon = " ";
|
||||
Android = " ";
|
||||
Arch = " ";
|
||||
Artix = " ";
|
||||
CentOS = " ";
|
||||
Debian = " ";
|
||||
DragonFly = " ";
|
||||
Emscripten = " ";
|
||||
EndeavourOS = " ";
|
||||
Fedora = " ";
|
||||
FreeBSD = " ";
|
||||
Garuda = " ";
|
||||
Gentoo = " ";
|
||||
HardenedBSD = " ";
|
||||
Illumos = " ";
|
||||
Linux = " ";
|
||||
Mabox = " ";
|
||||
Macos = " ";
|
||||
Manjaro = " ";
|
||||
Mariner = " ";
|
||||
MidnightBSD = " ";
|
||||
Mint = " ";
|
||||
NetBSD = " ";
|
||||
NixOS = " ";
|
||||
OpenBSD = " ";
|
||||
openSUSE = " ";
|
||||
OracleLinux = " ";
|
||||
Pop = " ";
|
||||
Raspbian = " ";
|
||||
Redhat = " ";
|
||||
RedHatEnterprise = " ";
|
||||
Redox = " ";
|
||||
Solus = " ";
|
||||
SUSE = " ";
|
||||
Ubuntu = " ";
|
||||
Unknown = " ";
|
||||
Windows = " ";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
44
home/programs/zsh.nix
Normal file
44
home/programs/zsh.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{pkgs, ...}: let
|
||||
shellAliases = builtins.mapAttrs (_: alias: alias.command) (import ./aliases.nix);
|
||||
in {
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableAutosuggestions = true;
|
||||
enableCompletion = true;
|
||||
dotDir = ".config/zsh";
|
||||
|
||||
syntaxHighlighting.enable = true;
|
||||
|
||||
envExtra = builtins.readFile ./zsh/envExtra.zsh;
|
||||
initExtraBeforeCompInit = builtins.readFile ./zsh/initExtraBeforeCompInit.zsh;
|
||||
initExtra = builtins.readFile ./zsh/initExtra.zsh;
|
||||
|
||||
inherit shellAliases;
|
||||
|
||||
localVariables = {
|
||||
vivid_theme = "catppuccin-macchiato";
|
||||
};
|
||||
|
||||
plugins = [
|
||||
{
|
||||
name = "ohmyzsh-macos";
|
||||
file = "plugins/macos.zsh";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "ohmyzsh";
|
||||
repo = "ohmyzsh";
|
||||
rev = "c4392a4da31efee36f29a62d3951d5c0fcd7d4e6";
|
||||
sha256 = "sha256-cMJCmhtcCAVDFgp6Ryv/5DteSRtwNcemO97as8ill8I=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "vivid-zsh";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "ryanccn";
|
||||
repo = "vivid-zsh";
|
||||
rev = "a76616c87821e96ae0cbdfb6bf897bffc170a283";
|
||||
sha256 = "sha256-E00xQMCmOt6fJ+IO/TrpFvskNa9QnDw/6DKR51T7i+8=";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
26
home/programs/zsh/envExtra.zsh
Normal file
26
home/programs/zsh/envExtra.zsh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# 1Password SSH
|
||||
export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
|
||||
|
||||
# Homebrew shell
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
|
||||
# fnm shell env
|
||||
eval "$(fnm env --use-on-cd)"
|
||||
|
||||
# deno
|
||||
export PATH="$HOME/.deno/bin:$PATH"
|
||||
|
||||
# pnpm
|
||||
export PNPM_HOME="${HOME}/Library/pnpm"
|
||||
|
||||
# direnv
|
||||
export DIRENV_LOG_FORMAT=""
|
||||
|
||||
# docker
|
||||
export PATH="$HOME/.docker/bin:$PATH"
|
||||
|
||||
# local bin
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# nish
|
||||
export PATH="$HOME/dev/nish/bin:$PATH"
|
||||
53
home/programs/zsh/initExtra.zsh
Normal file
53
home/programs/zsh/initExtra.zsh
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# environment variables
|
||||
export FZF_DEFAULT_OPTS=" \
|
||||
--color=bg+:#414559,bg:#303446,spinner:#f2d5cf,hl:#e78284 \
|
||||
--color=fg:#c6d0f5,header:#e78284,info:#ca9ee6,pointer:#f2d5cf \
|
||||
--color=marker:#f2d5cf,fg+:#c6d0f5,prompt:#ca9ee6,hl+:#e78284"
|
||||
|
||||
# zsh options
|
||||
setopt interactivecomments
|
||||
unsetopt menu_complete
|
||||
unsetopt flowcontrol
|
||||
setopt auto_menu
|
||||
setopt complete_in_word
|
||||
setopt always_to_end
|
||||
|
||||
# configure completion styles
|
||||
zstyle ':completion:*' menu select
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
|
||||
zstyle ':completion:*' group-name \'\'
|
||||
|
||||
function take() {
|
||||
mkdir "$1"
|
||||
cd "$1" || return 1
|
||||
}
|
||||
|
||||
function clean_vscode_workspace_storage() {
|
||||
for i in "$HOME/Library/Application Support/Code/User/workspaceStorage/"*; do
|
||||
if [ -f $i/workspace.json ]; then
|
||||
older="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')";
|
||||
if [ -n "$folder" ] && [ ! -d "$folder" ]; then
|
||||
echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"; rm -rfv "$i";
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# starship
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
# fzf
|
||||
# [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
# zoxide
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
# direnv
|
||||
command -v direnv &> /dev/null && eval "$(direnv hook zsh)"
|
||||
|
||||
# nix-your-shell
|
||||
eval "$(nix-your-shell zsh)"
|
||||
|
||||
# iTerm
|
||||
[ -e "$HOME/.iterm2_shell_integration.zsh" ] && source "$HOME/.iterm2_shell_integration.zsh"
|
||||
5
home/programs/zsh/initExtraBeforeCompInit.zsh
Normal file
5
home/programs/zsh/initExtraBeforeCompInit.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if command -v brew &>/dev/null
|
||||
then
|
||||
FPATH="$(brew --prefix)/share/zsh/site-functions:$FPATH"
|
||||
fi
|
||||
FPATH="$HOME/.zfunc:$FPATH"
|
||||
Loading…
Add table
Add a link
Reference in a new issue