1
0
Fork 0
mirror of https://github.com/ryanccn/flake.git synced 2026-01-27 04:06:28 +01:00

refactor: use snowfall

This commit is contained in:
Ryan Cao 2024-02-10 11:56:31 +08:00
parent bb39b10e1f
commit de8503d9a6
Signed by: ryanccn
SSH key fingerprint: SHA256:NtP/BlVhoQq4xU6BEcZeT8nIPvHntkJ3lIc2yB+F09E
34 changed files with 181 additions and 194 deletions

View file

@ -0,0 +1,30 @@
{
"vim".command = "hx";
"cat".command = "bat";
"dig".command = "doggo";
"g".command = "git";
"g".fishAlias = true;
"j".command = "just";
"j".fishAlias = true;
"nb".command = "nix build";
"nfu".command = "nix flake update";
"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;
}

View file

@ -0,0 +1,10 @@
_: {
programs.bat = {
enable = true;
catppuccin.enable = true;
config = {
style = "plain";
};
};
}

View file

@ -0,0 +1,21 @@
{
config,
inputs,
...
}: {
programs.home-manager.enable = true;
imports = [
inputs.catppuccin.homeManagerModules.catppuccin
inputs.am.homeManagerModules.default
];
services.am-discord-rich-presence = {
enable = false;
logFile = "${config.home.homeDirectory}/Library/Logs/am-discord-rich-presence.log";
};
catppuccin.flavour = "frappe";
home.stateVersion = "23.05";
}

View file

@ -0,0 +1,11 @@
_: {
programs.direnv = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
# enableFishIntegration = true;
nix-direnv.enable = true;
};
}

View file

@ -0,0 +1,8 @@
_: {
programs.eza = {
enable = true;
enableAliases = true;
icons = true;
extraOptions = ["--all"];
};
}

View file

@ -0,0 +1,27 @@
# ls/exa/eza
set -x LS_COLORS (vivid generate catppuccin-frappe)
# 1Password SSH
set -x SSH_AUTH_SOCK "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
# Nix
fish_add_path -Pm /etc/profiles/per-user/$USER/bin /run/current-system/sw/bin
# fnm shell env
fnm env --use-on-cd | source
# cargo
fish_add_path -P "$HOME/.cargo/bin"
# deno
fish_add_path -P "$HOME/.deno/bin"
# pnpm
set -x PNPM_HOME "$HOME/Library/pnpm"
# docker
fish_add_path -P "$HOME/.docker/bin"
# local bin
fish_add_path -P "$HOME/.local/bin"
# suppress greeting
set fish_greeting

View file

@ -0,0 +1,8 @@
if status is-interactive
# nix-your-shell
nix-your-shell fish | source
if test -e "$HOME/.iterm2_shell_integration.fish"
source "$HOME/.iterm2_shell_integration.fish"
end
end

View file

@ -0,0 +1,35 @@
{lib, ...}: let
aliases = import ../aliases;
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 = ./conf.d;
recursive = true;
};
}

View file

@ -0,0 +1,18 @@
{pkgs, ...}: {
home.packages = with pkgs; [
inter
public-sans
ibm-plex
monaspace
ryan-mono-bin
ryan-term-bin
commit-mono
(nerdfonts.override {
fonts = [
"CascadiaCode"
"NerdFontsSymbolsOnly"
];
})
];
}

View file

@ -0,0 +1,24 @@
_: {
programs.fzf = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
colors = {
"bg+" = "#414559";
"bg" = "#303446";
"fg+" = "#c6d0f5";
"fg" = "#c6d0f5";
"hl+" = "#e78284";
"hl" = "#e78284";
"spinner" = "#f2d5cf";
"header" = "#e78284";
"info" = "#ca9ee6";
"pointer" = "#f2d5cf";
"marker" = "#f2d5cf";
"prompt" = "#ca9ee6";
};
};
}

View file

@ -0,0 +1,31 @@
_: {
programs.git = {
enable = true;
difftastic.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;
};
}

View file

@ -0,0 +1,3 @@
_: {
programs.glamour.catppuccin.enable = true;
}

View file

