feat: add develop environment for ruby

This commit is contained in:
Ryan Yin
2024-03-14 00:30:32 +08:00
parent bcc8d2302c
commit 4d3a3750c1
67 changed files with 54 additions and 31 deletions

17
home/base/core/btop.nix Normal file
View File

@@ -0,0 +1,17 @@
{
pkgs,
nur-ryan4yin,
...
}: {
# https://github.com/catppuccin/btop/blob/main/themes/catppuccin_mocha.theme
xdg.configFile."btop/themes".source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-btop}/themes";
# replacement of htop/nmon
programs.btop = {
enable = true;
settings = {
color_theme = "catppuccin_mocha";
theme_background = false; # make btop transparent
};
};
}

View File

@@ -0,0 +1,45 @@
{
pkgs,
pkgs-unstable,
nur-ryan4yin,
...
}: {
home.packages = with pkgs; [
skopeo
docker-compose
dive # explore docker layers
lazydocker # Docker terminal UI.
kubectl
istioctl
kubevirt # virtctl
kubernetes-helm
fluxcd
argocd
];
programs = {
k9s = {
enable = true;
# https://k9scli.io/topics/aliases/
# aliases = {};
settings = {
skin = "catppuccino-mocha";
};
skins.catppuccin-mocha = let
skin_file = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-k9s}/dist/mocha.yml"; # theme - catppuccin mocha
skin_attr = builtins.fromJSON (
builtins.readFile
# replace 'base: &base "#1e1e2e"' with 'base: &base "default"'
# to make fg/bg color transparent. "default" means transparent in k9s skin.
(pkgs.runCommandNoCC "get-skin-json" {} ''
cat ${skin_file} \
| sed -E 's@(base: &base ).+@\1 "default"@g' \
| ${pkgs.yj}/bin/yj > $out
'')
);
in
skin_attr;
};
};
}

142
home/base/core/core.nix Normal file
View File

@@ -0,0 +1,142 @@
{
pkgs,
attic,
nur-ryan4yin,
...
}: {
home.packages = with pkgs; [
# Misc
tldr
cowsay
gnupg
gnumake
# Morden cli tools, replacement of grep/sed/...
# Interactively filter its input using fuzzy searching, not limit to filenames.
fzf
# search for files by name, faster than find
fd
# search for files by its content, replacement of grep
(ripgrep.override {withPCRE2 = true;})
# A fast and polyglot tool for code searching, linting, rewriting at large scale
# supported languages: only some mainstream languages currently(do not support nix/nginx/yaml/toml/...)
ast-grep
sad # CLI search and replace, just like sed, but with diff preview.
yq-go # yaml processer https://github.com/mikefarah/yq
just # a command runner like make, but simpler
delta # A viewer for git and diff output
lazygit # Git terminal UI.
hyperfine # command-line benchmarking tool
gping # ping, but with a graph(TUI)
doggo # DNS client for humans
duf # Disk Usage/Free Utility - a better 'df' alternative
du-dust # A more intuitive version of `du` in rust
gdu # disk usage analyzer(replacement of `du`)
# nix related
#
# it provides the command `nom` works just like `nix
# with more details log output
nix-output-monitor
hydra-check # check hydra(nix's build farm) for the build status of a package
nix-index # A small utility to index nix store paths
nix-init # generate nix derivation from url
# https://github.com/nix-community/nix-melt
nix-melt # A TUI flake.lock viewer
# https://github.com/utdemir/nix-tree
nix-tree # A TUI to visualize the dependency graph of a nix derivation
# productivity
caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx)
croc # File transfer between computers securely and easily
# self-hosted nix cache server
attic.packages.${pkgs.system}.attic-client
ncdu # analyzer your disk usage Interactively, via TUI(replacement of `du`)
];
programs = {
# A modern replacement for ls
# useful in bash/zsh prompt, not in nushell.
eza = {
enable = true;
enableAliases = false; # do not enable aliases in nushell!
git = true;
icons = true;
};
# a cat(1) clone with syntax highlighting and Git integration.
bat = {
enable = true;
config = {
pager = "less -FR";
theme = "catppuccin-mocha";
};
themes = {
# https://raw.githubusercontent.com/catppuccin/bat/main/Catppuccin-mocha.tmTheme
catppuccin-mocha = {
src = nur-ryan4yin.packages.${pkgs.system}.catppuccin-bat;
file = "Catppuccin-mocha.tmTheme";
};
};
};
# A command-line fuzzy finder
fzf = {
enable = true;
# https://github.com/catppuccin/fzf
# catppuccin-mocha
colors = {
"bg+" = "#313244";
"bg" = "#1e1e2e";
"spinner" = "#f5e0dc";
"hl" = "#f38ba8";
"fg" = "#cdd6f4";
"header" = "#f38ba8";
"info" = "#cba6f7";
"pointer" = "#f5e0dc";
"marker" = "#f5e0dc";
"fg+" = "#cdd6f4";
"prompt" = "#cba6f7";
"hl+" = "#f38ba8";
};
};
# zoxide is a smarter cd command, inspired by z and autojump.
# It remembers which directories you use most frequently,
# so you can "jump" to them in just a few keystrokes.
# zoxide works on all major shells.
#
# z foo # cd into highest ranked directory matching foo
# z foo bar # cd into highest ranked directory matching foo and bar
# z foo / # cd into a subdirectory starting with foo
#
# z ~/foo # z also works like a regular cd command
# z foo/ # cd into relative path
# z .. # cd one level up
# z - # cd into previous directory
#
# zi foo # cd with interactive selection (using fzf)
#
# z foo<SPACE><TAB> # show interactive completions (zoxide v0.8.0+, bash 4.4+/fish/zsh only)
zoxide = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableNushellIntegration = true;
};
# Atuin replaces your existing shell history with a SQLite database,
# and records additional context for your commands.
# Additionally, it provides optional and fully encrypted
# synchronisation of your history between machines, via an Atuin server.
atuin = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableNushellIntegration = true;
};
};
}

