Files
nixos/pkgs/hms/hms.sh
T

39 lines
668 B
Bash
Raw Normal View History

2022-11-10 11:15:49 -06:00
# vim: set ft=bash:
2025-06-10 14:56:59 -05:00
set -ex -o pipefail
2022-11-10 11:15:49 -06:00
# Build and switch
2025-06-10 14:56:59 -05:00
system="$(uname -s)"
# Determine where the Flake is
if [ "$system" == "Darwin" ]; then
try_src="/etc/nix-darwin"
else
try_src="/etc/nixos"
fi
if [ -d "$try_src" ]; then
src="$try_src"
target="$(hostname)"
else
src="$HOME/.config/nix"
target="$(whoami)"
fi
# Find the hostname
echo "Building user for ${target}"
# Build the system
2022-11-10 11:15:49 -06:00
dest=$(mktemp -d)
2025-06-10 14:56:59 -05:00
trap cleanup 1 2 3 6 15
function cleanup {
echo "Cleaning up"
rm -r "${dest}"
exit
}
2022-11-10 11:15:49 -06:00
pushd "${dest}" > /dev/null
2025-06-10 14:56:59 -05:00
nom build "${src}#homeConfigurations.\"${target}\".activationPackage"
2022-11-10 11:15:49 -06:00
./result/activate
popd > /dev/null