@ -0,0 +1,11 @@
_: {
programs.go = {
enable = true;
goPath = ".go";
};
home.sessionVariables = {
GOTOOLCHAIN = "path";
GOPROXY = "direct";
};
}

View file

@ -0,0 +1,7 @@
_: {
programs.helix = {
enable = true;
catppuccin.enable = true;
defaultEditor = true;
};
}

View file

@ -0,0 +1,32 @@
{
pkgs,
config,
...
}: let
toml = pkgs.formats.toml {};
in {
home.file.".cargo/config.toml".source = toml.generate "config.toml" {
build.target-dir = "${config.home.homeDirectory}/.cargo/target";
};
home.packages = with pkgs; [
(fenix.combine (
with fenix;
with stable; [
cargo
rustc
rustfmt
clippy
rust-src
llvm-tools-preview
targets.wasm32-unknown-unknown.stable.rust-std
]
))
cargo-bloat
cargo-cache
cargo-deny
cargo-expand
cargo-watch
];
}

View file

@ -0,0 +1,109 @@
_: {
programs.starship = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
settings = {
command_timeout = 1000;
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
gcloud.disabled = true;
bun.format = "[$symbol($version )]($style)";
cmd_duration.format = "[$duration]($style) ";
deno.format = "[$symbol($version )]($style)";
docker_context.format = "[$symbol$context]($style) ";
git_branch.format = "[$symbol$branch(:$remote_branch)]($style) ";
golang.format = "[$symbol($version )]($style)";
nix_shell.format = "[$symbol$state( \($name\))]($style) ";
nodejs.format = "[$symbol($version )]($style)";
package.format = "[$symbol$version]($style) ";
python.format = "[\${symbol}\${pyenv_prefix}(\${version} )(\($virtualenv\) )]($style)";
rust.format = "[$symbol($version )]($style)";
aws.symbol = " ";
bun.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 = "󰍲 ";
};
};
};
}

View file

@ -0,0 +1,9 @@
_: {
programs.tealdeer = {
enable = true;
settings = {
display.compact = true;
updates.auto_update = true;
};
};
}

View file

@ -0,0 +1,15 @@
_: {
home.sessionVariables = {
NEXT_TELEMETRY_DISABLED = "1";
NUXT_TELEMETRY_DISABLED = "1";
CHECKPOINT_DISABLE = "1";
DISABLE_TELEMETRY = "YES";
ASTRO_TELEMETRY_DISABLED = "1";
FNM_RESOLVE_ENGINES = "true";
FNM_COREPACK_ENABLED = "true";
DENO_NO_UPDATE_CHECK = "1";
CSC_IDENTITY_AUTO_DISCOVERY = "false";
};
}

View file

@ -0,0 +1,234 @@
{
pkgs,
lib,
...
}: let
extensions = builtins.map lib.strings.toLower [
"antfu.icons-carbon"
"antfu.unocss"
"astro-build.astro-vscode"
"bierner.lit-html"
"bmalehorn.vscode-fish"
"bradlc.vscode-tailwindcss"
# "Catppuccin.catppuccin-vsc"
# "Catppuccin.catppuccin-vsc-icons"
"charliermarsh.ruff"
"dbaeumer.vscode-eslint"
"denoland.vscode-deno"
"dprint.dprint"
"DotJoshJohnson.xml"
"eamodio.gitlens"
"EditorConfig.EditorConfig"
# "enkia.tokyo-night"
"esbenp.prettier-vscode"
"github.vscode-github-actions"
"GraphQL.vscode-graphql"
"GraphQL.vscode-graphql-syntax"
"golang.go"
"griimick.vhs"
"LeonardSSH.vscord"
"jdinhlife.gruvbox"
"jnoortheen.nix-ide"
"miguelsolorio.symbols"
"ms-python.isort"
"ms-python.vscode-pylance"
"ms-python.python"
# "mvllow.rose-pine"
"nvarner.typst-lsp"
"Prisma.prisma"
"ronnidc.nunjucks"
"rust-lang.rust-analyzer"
"sastan.twind-intellisense"
"skellock.just"
"svelte.svelte-vscode"
"tamasfe.even-better-toml"
"timonwong.shellcheck"
"unifiedjs.vscode-mdx"
"usernamehw.errorlens"
"Vue.volar"
"xaver.clang-format"
"YoavBls.pretty-ts-errors"
];
in {
programs.vscode = {
enable = true;
package = pkgs.stdenv.mkDerivation {
pname = "vscode";
version = "1.86.0";
src = pkgs.emptyDirectory;
installPhase = ''
mkdir -p $out
'';
};
extensions = [];
mutableExtensionsDir = true;
userSettings = {
"workbench.colorTheme" = "Gruvbox Dark Hard";
"workbench.iconTheme" = "symbols";
"workbench.productIconTheme" = "icons-carbon";
"workbench.sideBar.location" = "left";
"workbench.activityBar.location" = "top";
"symbols.hidesExplorerArrows" = false;
"catppuccin.boldKeywords" = false;
"catppuccin.italicKeywords" = true;
"catppuccin.accentColor" = "sky";
"catppuccin.workbenchMode" = "default";
"catppuccin.customUIColors" = {
"all" = {
"activityBar.activeBorder" = "accent";
"statusBarItem.remoteBackground" = "accent";
};
};
"git.autofetch" = true;
"git.confirmSync" = false;
"diffEditor.renderSideBySide" = false;
"git.inputValidation" = "off";
"git.suggestSmartCommit" = false;
"diffEditor.ignoreTrimWhitespace" = false;
"gitlens.showWelcomeOnInstall" = false;
"editor.fontFamily" = "\"RyanMono Nerd Font\", monospace";
"editor.fontLigatures" = true;
# "editor.fontLigatures" = "'calt', 'ss01'";
"editor.fontSize" = 16;
"editor.lineHeight" = 1.5;
"editor.cursorSmoothCaretAnimation" = "on";
# "editor.minimap.renderCharacters" = false;
"editor.cursorBlinking" = "phase";
"workbench.editor.highlightModifiedTabs" = true;
"workbench.editor.empty.hint" = "hidden";
"editor.inlineSuggest.enabled" = true;
"editor.tabSize" = 2;
"editor.insertSpaces" = true;
"editor.formatOnSave" = true;
"terminal.integrated.fontFamily" = "\"RyanTerm Nerd Font\", monospace";
"terminal.integrated.fontSize" = 14;
"terminal.integrated.lineHeight" = 1.5;
"terminal.integrated.cursorBlinking" = true;
"terminal.integrated.defaultProfile.osx" = "fish";
"terminal.integrated.inheritEnv" = false;
"terminal.integrated.shellIntegration.enabled" = true;
"javascript.preferGoToSourceDefinition" = true;
"typescript.preferGoToSourceDefinition" = true;
"shellcheck.ignorePatterns" = {
".envrc" = true;
};
"editor.defaultFormatter" = "esbenp.prettier-vscode";
"tailwindCSS.includeLanguages" = {
"typescript" = "javascript";
"typescriptreact" = "javascript";
"vue-html" = "html";
};
"typescript.enablePromptUseWorkspaceTsdk" = true;
"telemetry.telemetryLevel" = "off";
"workbench.enableExperiments" = false;
"workbench.settings.enableNaturalLanguageSearch" = false;
"extensions.ignoreRecommendations" = true;
"editor.accessibilitySupport" = "off";
"vscord.status.details.text.editing" = "In {workspace}";
"vscord.status.details.text.viewing" = "In {workspace}";
"vscord.status.problems.enabled" = false;
"vscord.status.state.text.editing" = "Working on {file_name}{file_extension}";
"vscord.status.buttons.button1.enabled" = false;
"gitlens.defaultTimeFormat" = "HH=mm";
"gitlens.defaultDateShortFormat" = "YYYY/MM/DD";
"gitlens.defaultDateFormat" = null;
"[python]"."editor.tabSize" = 4;
"[python]"."editor.defaultFormatter" = "charliermarsh.ruff";
"[cpp]"."editor.defaultFormatter" = "xaver.clang-format";
"[toml]"."editor.defaultFormatter" = "tamasfe.even-better-toml";
"[svelte]"."editor.defaultFormatter" = "svelte.svelte-vscode";
"[go][go.mod][go.sum]"."editor.defaultFormatter" = "golang.go";
"[xml]"."editor.defaultFormatter" = "DotJoshJohnson.xml";
"[fish]"."editor.defaultFormatter" = "bmalehorn.vscode-fish";
"[just]"."editor.defaultFormatter" = "skellock.just";
"[mdx]"."editor.wordWrap" = "on";
"[astro]"."editor.defaultFormatter" = "astro-build.astro-vscode";
"[rust]"."editor.tabSize" = 4;
"[rust]"."editor.defaultFormatter" = "rust-lang.rust-analyzer";
"rust-analyzer.server.path" = "${pkgs.rust-analyzer}/bin/rust-analyzer";
"rust-analyzer.check.command" = "clippy";
"rust-analyzer.showUnlinkedFileNotification" = false;
"files.associations" = {
"*.mcmeta" = "json";
"*.plist" = "xml";
".dockerignore" = "ignore";
".dev.vars" = "properties";
".env.example" = "properties";
"*.sarif" = "json";
".tokeignore" = "ignore";
"flake.lock" = "json";
};
"svelte.enable-ts-plugin" = true;
"clang-format.executable" = "${pkgs.clang-tools}/bin/clang-format";
"[nix]"."editor.defaultFormatter" = "jnoortheen.nix-ide";
"nix.enableLanguageServer" = true;
"nix.serverPath" = "${pkgs.nil}/bin/nil";
"nix.serverSettings" = {
nil = {
formatting = {
command = ["${pkgs.alejandra}/bin/alejandra"];
};
};
};
"typst-lsp.exportPdf" = "never";
"typst-lsp.experimentalFormatterMode" = "on";
"[typst]"."editor.defaultFormatter" = "nvarner.typst-lsp";
};
};
home.activation = {
vscodeExtensions = lib.hm.dag.entryAfter ["writeBoundary"] ''
code_bin="/usr/local/bin/code"
if ! command -v "$code_bin" &> /dev/null; then
echo "code CLI is not available"
exit 0
fi
declare -A currentExtensions
for extension in $("$code_bin" --list-extensions); do
currentExtensions["$extension"]=1;
done
${builtins.concatStringsSep
"\n"
(
builtins.map
(ext: ''
if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then
echo "installing ${ext}"
$DRY_RUN_CMD "$code_bin" --install-extension ${ext} &> /dev/null
fi
unset 'currentExtensions[${ext}]'
'')
extensions
)}
for ext in "''${!currentExtensions[@]}"; do
echo "uninstalling $ext"
$DRY_RUN_CMD "$code_bin" --uninstall-extension $ext &> /dev/null
unset 'currentExtensions[$ext]'
done
'';
};
}

