dotfiles/scripts/hm-switch.sh

25 lines
812 B
Bash
Raw Normal View History

2022-12-03 00:01:48 +00:00
#!/usr/bin/env sh
# NOTE: Untested on case of no home-manager
set -xv
# Where this script located
SCRIPT_DIR=$(realpath $(dirname $0))
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
HOME_MANAGER_DIR="${SCRIPT_DIR}/../nix-conf/home-manager"
# Mason is bad: it puts binaries onto xdg.data
# let's make mason starts fresh, just in case we introduce RPATH hacks
# that injects binary for Mason to use.
rm -rf ~/.local/share/nvim/mason
2022-12-03 00:01:48 +00:00
# test if we have home-manager, if not, attempt to use nix to put home-manager to
# our environment
2022-12-08 21:00:53 +00:00
if [ $(home-manager >/dev/null 2>&1) ]; then
# highly likely we don't even have nix support to start with, so let's fix that
nix-shell -p home-manager --run "home-manager switch --flake $HOME_MANAGER_DIR $@"
2022-12-03 00:01:48 +00:00
else
home-manager switch -b backup --flake "$HOME_MANAGER_DIR" $@
2022-12-03 00:01:48 +00:00
fi