nix-flakes/modules/nixos/features/packages/nr.nix
imnyang bbac123a8d
Some checks failed
CI / check (push) Has been cancelled
CI / ida (push) Has been cancelled
CI / cpt (push) Has been cancelled
CI / build-nixos (ena) (push) Has been cancelled
CI / build-nixos (hako) (push) Has been cancelled
CI / build-nixos (kazusa) (push) Has been cancelled
CI / build-nixos (mizuki) (push) Has been cancelled
wow
2026-07-03 00:45:07 +09:00

50 lines
No EOL
1.1 KiB
Nix

{ pkgs }:
pkgs.writeShellApplication {
name = "nr";
runtimeInputs = with pkgs; [
nix-output-monitor
openssh
coreutils
nix
attic-client
];
text = ''
set -e
TARGET_NAME="''${1:-$(hostname)}"
FLAKE_PATH="."
UPLOAD_CACHE=true
while [[ $# -gt 0 ]]; do
case "$1" in
--no-upload) UPLOAD_CACHE=false ;;
*) TARGET_NAME="$1" ;;
esac
shift
done
EXTRA_BUILD_FLAGS=()
if [ "$TARGET_NAME" = "kazusa" ]; then
EXTRA_BUILD_FLAGS+=("--max-substituter-jobs" "2")
fi
echo " ... $TARGET_NAME"
# shellcheck disable=SC2086
BUILD_PATH=$(nom build "$FLAKE_PATH#nixosConfigurations.$TARGET_NAME.config.system.build.toplevel" \
"''${EXTRA_BUILD_FLAGS[@]}" \
--print-out-paths --no-link)
echo " ..."
sudo nix-env --profile /nix/var/nix/profiles/system --set "$BUILD_PATH"
sudo "$BUILD_PATH/bin/switch-to-configuration" switch
if [ "$UPLOAD_CACHE" = true ]; then
echo " ..."
attic push imnyang "$BUILD_PATH" || echo " "
fi
echo " !"
'';
}