image: debian/unstable
sources:
- https://git.sr.ht/~singpolyma/jmp-pay
packages:
- guix
- xz-utils
environment:
  GUIX_PROFILE: /var/guix/profiles/per-user/root/guix-profile
  CID: QmRpV6qo68sC3ZCwdZT4qcARw5jUWM6ixSEyxv5ojkhVca
  TARNAME: 2kld8phgqyr21daa2j4aq3nv4zmmrm2y-guix-tarball-pack.tar.xz
secrets:
- 9ded4157-4cf9-42ae-b7d0-55eb6e52ea37
- fd52c9ce-04e8-4684-af6c-1ab78d2e124a
artifacts:
- jmp-pay.scm
- jmp-pay.nar.xz
tasks:
- pull: |
    curl -O https://cloudflare-ipfs.com/ipfs/$CID/$TARNAME
    sudo systemctl stop guix-daemon
    sudo tar -C / -xJf $TARNAME
    sudo /sbin/start-stop-daemon -Sbmp /tmp/guix-daemon.pid -a $GUIX_PROFILE/bin/guix-daemon -- --build-users-group=_guixbuild
- bake: |
    . $GUIX_PROFILE/etc/profile
    hash guix
    sed '/^;;;;$/q' jmp-pay/jmp-pay.scm > jmp-pay.scm
    printf "(define-public jmp-pay\n\t" >> jmp-pay.scm
    cd jmp-pay
    printf "(use-modules (jmp-pay))\n(write jmp-pay-baked)\n" | guix repl -L. /dev/stdin >> ../jmp-pay.scm
    cd -
    printf ")" >> jmp-pay.scm
    rm -rf jmp-pay
- build: |
    . "$GUIX_PROFILE/etc/profile"
    hash guix
    guix build --no-grafts -L. jmp-pay
- archive: |
    . "$GUIX_PROFILE/etc/profile"
    hash guix
    sudo mv signing-key.pub /etc/guix/
    sudo mv signing-key.sec /etc/guix/
    sudo chown root:root /etc/guix/signing-key.sec
    sudo chmod 0400 /etc/guix/signing-key.sec
    guix archive --export -r --no-grafts -L. jmp-pay > jmp-pay.nar
    xz jmp-pay.nar
