nix-flakes/modules/nixos/features/packages/dr.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

44 lines
941 B
Nix

{ pkgs }:
pkgs.writeShellApplication {
name = "dr";
runtimeInputs = with pkgs; [
nix-output-monitor
coreutils
nix
attic-client
];
text = ''
set -e
TARGET_NAME="''${1:-$(hostname -s)}"
FLAKE_PATH="."
UPLOAD_CACHE=true
while [[ $# -gt 0 ]]; do
case "$1" in
--no-upload) UPLOAD_CACHE=false ;;
*) TARGET_NAME="$1" ;;
esac
shift
done
echo "macOS ... ($TARGET_NAME)"
BUILD_PATH=$(nom build "$FLAKE_PATH#darwinConfigurations.$TARGET_NAME.system" --print-out-paths --no-link)
echo " ..."
sudo nix-env --profile /nix/var/nix/profiles/system --set "$BUILD_PATH"
sudo "$BUILD_PATH/activate"
if [ "$UPLOAD_CACHE" = true ]; then
echo " ..."
attic push imnyang "$BUILD_PATH" || echo " "
fi
echo "nix-darwin !"
'';
}