when:
  - event: ["push", "manual"]
    branch: ["main"]

engine: nixery

dependencies:
  nixpkgs:
    - nix
    - cachix
    - gnugrep

steps:
  - name: Authenticate
    command: |
      cachix authtoken "$CACHIX_AUTH_TOKEN"

  - name: Build and push x86_64
    command: |
      SUBS="--option extra-substituters https://tranquil.cachix.org --option extra-trusted-public-keys tranquil.cachix.org-1:PoO+mGL6a6LcJiPakMDHN4E218/ei/7v2sxeDtNkSRg="
      nix-store -qR --include-outputs $(nix-store -qd $(nix build .#packages.x86_64-linux.tranquil-pds $SUBS --print-out-paths --no-link)) | grep -v '\.drv$' | cachix push tranquil
      nix-store -qR --include-outputs $(nix-store -qd $(nix build .#packages.x86_64-linux.tranquil-frontend $SUBS --print-out-paths --no-link)) | grep -v '\.drv$' | cachix push tranquil

  - name: Build and push devShell
    command: |
      SUBS="--option extra-substituters https://tranquil.cachix.org --option extra-trusted-public-keys tranquil.cachix.org-1:PoO+mGL6a6LcJiPakMDHN4E218/ei/7v2sxeDtNkSRg="
      nix develop $SUBS --profile dev-profile -c true
      cachix push tranquil dev-profile
