#!/usr/bin/env sh host="${1-tiamat}" root="$(git rev-parse --show-toplevel)" SYSTEM_OUT="$root/result-system" HOME_OUT="$root/result-home-soispha" check() { file="$1" if [ -s "$file" ]; then rm "$file" elif ! [ -e "$file" ]; then : "Ignore not existing files" else echo "ERROR: '$file' is not a symlink. Not removing it." 1>&2 exit 1 fi } build_system() { _val="$(nix build ".#nixosConfigurations.$host.config.system.build.toplevel" --print-out-paths --no-link)" exit_val="$?" if [ "$exit_val" -ne 0 ]; then echo "ERROR: Failed to build you system config for host: '$host'" 1>&2 printf 1 else printf "%s" "$_val" fi } system="$(build_system)" [ "$system" = "1" ] && exit 1 check "$SYSTEM_OUT" ln --symbolic "$system" "$SYSTEM_OUT" home="$(grep ExecStart= "$SYSTEM_OUT/etc/systemd/system/home-manager-soispha.service" | awk '{print $2}')" check "$HOME_OUT" ln --symbolic "$home" "$HOME_OUT" # vim: ft=sh