Compare commits

..

No commits in common. "2ea9a291c453f3f5472cec13a106bd30579b78b5" and "21d150f6651f4c0beea59ba865861ae0f732a7a6" have entirely different histories.

1 changed files with 27 additions and 46 deletions

View File

@ -1,24 +1,24 @@
#!/bin/sh #!/bin/sh
[ -n "${DEBUG-}" ] && set -x [ ! -z "${DEBUG-}" ] && set -x
cd "$(dirname "$0")" || exit 1 cd "$(dirname $0)" || exit 1
if ! pgrep nix-daemon > /dev/null 2>&1 ; then if ! pgrep nix-daemon > /dev/null 2>&1 ; then
sh <"$(curl -L https://nixos.org/nix/install)" sh < $(curl -L https://nixos.org/nix/install)
fi fi
mkdir -p "$HOME/.config" mkdir -p "$HOME/.config"
mkdir -p "$HOME/.config/nix" mkdir -p "$HOME/.config/nix"
if [ ! -f "$HOME/.config/nix/nix.conf" ] ; then if [ ! -f "$HOME/.config/nix/nix.conf" ] ; then
echo "experimental-features = nix-command flakes" >>"$HOME/.config/nix/nix.conf" echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
echo "trusted-users = root andrew" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon echo "trusted-users = root andrew" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon
cachix use devenv cachix use devenv
nix profile install --accept-flake-config github:cachix/devenv/latest nix profile install --accept-flake-config github:cachix/devenv/latest
fi fi
has_bin() { function has_bin() {
[ -e "$HOME/.nix-profile/bin/$1" ] [ -e "$HOME/.nix-profile/bin/$1" ]
} }
@ -67,9 +67,7 @@ has_bin "llama" || nix profile install nixpkgs#llama
has_bin "mdbook" || nix profile install nixpkgs#mdbook has_bin "mdbook" || nix profile install nixpkgs#mdbook
has_bin "mosh" || nix profile install nixpkgs#mosh has_bin "mosh" || nix profile install nixpkgs#mosh
has_bin "nix-bisect" || nix profile install nixpkgs#nix-bisect has_bin "nix-bisect" || nix profile install nixpkgs#nix-bisect
# fails for some odd reason at the moment has_bin "nix-doc" || nix profile install nixpkgs#nix-doc
#has_bin "nix-doc" || nix profile install nixpkgs#nix-doc
command -v "nix-doc" >/dev/null || cargo install nix-doc
has_bin "nix-init" || nix profile install nixpkgs#nix-init has_bin "nix-init" || nix profile install nixpkgs#nix-init
has_bin "nix-search" || nix profile install github:peterldowns/nix-search-cli --refresh has_bin "nix-search" || nix profile install github:peterldowns/nix-search-cli --refresh
has_bin "nurl" || nix profile install nixpkgs#nurl has_bin "nurl" || nix profile install nixpkgs#nurl
@ -83,7 +81,6 @@ has_bin "rustfilt" || nix profile install nixpkgs#rustfilt
has_bin "sd" || nix profile install nixpkgs#sd has_bin "sd" || nix profile install nixpkgs#sd
has_bin "shellcheck" || nix profile install nixpkgs#shellcheck has_bin "shellcheck" || nix profile install nixpkgs#shellcheck
has_bin "shfmt" || nix profile install nixpkgs#shfmt has_bin "shfmt" || nix profile install nixpkgs#shfmt
has_bin "spacer" || nix profile install nixpkgs#spacer
has_bin "starship" || nix profile install nixpkgs#starship has_bin "starship" || nix profile install nixpkgs#starship
has_bin "terminal-notifier" || nix profile install nixpkgs#terminal-notifier has_bin "terminal-notifier" || nix profile install nixpkgs#terminal-notifier
has_bin "tig" || nix profile install nixpkgs#tig has_bin "tig" || nix profile install nixpkgs#tig
@ -95,30 +92,19 @@ has_bin "watchexec" || nix profile install nixpkgs#watchexec
has_bin "xcp" || nix profile install nixpkgs#xcp has_bin "xcp" || nix profile install nixpkgs#xcp
has_bin "xh" || nix profile install nixpkgs#xh has_bin "xh" || nix profile install nixpkgs#xh
has_bin "xsv" || nix profile install nixpkgs#xsv has_bin "xsv" || nix profile install nixpkgs#xsv
has_bin "zenith" || nix profile install nixpkgs#zenith
has_bin "zola" || nix profile install nixpkgs#zola has_bin "zola" || nix profile install nixpkgs#zola
has_bin "zoxide" || nix profile install nixpkgs#zoxide has_bin "zoxide" || nix profile install nixpkgs#zoxide
PATH="$PATH:$HOME/.nix-profile/bin" PATH="$PATH:$HOME/.nix-profile/bin"
newest_wezterm_release() { function newest_wezterm_release() {
curl -s -H "Accept: application/vnd.github+json" -L https://api.github.com/repos/wez/wezterm/releases/latest | jq -r '.assets | map(select(.name | startswith("WezTerm-macos"))) | first.browser_download_url' curl -H "Accept: application/vnd.github+json" -L https://api.github.com/repos/wez/wezterm/releases/latest | jq -r '.assets | map(select(.name | startswith("WezTerm-macos"))) | first.browser_download_url'
}
LATEST_WEZTERM=$(newest_wezterm_release)
install_latest_wezterm() {
curl -Lo wezterm.zip "$LATEST_WEZTERM"
ouch d wezterm.zip
mv WezTerm-macos-*/WezTerm.app /Applications/ && rm -rf wezterm.zip WezTerm-macos-*
} }
if [ ! -e /Applications/WezTerm.app ] ; then if [ ! -e /Applications/WezTerm.app ] ; then
install_latest_wezterm curl -Lo wezterm.zip $(latest_wezterm_release)
else ouch d wezterm.zip
current_wezterm=$(/Applications/WezTerm.app/Contents/MacOS/wezterm -V | awk '{print $2}') mv WezTerm-macos-*/WezTerm.app /Applications/ && rm -rf wezterm.zip WezTerm-macos-*
if ! echo "$LATEST_WEZTERM" | grep "$current_wezterm" >/dev/null; then
install_latest_wezterm
fi
fi fi
cat <<EOF > "$HOME/.wezterm.lua" cat <<EOF > "$HOME/.wezterm.lua"
@ -301,24 +287,19 @@ EOF
install -m 640 ./.zshrc "$HOME/" install -m 640 ./.zshrc "$HOME/"
AUTO_FILE="$HOME/.zshrc.auto" AUTO_FILE="$HOME/.zshrc.auto"
{ echo > "$AUTO_FILE"
atuin init zsh --disable-up-arrow atuin init zsh --disable-up-arrow >> "$AUTO_FILE"
direnv hook zsh direnv hook zsh >> "$AUTO_FILE"
starship init zsh --print-full-init starship init zsh --print-full-init >> "$AUTO_FILE"
zoxide init zsh zoxide init zsh >> "$AUTO_FILE"
} >"$AUTO_FILE"
[ -d /usr/local/bin ] || sudo mkdir /usr/local/bin [ -d /usr/local/bin ] || sudo mkdir /usr/local/bin
install_typst() { function install_typst() {
echo "manually installing typst" echo "manually installing typst"
curl -sLO https://github.com/typst/typst/releases/download/22-03-21-2/typst-x86_64-apple-darwin.tar.gz curl -sLO https://github.com/typst/typst/releases/download/22-03-21-2/typst-x86_64-apple-darwin.tar.gz
ouch d typst*.tar.gz ouch d typst*.tar.gz
sudo install -m 755 typst*/typst /usr/local/bin/ sudo install -m 755 typst*/typst /usr/local/bin/
rm -rf ./typst* rm -rf ./typst*
} }
[ -e "/usr/local/bin/typst" ] || install_typst [ -e "/usr/local/bin/typst" ] || install_typst
shellcheck "$0" || exit 1
shfmt -i 2 -d -s "$0"