image: guix
packages:
- plzip
sources:
- https://git.sr.ht/~singpolyma/sgx-jmp
secrets:
- 9ded4157-4cf9-42ae-b7d0-55eb6e52ea37
- fd52c9ce-04e8-4684-af6c-1ab78d2e124a
artifacts:
- sgx-jmp.scm
- sgx-jmp.nar.lz
tasks:
- bake: |
    printf "(define-module (sgx-jmp))\n" > sgx-jmp.scm
    sed '/^;;;;$/q' sgx-jmp/guix.scm >> sgx-jmp.scm
    printf "(define-public sgx-jmp\n\t" >> sgx-jmp.scm
    cd sgx-jmp
    printf '(load "%s/guix.scm")\n(write sgx-jmp-baked)\n' "$(pwd)" | guix time-machine --commit=3455a004ec78a8c8a579b74da8039fbcd36cea73 -- repl /dev/stdin >> ../sgx-jmp.scm
    cd -
    printf ")\n" >> sgx-jmp.scm
    rm -f sgx-jmp/guix.scm
    [ "$BUILD_REASON" = patchset ] || rm -rf sgx-jmp
- build: |
    if [ "$BUILD_REASON" = patchset ]; then with_source="--with-source=$PWD/sgx-jmp"; fi
    guix time-machine --commit=3455a004ec78a8c8a579b74da8039fbcd36cea73 -- guix build $with_source --no-grafts -r out -L. sgx-jmp
- archive: |
    if [ -e signing-key.sec ]; then
      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
    fi
    guix time-machine --commit=3455a004ec78a8c8a579b74da8039fbcd36cea73 -- guix archive --export -r --no-grafts $(readlink -f out) > sgx-jmp.nar
    plzip sgx-jmp.nar
