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:
parent
872c6be493
commit
42a1293f6d
63 changed files with 1118 additions and 875 deletions
25
users/ryan/programs/aliases.nix
Normal file
25
users/ryan/programs/aliases.nix
Normal 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";
|
||||
}
|
||||
13
users/ryan/programs/bat.nix
Normal file
13
users/ryan/programs/bat.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
}
|
||||
12
users/ryan/programs/direnv.nix
Normal file
12
users/ryan/programs/direnv.nix
Normal 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; };
|
||||
};
|
||||
}
|
||||
11
users/ryan/programs/eza.nix
Normal file
11
users/ryan/programs/eza.nix
Normal 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" ];
|
||||
};
|
||||
}
|
||||
61
users/ryan/programs/fish.nix
Normal file
61
users/ryan/programs/fish.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
32
users/ryan/programs/fish/configs/01_tooling.fish
Normal file
32
users/ryan/programs/fish/configs/01_tooling.fish
Normal 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
|
||||
18
users/ryan/programs/fish/configs/99_interactive.fish
Normal file
18
users/ryan/programs/fish/configs/99_interactive.fish
Normal 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
|
||||
54
users/ryan/programs/git.nix
Normal file
54
users/ryan/programs/git.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
15
users/ryan/programs/go.nix
Normal file
15
users/ryan/programs/go.nix
Normal 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";
|
||||
};
|
||||
}
|
||||
16
users/ryan/programs/helix.nix
Normal file
16
users/ryan/programs/helix.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
40
users/ryan/programs/rust.nix
Normal file
40
users/ryan/programs/rust.nix
Normal 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
|
||||
];
|
||||
}
|
||||
92
users/ryan/programs/starship.nix
Normal file
92
users/ryan/programs/starship.nix
Normal 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 = " ";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
13
users/ryan/programs/tealdeer.nix
Normal file
13
users/ryan/programs/tealdeer.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
45
users/ryan/programs/zsh.nix
Normal file
45
users/ryan/programs/zsh.nix
Normal 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;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
27
users/ryan/programs/zsh/envExtra.zsh
Normal file
27
users/ryan/programs/zsh/envExtra.zsh
Normal 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"
|
||||
30
users/ryan/programs/zsh/initExtra.zsh
Normal file
30
users/ryan/programs/zsh/initExtra.zsh
Normal 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue