switch *args:
	sudo nixos-rebuild switch --flake ".#" --impure --option warn-dirty false {{args}}

switch-remote *args:
	# Switch using the remote master flake.
	sudo nixos-rebuild switch --flake "git+https://github.com/colonelpanic8/dotfiles.git?ref=master&dir=nixos#" --impure --option warn-dirty false {{args}}

switch-local *args:
	# Backwards-compat alias for local switch.
	sudo nixos-rebuild switch --flake ".#" --impure --option warn-dirty false {{args}}

switch-local-taffybar *args:
	# Like `switch-remote`, but use the local taffybar checkout (useful when hacking on it).
	# Note: requires the submodule/checkout to exist at ../dotfiles/config/taffybar/taffybar.
	bash -lc 'if systemctl is-active --quiet nixos-rebuild-switch-to-configuration.service; then \
	  echo "nixos-rebuild switch already running; waiting..." >&2; \
	  systemctl status nixos-rebuild-switch-to-configuration.service --no-pager >&2 || true; \
	  while systemctl is-active --quiet nixos-rebuild-switch-to-configuration.service; do sleep 1; done; \
	fi'
	sudo env IMALISON_TAFFYBAR_LIVE_CHECKOUT=/home/imalison/dotfiles/dotfiles/config/taffybar/taffybar \
	  nixos-rebuild switch --flake "git+https://github.com/colonelpanic8/dotfiles.git?ref=master&dir=nixos#" --impure --option warn-dirty false \
	  --override-input taffybar git+file:///home/imalison/dotfiles/dotfiles/config/taffybar/taffybar \
	  {{args}}

remote-switch host *args:
	nixos-rebuild switch --flake "git+https://github.com/colonelpanic8/dotfiles.git?ref=master&dir=nixos#{{host}}" --target-host {{host}}.local --sudo --impure --option warn-dirty false {{args}}

fix-local-path-issue:
	# Kept for backwards-compat: update the lockfile inputs explicitly.
	nix flake update taffybar imalison-taffybar