View File

@@ -0,0 +1,3 @@
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}

View File

@@ -0,0 +1,4 @@
# Editors
See [desktop/editors/](../../desktop/editors/) for more details.

View File

@@ -0,0 +1,3 @@
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}

View File

@@ -0,0 +1,5 @@
{pkgs, ...}: {
programs.helix = {
enable = true;
};
}

View File

@@ -0,0 +1,11 @@
{pkgs, ...}: {
programs = {
neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
};
};
}

98
home/base/core/git.nix Normal file
View File

@@ -0,0 +1,98 @@
{
config,
lib,
pkgs,
myvars,
...
}: {
# `programs.git` will generate the config file: ~/.config/git/config
# to make git use this config file, `~/.gitconfig` should not exist!
#
# https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
rm -f ${config.home.homeDirectory}/.gitconfig
'';
home.packages = with pkgs; [
];
programs.git = {
enable = true;
lfs.enable = true;
userName = myvars.userfullname;
userEmail = myvars.useremail;
includes = [
{
# use diffrent email & name for work
path = "~/work/.gitconfig";
condition = "gitdir:~/work/";
}
];
extraConfig = {
init.defaultBranch = "main";
push.autoSetupRemote = true;
pull.rebase = true;
# replace https with ssh
url = {
"ssh://git@github.com/ryan4yin" = {
insteadOf = "https://github.com/ryan4yin";
};
# "ssh://git@gitlab.com/" = {
# insteadOf = "https://gitlab.com/";
# };
# "ssh://git@bitbucket.com/" = {
# insteadOf = "https://bitbucket.com/";
# };
};
};
# signing = {
# key = "xxx";
# signByDefault = true;
# };
# A syntax-highlighting pager in Rust(2019 ~ Now)
delta = {
enable = true;
options = {
diff-so-fancy = true;
line-numbers = true;
true-color = "always";
# features => named groups of settings, used to keep related settings organized
# features = "";
};
};
aliases = {
# common aliases
br = "branch";
co = "checkout";
st = "status";
ls = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate";
ll = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate --numstat";
cm = "commit -m"; # commit via `git cm <message>`
ca = "commit -am"; # commit all changes via `git ca <message>`
dc = "diff --cached";
amend = "commit --amend -m"; # amend commit message via `git amend <message>`
unstage = "reset HEAD --"; # unstage file via `git unstage <file>`
merged = "branch --merged"; # list merged(into HEAD) branches via `git merged`
unmerged = "branch --no-merged"; # list unmerged(into HEAD) branches via `git unmerged`
nonexist = "remote prune origin --dry-run"; # list non-exist(remote) branches via `git nonexist`
# delete merged branches except master & dev & staging
# `!` indicates it's a shell script, not a git subcommand
delmerged = ''! git branch --merged | egrep -v "(^\*|main|master|dev|staging)" | xargs git branch -d'';
# delete non-exist(remote) branches
delnonexist = "remote prune origin";
# aliases for submodule
update = "submodule update --init --recursive";
foreach = "submodule foreach";
};
};
}

13
home/base/core/pip.nix Normal file
View File

@@ -0,0 +1,13 @@
_: {
# use mirror for pip install
xdg.configFile."pip/pip.conf".text = ''
[global]
index-url = https://mirrors.ustc.edu.cn/pypi/web/simple
format = columns
'';
# xdg.configFile."pip/pip.conf".text = ''
# [global]
# index-url = https://mirrors.bfsu.edu.cn/pypi/web/simple
# '';
}

View File