View file

@ -0,0 +1,9 @@
_: {
programs.zoxide = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
};
}

View file

@ -0,0 +1,38 @@
{
config,
inputs,
...
}: let
shellAliases = builtins.mapAttrs (_: alias: alias.command) (import ../aliases);
in {
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
dotDir = ".config/zsh";
syntaxHighlighting.enable = true;
envExtra = builtins.readFile ./envExtra.zsh;
# initExtraBeforeCompInit = builtins.readFile ./zsh/initExtraBeforeCompInit.zsh;
initExtra = builtins.readFile ./initExtra.zsh;
inherit shellAliases;
localVariables = {
vivid_theme = "catppuccin-${config.catppuccin.flavour}";
};
plugins = [
{
name = "ohmyzsh-macos";
file = "plugins/macos/macos.plugin.zsh";
src = inputs.ohmyzsh;
}
{
name = "vivid-zsh";
src = inputs.vivid-zsh;
}
];
};
}

View file

@ -0,0 +1,20 @@
# 1Password SSH
export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
# 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"

View file

@ -0,0 +1,35 @@
# 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
}
# nix-your-shell
eval "$(nix-your-shell zsh)"
# iTerm
[ -e "$HOME/.iterm2_shell_integration.zsh" ] && source "$HOME/.iterm2_shell_integration.zsh"