1
0
Fork 0
mirror of https://github.com/ryanccn/flake.git synced 2025-12-06 08:10:43 +01:00

refactor: flake-parts

This commit is contained in:
Ryan Cao 2025-04-03 00:36:22 +08:00
parent 872c6be493
commit 42a1293f6d
Signed by: ryanccn
GPG key ID: F605AB4AF937D5D0
63 changed files with 1118 additions and 875 deletions

View file

@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
"g".command = "git";
"j".command = "just";
"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";
}

View file

@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.bat = {
enable = true;
config = {
style = "plain";
};
};
}

View file

@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{ pkgs, config, ... }:
{
programs.direnv = {
enable = true;
nix-direnv.enable = true;
nix-direnv.package = pkgs.nix-direnv.override { nix = config.nix.package; };
};
}

View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.eza = {
enable = true;
icons = "auto";
extraOptions = [ "--all" ];
};
}

View file

@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{ lib, ... }:
let
aliases = import ./aliases.nix;
shellAbbrs = builtins.mapAttrs (lib.const (builtins.getAttr "command")) (
lib.filterAttrs (_: a: !(lib.maybeAttr "fishAlias" false a)) aliases
);
shellAliases = builtins.mapAttrs (lib.const (builtins.getAttr "command")) (
lib.filterAttrs (_: a: lib.maybeAttr "fishAlias" false a) aliases
);
in
{
programs.fish = {
enable = true;
inherit shellAbbrs shellAliases;
shellInit = ''
for config in ${./fish/configs}/*.fish
source "$config"
end
'';
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
'';
};
};
programs.fzf = {
enable = true;
defaultOptions = [
"--height 40%"
"--layout reverse"
"--border"
];
};
programs.zoxide = {
enable = true;
};
}

View file

@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
set -x SSH_AUTH_SOCK "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
set -x LS_COLORS "$(vivid generate catppuccin-frappe)"
/opt/homebrew/bin/brew shellenv | source
fnm env --use-on-cd | source
fish_add_path -P "$CARGO_HOME/bin"
fish_add_path -P "$GOPATH/bin"
fish_add_path -P "$HOME/.deno/bin"
fish_add_path -P "$HOME/.orbstack/bin"
fish_add_path -P "$HOME/.local/bin"
function expose_app_to_path
set -f app $argv[1]
if test -d "$HOME/Applications/$app.app"
fish_add_path -P "$HOME/Applications/$app.app/Contents/MacOS"
end
if test -d "/Applications/$app.app"
fish_add_path -P "/Applications/$app.app/Contents/MacOS"
end
end
expose_app_to_path Ghostty
expose_app_to_path WezTerm
set fish_greeting

View file

@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
if status is-interactive
nix-your-shell fish | source
if command -q nrr
source "$(COMPLETE=fish nrr | psub)"
if command -q nrx
source "$(COMPLETE=fish nrx | psub)"
end
end
if set -q GHOSTTY_RESOURCES_DIR
source "$GHOSTTY_RESOURCES_DIR/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish"
end
end

View file

@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.git = {
enable = true;
# difftastic.enable = true;
ignores = [
".DS_Store"
".direnv/"
".vscode/"
".zed/"
".idea/"
];
userName = "Ryan Cao";
userEmail = "70191398+ryanccn@users.noreply.github.com";
extraConfig = {
init.defaultBranch = "main";
commit.gpgSign = true;
gpg.format = "openpgp";
user.signingKey = "F605AB4AF937D5D0";
column.ui = "auto";
log.date = "iso";
merge.conflictStyle = "zdiff3";
diff.algorithm = "histogram";
diff.colorMoved = "plain";
diff.mnemonicPrefix = true;
diff.renames = true;
fetch.prune = true;
fetch.pruneTags = true;
fetch.all = true;
transfer.fsckObjects = true;
branch.sort = "-committerdate";
tag.sort = "version:refname";
push.autoSetupRemote = true;
};
};
programs.gh = {
enable = true;
gitCredentialHelper.enable = true;
};
}

View file

@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.go = {
enable = true;
goPath = ".local/share/go";
};
home.sessionVariables = {
GOTOOLCHAIN = "local";
GOPROXY = "direct";
};
}

View file

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
inputs,
pkgs,
...
}:
{
programs.helix = {
enable = true;
package = inputs.self.packages.${pkgs.stdenvNoCC.hostPlatform.system}.helix-with-lsps;
defaultEditor = true;
};
}

View file

@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
pkgs,
inputs,
lib,
config,
...
}:
let
toml = pkgs.formats.toml { };
rust-bin = inputs.rust-overlay.lib.mkRustBin { } pkgs;
in
{
home.file."${config.xdg.dataHome}/cargo/config.toml".source = toml.generate "config.toml" {
linker = "${lib.getExe pkgs.clang}";
rustflags = [
"-C"
"link-arg=-fuse-ld=${lib.getExe pkgs.mold}"
];
};
home.packages = with pkgs; [
(rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
"llvm-tools-preview"
];
})
cargo-audit
cargo-bloat
cargo-cache
cargo-deny
cargo-expand
];
}

View file

@ -0,0 +1,92 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.starship = {
enable = true;
settings = {
command_timeout = 1000;
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
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 = "󰳮 ";
c.symbol = " ";
conda.symbol = " ";
directory.read_only = " 󰌾";
docker_context.symbol = " ";
git_branch.symbol = " ";
golang.symbol = " ";
haskell.symbol = " ";
hg_branch.symbol = " ";
hostname.ssh_symbol = " ";
java.symbol = " ";
memory_usage.symbol = "󰍛 ";
nim.symbol = "󰆥 ";
nix_shell.symbol = " ";
nodejs.symbol = " ";
package.symbol = "󰏗 ";
python.symbol = " ";
rust.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,13 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
programs.tealdeer = {
enable = true;
settings = {
display.compact = true;
updates.auto_update = true;
};
};
}

View file

@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
{
config,
inputs,
lib,
...
}:
let
shellAliases = builtins.mapAttrs (lib.const (builtins.getAttr "command")) (import ./aliases.nix);
in
{
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
enableCompletion = 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-${config.catppuccin.flavor}";
};
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,27 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
# 1Password SSH
export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# fnm shell env
eval "$(fnm env --use-on-cd)"
# cargo
export PATH="$CARGO_HOME/bin:$PATH"
# go
export PATH="$GOPATH/bin:$PATH"
# deno
export PATH="$HOME/.deno/bin:$PATH"
# pnpm
export PNPM_HOME="${HOME}/Library/pnpm"
export PATH="$PNPM_HOME:$PATH"
# local bin
export PATH="$HOME/.local/bin:$PATH"

View file

@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
#
# SPDX-License-Identifier: Apache-2.0
# zsh options
setopt interactivecomments
unsetopt menu_complete
unsetopt flowcontrol
setopt auto_menu
setopt complete_in_word
setopt always_to_end
export HISTFILE="$XDG_STATE_HOME"/zsh/history
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
# 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
}
# nix-your-shell
eval "$(nix-your-shell zsh)"
# Ghostty
[[ "$TERM_PROGRAM" == "ghostty" ]] && source "/Applications/Ghostty.app/Contents/Resources/ghostty/shell-integration/zsh/ghostty-integration"