#!/usr/bin/env nix-shell
#! nix-shell ./shell.nix -i bash
set -euo pipefail

mkdir -p state

if [ $(nixops list --state "$NIXOPS_STATE" | grep -c "$NIXOPS_DEPLOYMENT") -eq 0 ]; then
  nixops create ./deployment.nix --deployment "$NIXOPS_DEPLOYMENT" --state "$NIXOPS_STATE"
fi

nixops deploy "$@"