when:
  - event: push
    branch: main

steps:
  - name: build & deploy
    image: nixos/nix
    # volumes:
    #   - /nix:/mnt/nix:ro
    commands:
      - |
        echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
        #echo 'store = unix:///mnt/nix/var/nix/daemon-socket/socket?root=/mnt' >> /etc/nix/nix.conf

      - nix build -L .

      - |
        nix-shell -p s3cmd --command 's3cmd \
          --host=static-sites.hoki-porgy.ts.net:9000 \
          --host-bucket=static-sites.hoki-porgy.ts.net:9000 \
          --no-ssl \
            sync result/* s3://noe.sh'
    environment:
      AWS_ACCESS_KEY_ID:
        from_secret: static_sites_client
      AWS_SECRET_ACCESS_KEY:
        from_secret: static_sites_secret