@@ -0,0 +1,120 @@
# Nushell Config File
#
# version = 0.81.1
# let's define some colors
# https://github.com/catppuccin/i3/blob/main/themes/catppuccin-mocha
let rosewater = "#f5e0dc"
let flamingo = "#f2cdcd"
let pink = "#f5c2e7"
let mauve = "#cba6f7"
let red = "#f38ba8"
let maroon = "#eba0ac"
let peach = "#fab387"
let green = "#a6e3a1"
let teal = "#94e2d5"
let sky = "#89dceb"
let sapphire = "#74c7ec"
let blue = "#89b4fa"
let lavender = "#b4befe"
let text = "#cdd6f4"
let subtext1 = "#bac2de"
let subtext0 = "#a6adc8"
let overlay2 = "#9399b2"
let overlay1 = "#7f849c"
let overlay0 = "#6c7086"
let surface2 = "#585b70"
let surface1 = "#45475a"
let surface0 = "#313244"
let base = "#1e1e2e"
let mantle = "#181825"
let crust = "#11111b"
# we're creating a theme here that uses the colors we defined above.
let catppuccin_theme = {
separator: $overlay2
leading_trailing_space_bg: $surface2
header: $red
date: $pink
filesize: $green
row_index: $text
bool: $peach
int: $red
duration: $sky
range: $sapphire
float: $lavender
string: $text
nothing: $overlay1
binary: $subtext1
cellpath: $subtext0
hints: dark_gray
shape_garbage: { fg: $overlay2 bg: $red attr: b}
shape_bool: $maroon
shape_int: { fg: $pink attr: b}
shape_float: { fg: $pink attr: b}
shape_range: { fg: $overlay0 attr: b}
shape_internalcall: { fg: $maroon attr: b}
shape_external: $mauve
shape_externalarg: { fg: $red attr: b}
shape_literal: $flamingo
shape_operator: $rosewater
shape_signature: { fg: $red attr: b}
shape_string: $red
shape_filepath: $peach
shape_globpattern: { fg: $teal attr: b}
shape_variable: $pink
shape_flag: { fg: $mauve attr: b}
shape_custom: {attr: b}
}
# The default config record. This is where much of your global configuration is setup.
$env.config = {
color_config: $catppuccin_theme # <-- this is the theme
use_ansi_coloring: true
# true or false to enable or disable the welcome banner at startup
show_banner: false
table: {
mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column
show_empty: true # show 'empty list' and 'empty record' placeholders for command output
trim: {
methodology: wrapping # wrapping or truncating
wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology
truncating_suffix: "..." # A suffix used by the 'truncating' methodology
}
}
completions: {
case_sensitive: false # set to true to enable case-sensitive completions
quick: true # set this to false to prevent auto-selecting completions when only one remains
partial: true # set this to false to prevent partial filling of the prompt
algorithm: "prefix" # prefix or fuzzy
external: {
enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow
max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
completer: null # check 'carapace_completer' above as an example
}
}
filesize: {
metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard)
format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto
}
cursor_shape: {
emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default)
vi_insert: block # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default)
vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default)
}
use_grid_icons: true
footer_mode: "25" # always, never, number_of_rows, auto
float_precision: 2 # the precision for displaying floats in tables
# buffer_editor: "emacs" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL
bracketed_paste: true # enable bracketed paste, currently useless on windows
edit_mode: emacs # emacs, vi
shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
}

View File

@@ -0,0 +1,25 @@
let
shellAliases = {
k = "kubectl";
urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
};
in {
# only works in bash/zsh, not nushell
home.shellAliases = shellAliases;
programs.nushell = {
enable = true;
configFile.source = ./config.nu;
inherit shellAliases;
};
programs.bash = {
enable = true;
enableCompletion = true;
bashrcExtra = ''
export PATH="$HOME/.local/bin:$HOME/go/bin:$PATH"
'';
};
}

View File

@@ -0,0 +1,33 @@
{
pkgs,
nur-ryan4yin,
...
}: {
programs.starship = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableNushellIntegration = true;
settings =
{
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
aws = {
symbol = "🅰 ";
};
gcloud = {
# do not show the account/project's info
# to avoid the leak of sensitive information when sharing the terminal
format = "on [$symbol$active(\($region\))]($style) ";
symbol = "🅶 ";
};
palette = "catppuccin_mocha";
}
// builtins.fromTOML (builtins.readFile "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-starship}/palettes/mocha.toml");
};
}

18
home/base/core/yazi.nix Normal file
View File

@@ -0,0 +1,18 @@
{
pkgs,
pkgs-unstable,
nur-ryan4yin,
...
}: {
# terminal file manager
programs.yazi = {
enable = true;
package = pkgs-unstable.yazi;
# Changing working directory when exiting Yazi
enableBashIntegration = true;
# TODO: nushellIntegration is broken on release-23.11, wait for master's fix to be released
enableNushellIntegration = false;
};
xdg.configFile."yazi/theme.toml".source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-yazi}/mocha.toml";
}

View File

@@ -0,0 +1,12 @@
let
shellAliases = {
"zj" = "zellij";
};
in {
programs.zellij = {
enable = true;
};
# only works in bash/zsh, not nushell
home.shellAliases = shellAliases;
programs.nushell.shellAliases = shellAliases;
}