diff --git a/home/.chezmoi.toml.tmpl b/home/.chezmoi.toml.tmpl index 9812caa..960e3b5 100644 --- a/home/.chezmoi.toml.tmpl +++ b/home/.chezmoi.toml.tmpl @@ -68,7 +68,7 @@ Determining headless {{- $ephemeral = true -}} {{- $headless = true -}} {{- end -}} -{{ if not .headless }} +{{ if not $headless }} {{ if eq .chezmoi.os "linux" }} {{/* Fedora Server */}} {{ if eq .chezmoi.osRelease.variantID "server" }} diff --git a/home/.chezmoiexternals/linux-fonts.toml b/home/.chezmoiexternals/linux-fonts.toml new file mode 100644 index 0000000..aa0149e --- /dev/null +++ b/home/.chezmoiexternals/linux-fonts.toml @@ -0,0 +1,27 @@ +[".local/share/fonts/maple-nf"] + type = "archive" + url = {{ gitHubLatestReleaseAssetURL "subframe7536/maple-font" (printf "MapleMono-NF-CN-unhinted.zip") | quote }} + refreshPeriod = "672h" + exact = true + executable = false + +[".local/share/fonts/jetbrainsmono-nf"] + type = "archive" + url = {{ gitHubLatestReleaseAssetURL "ryanoasis/nerd-fonts" (printf "JetBrainsMono.zip") | quote }} + refreshPeriod = "672h" + exact = true + executable = false + +[".local/share/fonts/lxgw-wenkai"] + type = "archive" + url = {{ gitHubLatestReleaseAssetURL "lxgw/LxgwWenKai" (printf "lxgw-wenkai-v*.zip") | quote }} + refreshPeriod = "168h" + exact = true + executable = false + +[".local/share/fonts/lxgw-neoxihei"] + type = "file" + url = {{ gitHubLatestReleaseAssetURL "lxgw/LxgwNeoXiHei" (printf "LXGWNeoXiHei.ttf") | quote }} + refreshPeriod = "168h" + exact = true + executable = false diff --git a/home/.chezmoiignore.tmpl b/home/.chezmoiignore.tmpl index 2f25487..3e28b9f 100644 --- a/home/.chezmoiignore.tmpl +++ b/home/.chezmoiignore.tmpl @@ -8,10 +8,15 @@ vim:ft=gotmpl {{/* Secret Directory, always ignored, access via templates */}} secrets/** -{{/* Install appimages only on non-wheel linux systems */}} +{{/* Non-wheel */}} {{ if eq .chezmoi.os "linux" }} {{ if .wheel }} + {{/* Install appimages only on non-wheel linux systems */}} .local/bin/ghostty + {{/* If wheel, source bashrc directly from global bashrc */}} + .bashrc + .bash_profile + .zshenv {{ end }} {{ end }} @@ -41,6 +46,8 @@ vim:ft=gotmpl {{/* Managed by home-manager */}} {{ if .nix }} .bashrc + .bash_profile + .zshenv .chezmoiscripts/linux/** .chezmoiscripts/unixlike/** .chezmoiexternals/** diff --git a/home/.chezmoiscripts/+nixos/run_once_after_nvim.sh b/home/.chezmoiscripts/+nixos/run_once_after_nvim.sh index 02ffe19..449dbd5 100644 --- a/home/.chezmoiscripts/+nixos/run_once_after_nvim.sh +++ b/home/.chezmoiscripts/+nixos/run_once_after_nvim.sh @@ -1,6 +1,8 @@ #!/bin/sh # shellcheck shell=sh +echo "[INFO] Running neovim healthcheck" + if command -v nvim > /dev/null 2>&1; then nvim --headless +checkhealth +"w nvim-healthcheck.txt" +qall fi diff --git a/home/.chezmoiscripts/darwin/run_once_desktopservices.sh b/home/.chezmoiscripts/darwin/run_once_desktopservices.sh index b648589..5f0e479 100644 --- a/home/.chezmoiscripts/darwin/run_once_desktopservices.sh +++ b/home/.chezmoiscripts/darwin/run_once_desktopservices.sh @@ -1,3 +1,7 @@ #!/bin/sh +set -x + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + +set +x diff --git a/home/.chezmoiscripts/darwin/run_once_touchid-sudo.sh b/home/.chezmoiscripts/darwin/run_once_touchid-sudo.sh index d102df4..6b2c961 100644 --- a/home/.chezmoiscripts/darwin/run_once_touchid-sudo.sh +++ b/home/.chezmoiscripts/darwin/run_once_touchid-sudo.sh @@ -1,15 +1,16 @@ #!/bin/sh -echo "Use TouchID to authenticate before running sudo commands." -echo "WARNING: This operation modifies critical system files." -echo "If something goes wrong, you may need to boot into macOS Recovery Mode to restore your system." -echo "To continue, type EXACTLY 'yes' and press Enter." +echo "[INFO] Use TouchID to authenticate before running sudo commands." +echo "[WARNING] This operation modifies critical system files." +echo " If something goes wrong, you may need to boot into macOS Recovery Mode to restore your system." +echo "[ACTION] To continue, type EXACTLY 'yes' and press Enter." read -p "Do you want to continue? (yes/no): " response if [ "$response" != "yes" ]; then - echo "Operation cancelled." + echo "[INFO] Operation cancelled." exit 0 # Exit with success status code fi echo "" - +set -x sudo cp ~/.dotfiles/misc/mac/etc/pam.d/sudo /etc/pam.d/sudo +set +x diff --git a/home/.chezmoiscripts/linux/run_once_after_fonts.sh b/home/.chezmoiscripts/linux/run_once_after_fonts.sh new file mode 100644 index 0000000..0b1efc2 --- /dev/null +++ b/home/.chezmoiscripts/linux/run_once_after_fonts.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "[INFO] Rebuilding fonts cache..." + +fc-cache -fv diff --git a/home/.chezmoiscripts/linux/run_onchange_after_firefox-configs.sh.tmpl b/home/.chezmoiscripts/linux/run_onchange_after_firefox-configs.sh.tmpl index 4801b98..c5de4b0 100644 --- a/home/.chezmoiscripts/linux/run_onchange_after_firefox-configs.sh.tmpl +++ b/home/.chezmoiscripts/linux/run_onchange_after_firefox-configs.sh.tmpl @@ -1,8 +1,15 @@ #!/bin/sh +# Check if firefox is installed +if ! command -v firefox &> /dev/null; then + echo "[WARNING] Firefox is not installed. Skip this script." + exit 0 +fi + src=~/.dotfiles/misc/firefox/search.json.mozlz4 dest=~/.mozilla/firefox/*.default/search.json.mozlz4 if ! cmp -s "$src" "$dest" 2>/dev/null; then + echo "[INFO] search.json.mozlz4 is updated, copying..." cp "$src" "$dest" fi @@ -11,7 +18,9 @@ fi src=~/.dotfiles/misc/firefox/policies.json dest=/etc/firefox/policies/policies.json if ! cmp -s "$src" "$dest" 2>/dev/null; then - sudo cp "$src" "$dest" + echo "[INFO] policies.json is updated, copying..." + echo "[ACTION] elevation required" + sudo cp "$src" "$dest" && exit 0 fi {{ end }} diff --git a/home/.chezmoiscripts/linux/run_onchange_after_fonts.sh b/home/.chezmoiscripts/linux/run_onchange_after_fonts.sh deleted file mode 100644 index 99d41f7..0000000 --- a/home/.chezmoiscripts/linux/run_onchange_after_fonts.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -fc-cache -fv diff --git a/home/.chezmoiscripts/unixlike/run_once_bash.sh b/home/.chezmoiscripts/unixlike/run_once_bash.sh deleted file mode 100644 index 6f6af51..0000000 --- a/home/.chezmoiscripts/unixlike/run_once_bash.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# shellcheck shell=sh - -sudo cp $CHEZMOI_SOURCE_DIR/dot_config/bash/xdg-compat.sh /etc/profile.d/xdg-compat.sh diff --git a/home/.chezmoiscripts/unixlike/run_once_bash.sh.tmpl b/home/.chezmoiscripts/unixlike/run_once_bash.sh.tmpl new file mode 100644 index 0000000..812f084 --- /dev/null +++ b/home/.chezmoiscripts/unixlike/run_once_bash.sh.tmpl @@ -0,0 +1,12 @@ +#!/bin/sh +# shellcheck shell=sh + +{{ if .wheel }} + +echo "[ACTION] Elevation required: " +echo " Setting XDG Environment Variables to global scope" +sudo cp $CHEZMOI_SOURCE_DIR/.chezmoitemplates/bash_profile /etc/profile.d/xdg-compat.sh + +{{ else }} + +{{ end }} diff --git a/home/.chezmoiscripts/unixlike/run_once_zsh-set-env.sh.tmpl b/home/.chezmoiscripts/unixlike/run_once_zsh-set-env.sh.tmpl index 568c119..a4bb536 100644 --- a/home/.chezmoiscripts/unixlike/run_once_zsh-set-env.sh.tmpl +++ b/home/.chezmoiscripts/unixlike/run_once_zsh-set-env.sh.tmpl @@ -1,9 +1,13 @@ #!/bin/sh +echo "[INFO] Running: zsh-set-env.sh" + XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" {{ if .wheel }} +echo "[INFO] " + if [ -f /etc/zshenv ]; then sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zshenv fi diff --git a/home/.chezmoitemplates/bash_profile b/home/.chezmoitemplates/bash_profile new file mode 100644 index 0000000..77a9e8a --- /dev/null +++ b/home/.chezmoitemplates/bash_profile @@ -0,0 +1,15 @@ +# Location: /etc/profile.d/xdg-compat.sh +# If elevated: copy it to /etc/profile.d/xdg-compat.sh +# Else: Set as .bash_profile + +# Set XDG Base Directory Path +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_STATE_HOME="$HOME/.local/state" +export XDG_RUNTIME_DIR="/run/user/$(id -u)" + +# Source user's XDG-compliant Bash configs +if [ -f "$XDG_CONFIG_HOME/bash/profile" ]; then + . "$XDG_CONFIG_HOME/bash/profile" +fi diff --git a/home/dot_config/bash/bashrc b/home/.chezmoitemplates/bashrc similarity index 100% rename from home/dot_config/bash/bashrc rename to home/.chezmoitemplates/bashrc diff --git a/home/dot_config/zsh/dot_zshenv b/home/.chezmoitemplates/zshenv similarity index 100% rename from home/dot_config/zsh/dot_zshenv rename to home/.chezmoitemplates/zshenv diff --git a/home/dot_bash_profile.tmpl b/home/dot_bash_profile.tmpl new file mode 100644 index 0000000..d6fd3c1 --- /dev/null +++ b/home/dot_bash_profile.tmpl @@ -0,0 +1 @@ +{{ template "bash_profile" . }} diff --git a/home/dot_bashrc.tmpl b/home/dot_bashrc.tmpl new file mode 100644 index 0000000..26a1101 --- /dev/null +++ b/home/dot_bashrc.tmpl @@ -0,0 +1 @@ +{{ template "bashrc" }} diff --git a/home/dot_config/bash/bashrc.tmpl b/home/dot_config/bash/bashrc.tmpl new file mode 100644 index 0000000..26a1101 --- /dev/null +++ b/home/dot_config/bash/bashrc.tmpl @@ -0,0 +1 @@ +{{ template "bashrc" }} diff --git a/home/dot_config/bash/profile b/home/dot_config/bash/profile index ec7c896..1b63c85 100644 --- a/home/dot_config/bash/profile +++ b/home/dot_config/bash/profile @@ -11,10 +11,6 @@ if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bash_profile" ]; then . "$HOME/.bash_profile" fi -if [ -n "$BASH_VERSION" ] && [ -f "$XDG_CONFIG_HOME/bash/bashrc" ]; then - . "$XDG_CONFIG_HOME/bash/bashrc" -fi - pathadd() { # 检查是否存在且不在 PATH 中 if [[ -d "$1" && ":$PATH:" != *":$1:"* ]]; then diff --git a/home/dot_config/git/_gitconfig.shared.tmpl b/home/dot_config/git/_gitconfig.shared.tmpl deleted file mode 100644 index 33adc3f..0000000 --- a/home/dot_config/git/_gitconfig.shared.tmpl +++ /dev/null @@ -1,76 +0,0 @@ -# vim:ft=gotmpl -# $DOTFILES/common/gitconfig.example -# Date: 2024-12-22 -# Author: js0ny - -# Location: -# Windows: %USERPROFILE%\.gitconfig -# *nix: ~/.config/git/config -# Linking: (Note that this file is an example, only copy this then edit) -# cp $DOTFILES/common/gitconfig.example ~/.config/git/config -[user] - name = {{ .username }} - email = {{ .email }} -[alias] - cl = clone - clnh = clone --depth 1 # Clone with no history - cma = commit -am # Add and commit - logs = log --oneline --graph --decorate --all # Show logs - last = log -1 HEAD # Show last commit - undo = reset --hard HEAD # Undo the last commit -[core] - editor = nvim - pager = delta - # autocrlf: - # true: Keep crlf in Windows, lf in *nix - # input: Keep lf in all platforms - autocrlf = input - safecrlf = true - excludesfile = $XDG_CONFIG_HOME/git/ignore - quotePath = false # zh-CN: 解决中文路径问题 - eol = lf -[core] -{{- if eq .chezmoi.os "windows" }} - editor = vim -{{- else }} - editor = nvim -{{- end }} - pager = delta - autocrlf = input # Force End of Line in different platforms -[interactive] - diffFilter = delta --color-only -[delta] - navigate = true - dark = true - features = catppuccin-mocha # Colorscheme -[diff] - tool = nvimdiff -[difftool] - prompt = false -[difftool "nvimdiff"] - cmd = "nvim -d \"$LOCAL\" \"$REMOTE\"" -[merge] - tool = nvimdiff -[mergetool] - prompt = false -[mergetool "nvimdiff"] - cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\"" -[color] - ui = auto -[pull] - ff = only -[init] - defaultBranch = master -[filter "lfs"] - clean = git-lfs clean -- %f - smudge = git-lfs smudge -- %f - process = git-lfs filter-process - required = true -# Force ssh -# Don't use ssh in GitHub since ssh-agent doesn't work in non-interactive environment -# While GitHub holds many plugins, it's better to use https -# This prevents from Neovide `publickey` error when installing plugins -# [url "git@github.com:"] -# insteadOf = https://github.com/ -[url "git@codeberg.org:"] - insteadOf = https://codeberg.org/ diff --git a/home/dot_config/zsh/dot_zshenv.tmpl b/home/dot_config/zsh/dot_zshenv.tmpl new file mode 100644 index 0000000..41b02fc --- /dev/null +++ b/home/dot_config/zsh/dot_zshenv.tmpl @@ -0,0 +1 @@ +{{ template "zshenv" }} diff --git a/home/dot_gitconfig b/home/dot_gitconfig index 4729650..aaa60ca 100644 --- a/home/dot_gitconfig +++ b/home/dot_gitconfig @@ -1 +1 @@ -{{ includeTemplate "dot_config/git/_gitconfig.shared.tmpl" . }} \ No newline at end of file +{{ template "gitconfig" . }} diff --git a/home/dot_zshenv.tmpl b/home/dot_zshenv.tmpl new file mode 100644 index 0000000..41b02fc --- /dev/null +++ b/home/dot_zshenv.tmpl @@ -0,0 +1 @@ +{{ template "zshenv" }} diff --git a/home/symlink_dot_bashrc b/home/symlink_dot_bashrc deleted file mode 100644 index 2ac1df5..0000000 --- a/home/symlink_dot_bashrc +++ /dev/null @@ -1 +0,0 @@ -/home/js0ny/.config/bash/bashrc diff --git a/nixcfgs/users/js0ny/programs/shell/aliases.nix b/nixcfgs/users/js0ny/programs/shell/aliases.nix index 35e67e7..abbe5dd 100644 --- a/nixcfgs/users/js0ny/programs/shell/aliases.nix +++ b/nixcfgs/users/js0ny/programs/shell/aliases.nix @@ -7,7 +7,7 @@ nrs = "sudo nixos-rebuild switch --flake ~/.dotfiles/nixcfgs"; clip = "wl-copy"; paste = "wl-paste"; - ipy = "nix run 'nixpkgs#python313Packages.ipython'"; # IPython + py = "nix run 'nixpkgs#python314'"; # Python Interactive Shell }; darwinAliases = { reboot = "sudo reboot";