From 68f03b321774fb43e0d9bdc1c2820a7bde374434 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 14 Jul 2023 20:50:49 +0900 Subject: [PATCH] Avoid to manage sheldon with Nix (#177) * Avoid to manage sheldon with Nix * Make silent installer * Avoid to making slower zsh exection --- .config/home-manager/home.nix | 6 ++---- .config/zsh/.zshrc | 14 ++++++++++++++ home/.zshenv | 19 +++++++++++-------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.config/home-manager/home.nix b/.config/home-manager/home.nix index 6d956bb4..04933f09 100644 --- a/.config/home-manager/home.nix +++ b/.config/home-manager/home.nix @@ -81,10 +81,8 @@ pkgs.gnumake pkgs.elmPackages.elm - # TODO: not yet officially supported macos, but works. - # So you should `NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 home-manager switch` in macos - # https://github.com/NixOS/nixpkgs/pull/177024/files#diff-82935a120aeca7ac66b6d3b13c94ddffb8b33c87849105f732ac59b26e7812c5R58 - pkgs.sheldon + # Do not manage sheldon with nix for unsupported Darwin https://github.com/kachick/dotfiles/issues/149 + # pkgs.sheldon # Required in many asdf(rtx) plugins pkgs.unzip diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 366893d7..1783f78d 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -6,6 +6,19 @@ # in ~/.zshenv, executed `unsetopt GLOBAL_RCS` and ignored /etc/zshrc [ -r /etc/zshrc ] && . /etc/zshrc +# https://github.com/kachick/dotfiles/issues/149 +_install_latest_sheldon() { + mkdir -p "$XDG_DATA_HOME/sheldon/bin" + # https://github.com/rossmacarthur/sheldon/blob/e989c2f1799988104ecf2dff4e5907d54fc1d693/README.md#pre-built-binaries + # Depending external resource without any hash ... :< + curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh | bash -s -- --repo rossmacarthur/sheldon --to "$XDG_DATA_HOME/sheldon/bin" +} + +# Do NOT use (( $+commands[sheldon] )) here. It made 1.5x slower zsh execution :< +if ! type 'sheldon' > /dev/null; then + _install_latest_sheldon +fi + eval "$(sheldon source)" # zsh-history-substring-search @@ -82,6 +95,7 @@ update_tools() { nix-channel --update home-manager switch + _install_latest_sheldon sheldon lock --update if command -v rtx; then rtx self-update diff --git a/home/.zshenv b/home/.zshenv index eb952fd9..148b4c39 100644 --- a/home/.zshenv +++ b/home/.zshenv @@ -5,6 +5,17 @@ # https://qiita.com/vintersnow/items/7343b9bf60ea468a4180 # zmodload zsh/zprof && zprof +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:=$HOME/.config}" +# Do NOT manage .zshenv(thisfile) in the dir. +export ZDOTDIR="${ZDOTDIR:=$XDG_CONFIG_HOME/zsh}" + +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_STATE_HOME="$HOME/.local/state" +export XDG_DATA_HOME="$HOME/.local/share" + +# https://github.com/kachick/dotfiles/issues/149 +path+=("$XDG_DATA_HOME/sheldon/bin") + export PATH export MANPATH # -U: keep only the first occurrence of each duplicated value @@ -21,14 +32,6 @@ if [ -x /usr/libexec/path_helper ]; then eval $(/usr/libexec/path_helper -s) fi -export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:=$HOME/.config}" -# Do NOT manage .zshenv(thisfile) in the dir. -export ZDOTDIR="${ZDOTDIR:=$XDG_CONFIG_HOME/zsh}" - -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_STATE_HOME="$HOME/.local/state" -export XDG_DATA_HOME="$HOME/.local/share" - # Actually not used? # https://wiki.archlinux.jp/index.php/XDG_Base_Directory # https://www.reddit.com/r/zsh/comments/tpwx9t/zcompcache_vs_zcompdump/