This commit is contained in:
암냥 2026-09-10 01:54:06 +09:00
commit ed42006971
No known key found for this signature in database
21 changed files with 271 additions and 366 deletions

View file

@ -6,16 +6,40 @@ pkgs.writeShellApplication {
nix-output-monitor
openssh
coreutils
nix
attic-client
];
text = ''
set -e
set -euo pipefail
TARGET_NAME=""
if [ $# -gt 0 ]; then
TARGET_NAME="$1"
fi
FLAKE_PATH="."
UPLOAD_CACHE=false
MAX_JOBS="''${NIX_BUILD_MAX_JOBS:-4}"
while [[ $# -gt 0 ]]; do
case "$1" in
--upload) UPLOAD_CACHE=true ;;
--no-upload) UPLOAD_CACHE=false ;;
--help|-h)
echo ": nrr <> [--upload|--no-upload]"
exit 0
;;
-*)
echo " : $1" >&2
exit 2
;;
*)
if [ -n "$TARGET_NAME" ]; then
echo " ." >&2
exit 2
fi
TARGET_NAME="$1"
;;
esac
shift
done
declare -A HOST_MAP
HOST_MAP["hikari"]="10.11.8.100"
@ -43,17 +67,20 @@ pkgs.writeShellApplication {
fi
echo " ..."
BUILD_PATH=$(nom build "$FLAKE_PATH#nixosConfigurations.$TARGET_NAME.config.system.build.toplevel" --print-out-paths --no-link --eval-cache --accept-flake-config)
BUILD_PATH=$(nom build "$FLAKE_PATH#nixosConfigurations.$TARGET_NAME.config.system.build.toplevel" \
--max-jobs "$MAX_JOBS" --print-out-paths --no-link)
echo " ... ($BUILD_PATH -> $TARGET_IP)"
nix copy --to "ssh://imnyang@$TARGET_IP" "$BUILD_PATH"
nix copy --substitute-on-destination --to "ssh://imnyang@$TARGET_IP" "$BUILD_PATH"
echo " ..."
# shellcheck disable=SC2029
ssh "imnyang@$TARGET_IP" "sudo nix-env --profile /nix/var/nix/profiles/system --set \"$BUILD_PATH\" && sudo $BUILD_PATH/bin/switch-to-configuration switch"
echo " ..."
attic push imnyang "$BUILD_PATH" || echo " "
if [ "$UPLOAD_CACHE" = true ]; then
echo " ..."
attic push imnyang "$BUILD_PATH" || echo " "
fi
echo " !"
'';