diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..802502e26 --- /dev/null +++ b/.envrc @@ -0,0 +1,8 @@ +# Initialize git submodules (required for cabal packages in server/modules/) +git submodule update --init --recursive + +# git+file: (not path:) is required for ?submodules=1 support. +# Without direnv, run: +# git submodule update --init --recursive +# nix develop "git+file:.?submodules=1" --impure +use flake "git+file:.?submodules=1" --impure diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 73363164c..c2e4f8891 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -1,650 +1,174 @@ +--- name: Continuous Integration on: workflow_dispatch: pull_request: - branches: [ "master" ] + branches: + - master push: - branches: [ "master", "v*.*" ] - tags: [ "*.*.*" ] + branches: + - master -jobs: - - # █████████ ███████████ ███ ████ █████ - # ███░░░░░███ ░░███░░░░░███ ░░░ ░░███ ░░███ - # ░███ ░░░ ██████ ████████ █████ █████ ██████ ████████ ░███ ░███ █████ ████ ████ ░███ ███████ - # ░░█████████ ███░░███░░███░░███░░███ ░░███ ███░░███░░███░░███ ░██████████ ░░███ ░███ ░░███ ░███ ███░░███ - # ░░░░░░░░███░███████ ░███ ░░░ ░███ ░███ ░███████ ░███ ░░░ ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███ - # ███ ░███░███░░░ ░███ ░░███ ███ ░███░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ - # ░░█████████ ░░██████ █████ ░░█████ ░░██████ █████ ███████████ ░░████████ █████ █████░░████████ - # ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ +env: + CARDANO_NODE_VERSION: "11.0.1" + NETWORK: preview + S3_DB_PATH: s3://${{ secrets.AWS_S3_BUCKET }}/db-preview - server_build: - strategy: - matrix: - os: [ linux ] - arch: [ x86_64, aarch64 ] - compiler: [ ghc96 ] - devx-version: [ 887b833d89db35168fbd4f10afb6f93d26d70f9a ] - - runs-on: ${{ matrix.os == 'linux' && matrix.arch == 'aarch64' && 'buildjet-16vcpu-ubuntu-2204-arm' || 'ubuntu-22.04' }} +jobs: + # TODO: switch back to this once Hydra reports check-runs to GitHub + # wait-for-hydra: + # runs-on: ubuntu-latest + # steps: + # - name: Wait for Hydra build + # env: + # GH_TOKEN: ${{ github.token }} + # run: | + # check_name="ci/hydra-build:required" + # while true; do + # conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/check-runs?check_name=$check_name" \ + # --paginate --jq '.check_runs[].conclusion') + # case "$conclusion" in + # success) echo "Hydra build succeeded"; exit 0 ;; + # "") echo "Hydra build pending, waiting 30s..."; sleep 30 ;; + # *) echo "Hydra build failed with: $conclusion"; exit 1 ;; + # esac + # done + clients_TypeScript: + # needs: + # - wait-for-hydra + runs-on: ubuntu-24.04 steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: submodules: true + persist-credentials: false - - name: 📝 Version - id: version - shell: bash - working-directory: server - run: | - VERSION=$(cat package.yaml | grep "version:" | sed "s/[^0-9]*\([0-9]\)\(.[0-9].[0-9]\)*/\1\2/") - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - name: Install Nix with good defaults - uses: cachix/install-nix-action@v22 + - name: Install Nix + uses: cachix/install-nix-action@b97f05dcb019ddea06450a50ef6203d2fdc19fee # v31 with: extra_nix_config: | trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= substituters = https://cache.iog.io/ https://cache.nixos.org/ - nix_path: nixpkgs=channel:nixos-unstable - - - uses: cachix/cachix-action@v14 - with: - name: cardano-ogmios - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - - name: ❄️ Prepare cache (x86_64) - if: ${{ matrix.arch == 'x86_64' }} - working-directory: server - run: | - nix develop github:input-output-hk/devx/${{ matrix.devx-version}}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cat /nix/store/vd865r55pdbndjwh994h90m35qq77x44-cabal.project.local >> cabal.project.local && cabal update && cabal freeze" - - - name: ❄️ Prepare cache (aarch64) - if: ${{ matrix.arch == 'aarch64' }} - working-directory: server - run: | - nix develop github:input-output-hk/devx/${{ matrix.devx-version}}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cat /nix/store/hviyb5sciblcyr5fc3vsqcwmfh1nz69w-cabal.project.local >> cabal.project.local && cabal update && cabal freeze" - - name: 💾 Download Cache - uses: actions/cache/restore@v4 - with: - path: | - ~/.cabal-static/packages - ~/.cabal-static/store - server/dist-newstyle - key: cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ hashFiles('server/cabal.project.freeze') }} - restore-keys: | - cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }} + # Temporary: poll the Nix cache directly until Hydra check-run reporting is fixed + - name: Wait for ogmios-exe in Hydra cache + run: | + out=$(nix eval --raw "git+https://github.com/$GITHUB_REPOSITORY?rev=$GITHUB_SHA&submodules=1#ogmios-exe") + echo "Waiting for $out in cache..." + deadline=$((SECONDS + 1800)) + while true; do + if nix path-info --store https://cache.iog.io "$out" >/dev/null 2>&1; then + echo "Found in cache" + break + fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "Timed out after 30 minutes waiting for Hydra cache" + exit 1 + fi + echo "Not in cache yet, waiting 30s..." + sleep 30 + done - - name: 🔨 Dependencies - working-directory: server + - name: Download ogmios binary from Hydra cache run: | - nix develop github:input-output-hk/devx/${{ matrix.devx-version }}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cabal build --enable-executable-static --only-dependencies ogmios:lib:ogmios" - env: - GIT_SHA: ${{ github.sha }} + nix build .#ogmios-exe --builders "" --max-jobs 0 + mkdir -p server/bin + cp result/bin/ogmios server/bin/ogmios + chmod +x server/bin/ogmios - - name: 💾 Save Cache - uses: actions/cache/save@v4 - with: - path: | - ~/.cabal-static/packages - ~/.cabal-static/store - server/dist-newstyle - key: cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ hashFiles('server/cabal.project.freeze') }} - - - name: 🔨 Build - working-directory: server - run: | - nix develop github:input-output-hk/devx/${{ matrix.devx-version }}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cabal build --enable-executable-static ogmios:exe:ogmios" + - name: Download cardano-node configs env: - GIT_SHA: ${{ github.sha }} - - - name: 📦 Package + BASE_URL: https://raw.githubusercontent.com/input-output-hk/cardano-playground/refs/tags/node-${{ env.CARDANO_NODE_VERSION }}-config/docs/environments/preview run: | - mkdir -p bin - cp ./server/dist-newstyle/build/${{ matrix.arch }}-${{ matrix.os }}/ghc-${{ matrix.compiler == 'ghc96' && '9.6.5' }}/ogmios-${{ steps.version.outputs.version }}/x/ogmios/build/ogmios/ogmios ./bin/ogmios - mkdir -p share && chmod +w share - mkdir -p share/zsh/site-functions - ./bin/ogmios --zsh-completion-script ogmios > ./share/zsh/site-functions/_ogmios - mkdir -p share/bash-completion/completions - ./bin/ogmios --bash-completion-script ogmios > ./share/bash-completion/completions/ogmios - chmod -w share - - - name: 🔬 Version Sanity Check - if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }} - id: version-check - shell: bash - run: | - OUTPUT=$(./bin/ogmios --version) - - if [[ $CABAL == "0" ]]; then - VERSION="nightly" - else - VERSION="v$CABAL" - fi - - if [[ $GITHUB_REF == "refs/tags"* ]]; then - TAG=$(echo ${GITHUB_REF/refs\/tags\/} | sed "s/^.*\(v[0-9].[0-9].[0-9]\).*$/\1/") - else - TAG="nightly" - fi + mkdir -p config/preview + cd config/preview + for f in config.json topology.json peer-snapshot.json checkpoints.json \ + byron-genesis.json shelley-genesis.json alonzo-genesis.json conway-genesis.json; do + curl -sfLO "$BASE_URL/$f" + done - echo "git: $TAG <-- ${GITHUB_REF/refs\/tags\/}" - echo "cabal: $VERSION <-- $CABAL" - echo "bin: $OUTPUT" - echo "" - - if [[ $OUTPUT == $TAG* ]] && [[ $OUTPUT == $VERSION* ]]; then - echo "tag=$TAG" >> $GITHUB_OUTPUT - echo "Ok." - exit 0 - else - echo "x inconsistent versions" - exit 1 - fi - env: - CABAL: ${{ steps.version.outputs.version }} - - - name: 📎 Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }} - path: | - bin - share - - # █████████ █████ ███ █████ - # ███░░░░░███ ░░███ ░░░ ░░███ - # ░███ ░░░ ██████ ████████ █████ █████ ██████ ████████ ░███ ████ ████████ ███████ - # ░░█████████ ███░░███░░███░░███░░███ ░░███ ███░░███░░███░░███ ░███ ░░███ ░░███░░███ ░░░███░ - # ░░░░░░░░███░███████ ░███ ░░░ ░███ ░███ ░███████ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ - # ███ ░███░███░░░ ░███ ░░███ ███ ░███░░░ ░███ ░███ █ ░███ ░███ ░███ ░███ ███ - # ░░█████████ ░░██████ █████ ░░█████ ░░██████ █████ ███████████ █████ ████ █████ ░░█████ - # ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░ - - server_lint: - strategy: - matrix: - os: [ ubuntu-22.04 ] - runs-on: ${{ matrix.os }} - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3.5.3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@ff717079ee2060e4bcee96c4779b553acc87447c # v4 with: - submodules: true + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} - - name: 🔬 hlint - working-directory: server - shell: bash + - name: Restore cardano-node DB from S3 + shell: bash {0} env: - PACKAGE: hlint - REPOSITORY: ndmitchell/hlint - PLATFORM: x86_64-linux - RELEASE: v3.6.1 - VERSION: 3.6.1 - run: | - curl -sSL https://raw.github.com/cardanosolutions/ogmios/master/scripts/exec-from-github.sh | sh -s src test app -h .hlint.yaml - - - name: 🧐 stylish-haskell - working-directory: server - shell: bash - env: - PACKAGE: stylish-haskell - REPOSITORY: jaspervdj/stylish-haskell - PLATFORM: linux-x86_64 - RELEASE: v0.14.5.0 - VERSION: v0.14.5.0 - run: | - curl -sSL https://raw.github.com/cardanosolutions/ogmios/master/scripts/exec-from-github.sh | sh -s $(find src test app -type f -name '*.hs' ! -path '*.stack-work*') -i -c .stylish-haskell.yaml - if [ -z "$(git status --porcelain)" ]; then - echo "No style errors detected." - else - echo "Style errors detected:" - git diff + RUNNER_TEMP: ${{ runner.temp }} + run: | + mkdir -p "$RUNNER_TEMP/db-preview" + for attempt in 1 2 3; do + echo "S3 sync attempt $attempt..." + nix shell nixpkgs#s5cmd -c \ + s5cmd --log error sync "$S3_DB_PATH/*" "$RUNNER_TEMP/db-preview/" > /tmp/s3-sync.log 2>&1 & + pid=$! + while kill -0 "$pid" 2>/dev/null; do + du -sh "$RUNNER_TEMP/db-preview" 2>/dev/null + sleep 15 + done + wait "$pid" + rc=$? + echo "S3 sync attempt $attempt finished (exit $rc). Last 30 lines of log:" + tail -30 /tmp/s3-sync.log + if [ "$rc" -eq 0 ]; then + echo "S3 sync succeeded" + break + fi + if [ "$attempt" -eq 3 ]; then exit 1 - fi - - # - # ███████████ █████████ ███ █████ █████████ ████ ███ █████ - # ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ███░░░░░███░░███ ░░░ ░░███ - # ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ███ ░░░ ░███ ████ ██████ ████████ ███████ - # ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░███ ░███ ░░███ ███░░███░░███░░███ ░░░███░ - # ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░███ ░███ ░███ - # ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░░███ ███ ░███ ░███ ░███░░░ ░███ ░███ ░███ ███ - # █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ ░░█████████ █████ █████░░██████ ████ █████ ░░█████ - # ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░ - # ███ ░███ ░███ ░███ - # ░░██████ █████ █████ - # ░░░░░░ ░░░░░ ░░░░░ - - clients_TypeScript: - needs: [server_build] - strategy: - matrix: - os: [ linux ] - arch: [ x86_64 ] - network: [ preview ] - cardano-node: [ 10.5.1 ] - - runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }} - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3 - with: - submodules: true - - - name: ⌚ Get Date/Time - id: date-time - shell: bash - run: | - echo "::set-output name=value::$(/bin/date -u "+%Y%m%d-%H%M%S")" + fi + echo "Retrying..." + done - - name: 🧰 Setup Node.js - uses: actions/setup-node@v3.7.0 + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: lts/jod - - name: 🔨 Build + - name: Build TypeScript client working-directory: clients/TypeScript run: | yarn install --frozen-lockfile --non-interactive --logevel=error yarn build yarn lint - - name: 📥 Download - uses: actions/download-artifact@v4 - with: - name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }} - path: server - - - name: 💾 Cache cardano-node DB - id: cache - uses: actions/cache@v4 - with: - path: ${{ runner.temp }}/db-${{ matrix.network }} - key: cardano-node-ogmios-${{ matrix.network }}-${{ steps.date-time.outputs.value }} - restore-keys: | - cardano-node-ogmios-${{ matrix.network }}- - - - name: 🔬 Test - if: ${{ matrix.network == 'preview' }} + - name: Start cardano-node and wait for sync + id: sync working-directory: clients/TypeScript - shell: bash env: - CONFDIR: /home/runner/work/ogmios/ogmios/server/config/network/${{ matrix.network }} + CONFDIR: ${{ github.workspace }}/config/preview + RUNNER_TEMP: ${{ runner.temp }} run: | - chmod +x ../../server/bin/ogmios - sudo ../../server/bin/ogmios --port 1337 --log-level error --node-socket ${{ runner.temp }}/ipc/node.socket --node-config $CONFDIR/cardano-node/config.json & + sudo ../../server/bin/ogmios --port 1337 --log-level error --node-socket "$RUNNER_TEMP/ipc/node.socket" --node-config "$CONFDIR/config.json" & - docker pull ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }} docker run -d --name cardano-node \ - -v ${{ runner.temp }}/db-${{ matrix.network }}:/db \ - -v ${{ runner.temp }}/ipc:/ipc \ - -v $CONFDIR/cardano-node:/config \ - -v $CONFDIR/genesis:/genesis \ - ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }} run --config /config/config.json --database-path /db --socket-path /ipc/node.socket --topology /config/topology.json + -v "$RUNNER_TEMP/db-preview:/db" \ + -v "$RUNNER_TEMP/ipc:/ipc" \ + -v "$CONFDIR:/config" \ + "ghcr.io/intersectmbo/cardano-node:$CARDANO_NODE_VERSION" run --config /config/config.json --database-path /db --socket-path /ipc/node.socket --topology /config/topology.json ../../scripts/wait-for-sync.sh 1337 1 "docker logs --since 10s cardano-node" - yarn test - docker stop cardano-node - docker rm cardano-node - - # - # ███████████ █████████ ███ █████ ███████████ ██████████ ███████████ █████ - # ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ░░███░░░░░███ ░░███░░░░░█░░███░░░░░███░░███ - # ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ░███ ░███ ░███ █ ░ ░███ ░███ ░███ - # ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░██████████ ░██████ ░██████████ ░███ - # ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███░░░░░███ ░███░░█ ░███░░░░░░ ░███ - # ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░███ ░███ ░ █ ░███ ░███ █ - # █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ █████ █████ ██████████ █████ ███████████ - # ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░░░░░░░ - # ███ ░███ ░███ ░███ - # ░░██████ █████ █████ - # ░░░░░░ ░░░░░ ░░░░░ - - clients_TypeScript_repl: - if: ${{ github.event_name == 'push' }} - runs-on: ${{ matrix.os }} - needs: [clients_TypeScript] - strategy: - matrix: - os: [ ubuntu-22.04 ] - target: [linux,macos,win.exe] - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3.5.3 - - - name: 🧰 Setup Node.js - uses: actions/setup-node@v3.7.0 - with: - node-version: lts/jod - - - name: 📦 Package REPL + - name: Run integration tests working-directory: clients/TypeScript - run: | - yarn install --frozen-lockfile --non-interactive --logevel=error - yarn repl:pkg - - - name: 📎 Upload REPL exe - uses: actions/upload-artifact@v4 - with: - name: cardano-ogmios-repl-${{ matrix.target }}-${{ github.sha }} - path: clients/TypeScript/packages/repl/build/cardano-ogmios-repl-${{ matrix.target }} + run: yarn test - # ███████████ █████████ ███ █████ ██████ █████ ███████████ ██████ ██████ - # ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ░░██████ ░░███ ░░███░░░░░███░░██████ ██████ - # ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ░███░███ ░███ ░███ ░███ ░███░█████░███ - # ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░███░░███░███ ░██████████ ░███░░███ ░███ - # ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ ░░██████ ░███░░░░░░ ░███ ░░░ ░███ - # ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░░█████ ░███ ░███ ░███ - # █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ █████ ░░█████ █████ █████ █████ - # ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ - # ███ ░███ ░███ ░███ - # ░░██████ █████ █████ - # ░░░░░░ ░░░░░ ░░░░░ - - clients_TypeScript_npm: - if: ${{ github.event_name == 'push' }} - runs-on: ${{ matrix.os }} - needs: [clients_TypeScript] - strategy: - matrix: - os: [ ubuntu-22.04 ] - package: [ schema, client, repl ] - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3.5.3 - - - name: 🧰 Setup Node.js - uses: actions/setup-node@v3.7.0 - with: - node-version: lts/jod - - - name: 📦 Pack - working-directory: clients/TypeScript - run: | - yarn install --frozen-lockfile --non-interactive --logevel=error - ./scripts/pack.sh - - - name: 📎 Upload npm packages - uses: actions/upload-artifact@v4 - with: - name: cardano-ogmios-clients-ts-packages - path: | - clients/TypeScript/cardano-ogmios-client-${{ github.sha }}.tgz - clients/TypeScript/cardano-ogmios-schema-${{ github.sha }}.tgz - clients/TypeScript/cardano-ogmios-repl-${{ github.sha }}.tgz - - - name: 📤 Publish client package to npm registry - if: ${{ startsWith(github.ref, 'refs/tags') }} - uses: JS-DevTools/npm-publish@v2 - with: - package: clients/TypeScript/packages/${{ matrix.package }}/package.json - strategy: upgrade - token: ${{ secrets.NPM_TOKEN }} - - # ██████████ ███████ █████████ █████ ████ ██████████ ███████████ - # ░░███░░░░███ ███░░░░░███ ███░░░░░███░░███ ███░ ░░███░░░░░█░░███░░░░░███ - # ░███ ░░███ ███ ░░███ ███ ░░░ ░███ ███ ░███ █ ░ ░███ ░███ - # ░███ ░███░███ ░███░███ ░███████ ░██████ ░██████████ - # ░███ ░███░███ ░███░███ ░███░░███ ░███░░█ ░███░░░░░███ - # ░███ ███ ░░███ ███ ░░███ ███ ░███ ░░███ ░███ ░ █ ░███ ░███ - # ██████████ ░░░███████░ ░░█████████ █████ ░░████ ██████████ █████ █████ - # ░░░░░░░░░░ ░░░░░░░ ░░░░░░░░░ ░░░░░ ░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ - - docker_combined: - needs: [ server_build ] - runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }} - strategy: - matrix: - os: [ linux ] - target: [ cardano-node-ogmios ] - network: [ mainnet, preprod, preview ] - cardano-node: [ 10.5.1 ] - cardano-node-latest: [ 10.5.1 ] - arch: [ x86_64 ] - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3 - with: - submodules: true - - - name: 🧰 Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: 🧐 hadolint - uses: brpaz/hadolint-action@v1.5.0 - with: - dockerfile: "./Dockerfile" - failure-threshold: warning - ignore: DL3029 DL3059 - - - name: 🐳 Login to DockerHub - if: ${{ github.event_name == 'push' }} - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - - name: 📝 Base Variables - id: base-variables + - name: Stop cardano-node + if: always() && steps.sync.outcome != 'skipped' run: | - echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT - - - name: 📝 Tag Variables - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} - id: tag-variables - run: | - echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT - - - name: 📥 Download - uses: actions/download-artifact@v4 - with: - name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }} - path: server - - - name: "📸 :latest" - id: build - if: ${{ github.event_name == 'push' && matrix.network == 'mainnet' && github.ref == 'refs/heads/master' }} - uses: docker/build-push-action@v4 - with: - build-args: | - NETWORK=${{ matrix.network }} - CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node-latest }} - context: . - push: true - tags: ${{ steps.base-variables.outputs.image }}:latest - target: ${{ matrix.target }} - platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest - cache-to: type=inline - - - name: "📸 :latest-${{ matrix.network }}" - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - uses: docker/build-push-action@v4 - with: - build-args: | - NETWORK=${{ matrix.network }} - CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node-latest }} - context: . - push: true - tags: ${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }} - target: ${{ matrix.target }} - platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }} - cache-to: type=inline - - - name: "🏷️ :v*.*.*" - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && matrix.network == 'mainnet' }} - uses: docker/build-push-action@v4 - with: - build-args: | - NETWORK=${{ matrix.network }} - CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }} - context: . - push: true - tags: ${{ steps.base-variables.outputs.image }}:${{ steps.tag-variables.outputs.tag }}_${{ matrix.cardano-node }} - target: ${{ matrix.target }} - platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest - cache-to: type=inline - - - name: "🏷️ :v*.*.*-${{ matrix.network }}" - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} - uses: docker/build-push-action@v4 - with: - build-args: | - NETWORK=${{ matrix.network }} - CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }} - context: . - push: true - tags: ${{ steps.base-variables.outputs.image }}:${{ steps.tag-variables.outputs.tag }}_${{ matrix.cardano-node }}-${{ matrix.network }} - target: ${{ matrix.target }} - platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }} - cache-to: type=inline + docker stop cardano-node || true + docker rm cardano-node || true - docker_standalone: - needs: [ server_build ] - runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }} - strategy: - matrix: - os: [ linux ] - target: [ ogmios ] - arch: [ x86_64, aarch64 ] - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3 - with: - submodules: true - - - name: 🧰 Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: 🧐 hadolint - uses: brpaz/hadolint-action@v1.5.0 - with: - dockerfile: "./Dockerfile" - failure-threshold: warning - ignore: DL3029 DL3059 - - - name: 🐳 Login to DockerHub - if: ${{ github.event_name == 'push' }} - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - - name: 📝 Base Variables - id: base-variables - run: | - echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT - - - name: 📝 Tag Variables - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} - id: tag-variables - run: | - echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT - - - name: 📝 Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.base-variables.outputs.image }} - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern=v{{version}} - - - name: 📥 Download - uses: actions/download-artifact@v4 - with: - name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }} - path: server - - - name: 📸 Build image - id: build - if: ${{ github.event_name == 'push' }} - uses: docker/build-push-action@v4 - with: - context: . - target: ${{ matrix.target }} - platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest - cache-to: type=inline - outputs: type=image,name=${{ steps.base-variables.outputs.image }},push-by-digest=true,name-canonical=true,push=true - - - name: 🔡 Export digest - if: ${{ github.event_name == 'push' }} + - name: Save cardano-node DB to S3 + if: always() && steps.sync.outcome == 'success' + env: + RUNNER_TEMP: ${{ runner.temp }} run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: 💾 Upload digest - if: ${{ github.event_name == 'push' }} - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - registry: - needs: [ docker_standalone ] - runs-on: ubuntu-22.04 - strategy: - matrix: - target: [ ogmios ] - steps: - - name: 📥 Download digests (amd) - uses: actions/download-artifact@v4 - with: - name: digests-amd64 - path: /tmp/digests - - - name: 📥 Download digests (arm) - uses: actions/download-artifact@v4 - with: - name: digests-arm64 - path: /tmp/digests - - - name: 🧰 Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: 📝 Base Variables - id: base-variables - run: | - echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT - - - name: 📝 Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.base-variables.outputs.image }} - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern=v{{version}} - - - name: 🐳 Login to DockerHub - if: ${{ github.event_name == 'push' }} - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - - name: 📦 Create manifest list and push - if: ${{ github.event_name == 'push' }} - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ steps.base-variables.outputs.image }}@sha256:%s ' *) - - - name: 🧐 Inspect image - if: ${{ github.event_name == 'push' }} - run: | - docker buildx imagetools inspect ${{ steps.base-variables.outputs.image }}:${{ steps.meta.outputs.version }} + nix shell nixpkgs#s5cmd -c \ + s5cmd --log error sync "$RUNNER_TEMP/db-preview/" "$S3_DB_PATH/" diff --git a/.github/workflows/network-synchronization.yaml b/.github/workflows/network-synchronization.yaml index de6904062..7e1bdc6ce 100644 --- a/.github/workflows/network-synchronization.yaml +++ b/.github/workflows/network-synchronization.yaml @@ -1,8 +1,9 @@ +--- name: Network Synchronization on: schedule: - - cron: '00 06,18 * * *' + - cron: '00 06 */2 * *' workflow_dispatch: inputs: synchronization-level: @@ -11,39 +12,109 @@ on: default: 1 type: number +env: + CARDANO_NODE_VERSION: "11.0.1" + S3_DB_PATH: s3://${{ secrets.AWS_S3_BUCKET }}/db-preview + jobs: sync_and_cache: - strategy: - matrix: - network: [ preview ] - ogmios_version: [ v6.11.0 ] - cardano_node_version: [ 10.1.4 ] - - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - - name: 📥 Checkout repository - uses: actions/checkout@v3.5.3 - - - name: ⌚ Get Date/Time - id: date-time - shell: bash + - name: Download cardano-node configs + env: + BASE_URL: https://raw.githubusercontent.com/input-output-hk/cardano-playground/refs/tags/node-${{ env.CARDANO_NODE_VERSION }}-config/docs/environments/preview run: | - echo "timestamp=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT + mkdir -p config/preview + cd config/preview + for f in config.json topology.json peer-snapshot.json checkpoints.json \ + byron-genesis.json shelley-genesis.json alonzo-genesis.json conway-genesis.json; do + curl -sfLO "$BASE_URL/$f" + done - - name: 💾 Cache cardano-node DB - id: cache - uses: actions/cache@v4 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@ff717079ee2060e4bcee96c4779b553acc87447c # v4 with: - path: ${{ runner.temp }}/db-${{ matrix.network }} - key: cardano-node-ogmios-${{ matrix.network }}-${{ steps.date-time.outputs.timestamp }} - restore-keys: | - cardano-node-ogmios-${{ matrix.network }}- + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} - - name: ⟲ Sync Node - uses: CardanoSolutions/gh-action-cardano-node-ogmios-docker-sync@v1.2.2 + - name: Install Nix + uses: cachix/install-nix-action@b97f05dcb019ddea06450a50ef6203d2fdc19fee # v31 with: - db-dir: ${{ runner.temp }}/db-${{ matrix.network }} - network: ${{ matrix.network }} - version: ${{ matrix.ogmios_version }}_${{ matrix.cardano_node_version }} - synchronization-level: ${{ inputs.synchronization-level || 1 }} + extra_nix_config: | + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= + substituters = https://cache.iog.io/ https://cache.nixos.org/ + + - name: Restore cardano-node DB from S3 + shell: bash {0} + env: + RUNNER_TEMP: ${{ runner.temp }} + run: | + mkdir -p "$RUNNER_TEMP/db-preview" + for attempt in 1 2 3; do + echo "S3 sync attempt $attempt..." + nix shell nixpkgs#s5cmd -c \ + s5cmd --log error sync "$S3_DB_PATH/*" "$RUNNER_TEMP/db-preview/" > /tmp/s3-sync.log 2>&1 & + pid=$! + while kill -0 "$pid" 2>/dev/null; do + du -sh "$RUNNER_TEMP/db-preview" 2>/dev/null + sleep 15 + done + wait "$pid" + rc=$? + echo "S3 sync attempt $attempt finished (exit $rc). Last 30 lines of log:" + tail -30 /tmp/s3-sync.log + if [ "$rc" -eq 0 ]; then + echo "S3 sync succeeded" + break + fi + if [ "$attempt" -eq 3 ]; then + exit 1 + fi + echo "Retrying..." + done + + - name: Sync node + id: sync + env: + CONFDIR: ${{ github.workspace }}/config/preview + RUNNER_TEMP: ${{ runner.temp }} + SYNC_LEVEL: ${{ inputs.synchronization-level || 1 }} + run: | + docker run -d --name cardano-node \ + -v "$RUNNER_TEMP/db-preview:/db" \ + -v "$RUNNER_TEMP/ipc:/ipc" \ + -v "$CONFDIR:/config" \ + "ghcr.io/intersectmbo/cardano-node:$CARDANO_NODE_VERSION" run --config /config/config.json --database-path /db --socket-path /ipc/node.socket --topology /config/topology.json + + echo "Waiting for node socket..." + while [ ! -S "$RUNNER_TEMP/ipc/node.socket" ]; do + sleep 5 + done + + echo "Waiting for sync to reach $SYNC_LEVEL..." + while true; do + tip=$(docker exec cardano-node cardano-cli query tip --testnet-magic 2 2>/dev/null) || { sleep 5; continue; } + sync=$(echo "$tip" | jq -r '.syncProgress // "0"' | tr -d '%') + pct=$(echo "scale=4; $sync / 100" | bc) + echo "Sync progress: ${sync}%" + if [ "$(echo "$pct >= $SYNC_LEVEL" | bc)" -eq 1 ]; then + echo "Reached target sync level" + break + fi + sleep 30 + done + + - name: Stop cardano-node + if: always() && steps.sync.outcome != 'skipped' + run: | + docker stop cardano-node || true + docker rm cardano-node || true + + - name: Save cardano-node DB to S3 + if: always() && steps.sync.outcome != 'skipped' + env: + RUNNER_TEMP: ${{ runner.temp }} + run: | + nix shell nixpkgs#s5cmd -c \ + s5cmd --log error sync "$RUNNER_TEMP/db-preview/" "$S3_DB_PATH/" diff --git a/.github/workflows/user-guide.yaml b/.github/workflows/user-guide.yaml deleted file mode 100644 index a3520fd3a..000000000 --- a/.github/workflows/user-guide.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: User Guide - -on: - push: { "branches": [ "master" ] } - pull_request: { "branches": [ "master" ] } - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - name: 📥 Checkout repository - uses: actions/checkout@v3.5.3 - with: - submodules: true - - - name: 🧰 Setup Node.js - uses: actions/setup-node@v3.7.0 - with: - node-version: lts/jod - - - name: 🧰 Download Hugo - run: | - curl -L https://github.com/gohugoio/hugo/releases/download/v0.76.5/hugo_extended_0.76.5_Linux-64bit.tar.gz | tar xz - - - name: 🔨 Build TypeScript Doc - working-directory: clients/TypeScript - run: | - yarn install --frozen-lockfile --non-interactive --logevel=error - yarn build - yarn docs - - - name: 📸 Build Static Website - shell: bash - working-directory: docs - run: | - ../hugo -t learn --minify - echo "ogmios.dev" > public/CNAME - - - name: 📘 Publish Artifacts - if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' - uses: peaceiris/actions-gh-pages@v3.9.3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/public - enable_jekyll: false diff --git a/.gitignore b/.gitignore index 7ea203b5e..d8096491c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ docs/static/typescript/api ## Nix /result /result-* + +/.direnv diff --git a/README.md b/README.md index f3fb28463..d6197a669 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,27 @@ Ogmios provides a language-agnostic API which can be implemented using any WebSo +## Development + +This project uses a [Nix flake](https://nixos.wiki/wiki/Flakes) for development and CI. + +### With direnv + +If you have [direnv](https://direnv.net/) installed, simply run: + +```sh +direnv allow +``` + +This will automatically initialize git submodules and enter the development shell. + +### Without direnv + +```sh +git submodule update --init --recursive +nix develop "git+file:.?submodules=1" --impure +``` + ## Sponsors A big thank to [all our sponsors 💖](https://github.com/CardanoSolutions#-sponsors). diff --git a/clients/TypeScript/packages/client/test/TransactionSubmission.test.ts b/clients/TypeScript/packages/client/test/TransactionSubmission.test.ts index 119022234..7bb4802ce 100644 --- a/clients/TypeScript/packages/client/test/TransactionSubmission.test.ts +++ b/clients/TypeScript/packages/client/test/TransactionSubmission.test.ts @@ -60,7 +60,7 @@ describe('TransactionSubmission', () => { await submit(someTransaction) } catch (e) { expect(e).toBeInstanceOf(JSONRPCError) - expect(e.code).toBe(3117) + expect(e.code).toBe(3997) } }) @@ -150,7 +150,7 @@ describe('TransactionSubmission', () => { }, budget: { memory: 15694, - cpu: 3776833 + cpu: 3776164 } }]) }) @@ -205,7 +205,7 @@ describe('TransactionSubmission', () => { }, budget: { memory: 15694, - cpu: 3776833 + cpu: 3776164 } }]) }) diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..acb775bb4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,760 @@ +{ + "nodes": { + "CHaP": { + "flake": false, + "locked": { + "lastModified": 1779802675, + "narHash": "sha256-LQN0f9GBBmYMo9tQ/11EvU5tAEOhGtQnU2UP3S78cqg=", + "owner": "intersectmbo", + "repo": "cardano-haskell-packages", + "rev": "b8c7b848cdb6d08e414c37d026c300200f8c1b5b", + "type": "github" + }, + "original": { + "owner": "intersectmbo", + "ref": "repo", + "repo": "cardano-haskell-packages", + "type": "github" + } + }, + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, + "blst": { + "flake": false, + "locked": { + "lastModified": 1749204514, + "narHash": "sha256-Q9/zGN93TnJt2c8YvSaURstoxT02ts3nVkO5V08m4TI=", + "owner": "supranational", + "repo": "blst", + "rev": "6d960cd05d6fe2b5bc9ba161edf0c1a131b87c4c", + "type": "github" + }, + "original": { + "owner": "supranational", + "ref": "v0.3.15", + "repo": "blst", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1645834128, + "narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=", + "owner": "haskell", + "repo": "cabal", + "rev": "5ff598c67f53f7c4f48e31d722ba37172230c462", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cabal-36": { + "flake": false, + "locked": { + "lastModified": 1669081697, + "narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=", + "owner": "haskell", + "repo": "cabal", + "rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.6", + "repo": "cabal", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1672831974, + "narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=", + "owner": "input-output-hk", + "repo": "flake-compat", + "rev": "45f2638735f8cdc40fe302742b79f248d23eb368", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "hkm/gitlab-fix", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "hackage-for-stackage": { + "flake": false, + "locked": { + "lastModified": 1779756795, + "narHash": "sha256-bzFkGq3myTc6t7BN4riMdhe6s7XSXtJq7erPQDHrCYU=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "6e821564270a208b06fcabd00700ec733fc5fc50", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "for-stackage", + "repo": "hackage.nix", + "type": "github" + } + }, + "hackage-internal": { + "flake": false, + "locked": { + "lastModified": 1750307553, + "narHash": "sha256-iiafNoeLHwlSLQTyvy8nPe2t6g5AV4PPcpMeH/2/DLs=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "f7867baa8817fab296528f4a4ec39d1c7c4da4f3", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "hackageNix": { + "flake": false, + "locked": { + "lastModified": 1777003018, + "narHash": "sha256-gjAiW1OwB1q02PE3TkcTvOtOHGrehpXyMKbNjFxa6Qg=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "dc7cfd9bd2e8d0fc662c4bbec02ad36455758912", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "dc7cfd9bd2e8d0fc662c4bbec02ad36455758912", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskellNix": { + "inputs": { + "HTTP": "HTTP", + "cabal-34": "cabal-34", + "cabal-36": "cabal-36", + "cardano-shell": "cardano-shell", + "flake-compat": "flake-compat", + "hackage": [ + "hackageNix" + ], + "hackage-for-stackage": "hackage-for-stackage", + "hackage-internal": "hackage-internal", + "hls": "hls", + "hls-1.10": "hls-1.10", + "hls-2.0": "hls-2.0", + "hls-2.10": "hls-2.10", + "hls-2.11": "hls-2.11", + "hls-2.12": "hls-2.12", + "hls-2.2": "hls-2.2", + "hls-2.3": "hls-2.3", + "hls-2.4": "hls-2.4", + "hls-2.5": "hls-2.5", + "hls-2.6": "hls-2.6", + "hls-2.7": "hls-2.7", + "hls-2.8": "hls-2.8", + "hls-2.9": "hls-2.9", + "hpc-coveralls": "hpc-coveralls", + "iserv-proxy": "iserv-proxy", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-2305": "nixpkgs-2305", + "nixpkgs-2311": "nixpkgs-2311", + "nixpkgs-2405": "nixpkgs-2405", + "nixpkgs-2411": "nixpkgs-2411", + "nixpkgs-2505": "nixpkgs-2505", + "nixpkgs-2511": "nixpkgs-2511", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1779758596, + "narHash": "sha256-+JyDKZj0sKUxZHI1oID4oLrJdNSQaJO5ziaid0Zn07E=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "daad9b0ee7e087911c484b445d9045056e5a7450", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" + } + }, + "hls": { + "flake": false, + "locked": { + "lastModified": 1741604408, + "narHash": "sha256-tuq3+Ip70yu89GswZ7DSINBpwRprnWnl6xDYnS4GOsc=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "682d6894c94087da5e566771f25311c47e145359", + "type": "github" + }, + "original": { + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-1.10": { + "flake": false, + "locked": { + "lastModified": 1680000865, + "narHash": "sha256-rc7iiUAcrHxwRM/s0ErEsSPxOR3u8t7DvFeWlMycWgo=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b08691db779f7a35ff322b71e72a12f6e3376fd9", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "1.10.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.0": { + "flake": false, + "locked": { + "lastModified": 1687698105, + "narHash": "sha256-OHXlgRzs/kuJH8q7Sxh507H+0Rb8b7VOiPAjcY9sM1k=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "783905f211ac63edf982dd1889c671653327e441", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.0.0.1", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.10": { + "flake": false, + "locked": { + "lastModified": 1743069404, + "narHash": "sha256-q4kDFyJDDeoGqfEtrZRx4iqMVEC2MOzCToWsFY+TOzY=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "2318c61db3a01e03700bd4b05665662929b7fe8b", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.10.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.11": { + "flake": false, + "locked": { + "lastModified": 1747306193, + "narHash": "sha256-/MmtpF8+FyQlwfKHqHK05BdsxC9LHV70d/FiMM7pzBM=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "46ef4523ea4949f47f6d2752476239f1c6d806fe", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.11.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.12": { + "flake": false, + "locked": { + "lastModified": 1758709460, + "narHash": "sha256-xkI8MIIVEVARskfWbGAgP5sHG/lyeKnkm0LIOJ19X5w=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "7d983de4fa7ff54369f6dd31444bdb9869aec83e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.12.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.2": { + "flake": false, + "locked": { + "lastModified": 1693064058, + "narHash": "sha256-8DGIyz5GjuCFmohY6Fa79hHA/p1iIqubfJUTGQElbNk=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b30f4b6cf5822f3112c35d14a0cba51f3fe23b85", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.2.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.3": { + "flake": false, + "locked": { + "lastModified": 1695910642, + "narHash": "sha256-tR58doOs3DncFehHwCLczJgntyG/zlsSd7DgDgMPOkI=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "458ccdb55c9ea22cd5d13ec3051aaefb295321be", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.3.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.4": { + "flake": false, + "locked": { + "lastModified": 1699862708, + "narHash": "sha256-YHXSkdz53zd0fYGIYOgLt6HrA0eaRJi9mXVqDgmvrjk=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "54507ef7e85fa8e9d0eb9a669832a3287ffccd57", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.4.0.1", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.5": { + "flake": false, + "locked": { + "lastModified": 1701080174, + "narHash": "sha256-fyiR9TaHGJIIR0UmcCb73Xv9TJq3ht2ioxQ2mT7kVdc=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "27f8c3d3892e38edaef5bea3870161815c4d014c", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.5.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.6": { + "flake": false, + "locked": { + "lastModified": 1705325287, + "narHash": "sha256-+P87oLdlPyMw8Mgoul7HMWdEvWP/fNlo8jyNtwME8E8=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "6e0b342fa0327e628610f2711f8c3e4eaaa08b1e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.6.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.7": { + "flake": false, + "locked": { + "lastModified": 1708965829, + "narHash": "sha256-LfJ+TBcBFq/XKoiNI7pc4VoHg4WmuzsFxYJ3Fu+Jf+M=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "50322b0a4aefb27adc5ec42f5055aaa8f8e38001", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.7.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.8": { + "flake": false, + "locked": { + "lastModified": 1715153580, + "narHash": "sha256-Vi/iUt2pWyUJlo9VrYgTcbRviWE0cFO6rmGi9rmALw0=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "dd1be1beb16700de59e0d6801957290bcf956a0a", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.8.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.9": { + "flake": false, + "locked": { + "lastModified": 1719993701, + "narHash": "sha256-wy348++MiMm/xwtI9M3vVpqj2qfGgnDcZIGXw8sF1sA=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "90319a7e62ab93ab65a95f8f2bcf537e34dae76a", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.9.0.1", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "iohkNix": { + "inputs": { + "blst": "blst", + "nixpkgs": "nixpkgs", + "secp256k1": "secp256k1", + "sodium": "sodium" + }, + "locked": { + "lastModified": 1777941182, + "narHash": "sha256-FX3+8GIrB2z4akmcYTStELDKVJWgqy9yFt0mxwpU3Qc=", + "owner": "input-output-hk", + "repo": "iohk-nix", + "rev": "9de00113c11ba8cac908a63acf34b193cda7475b", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "iohk-nix", + "type": "github" + } + }, + "iserv-proxy": { + "flake": false, + "locked": { + "lastModified": 1775620557, + "narHash": "sha256-10x8/G0x3eR/++XRHPx4MBuqlnc6+N+ajIxXyLkG+nU=", + "owner": "stable-haskell", + "repo": "iserv-proxy", + "rev": "3f7b2815307c20a0dfd816bdf4a39ab86af3e0d4", + "type": "github" + }, + "original": { + "owner": "stable-haskell", + "ref": "iserv-syms", + "repo": "iserv-proxy", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751071626, + "narHash": "sha256-/uHE/AD2qGq4QLigWAnBHiVvpVXB04XAfrOtw8JMv+Y=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a47938d89bdf8e279ad432bd6a473cf4c430f48c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2305": { + "locked": { + "lastModified": 1705033721, + "narHash": "sha256-K5eJHmL1/kev6WuqyqqbS1cdNnSidIZ3jeqJ7GbrYnQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a1982c92d8980a0114372973cbdfe0a307f1bdea", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2311": { + "locked": { + "lastModified": 1719957072, + "narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7144d6241f02d171d25fba3edeaf15e0f2592105", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2405": { + "locked": { + "lastModified": 1735564410, + "narHash": "sha256-HB/FA0+1gpSs8+/boEavrGJH+Eq08/R2wWNph1sM1Dg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1e7a8f391f1a490460760065fa0630b5520f9cf8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2411": { + "locked": { + "lastModified": 1751290243, + "narHash": "sha256-kNf+obkpJZWar7HZymXZbW+Rlk3HTEIMlpc6FCNz0Ds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5ab036a8d97cb9476fbe81b09076e6e91d15e1b6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2505": { + "locked": { + "lastModified": 1764560356, + "narHash": "sha256-M5aFEFPppI4UhdOxwdmceJ9bDJC4T6C6CzCK1E2FZyo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c8f0cca84510cc79e09ea99a299c9bc17d03cb6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2511": { + "locked": { + "lastModified": 1775749320, + "narHash": "sha256-msT6frWJSQ2WR+0cpk+KPcZdLTLagUIsJwQwIX9JNSo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "74b87959b2d16f59f54d8559cf3cf26b9d907949", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1777168982, + "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1775888245, + "narHash": "sha256-nwASzrRDD1JBEu/o8ekKYEXm/oJW6EMCzCRdrwcLe90=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "13043924aaa7375ce482ebe2494338e058282925", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1631092763, + "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master", + "repo": "old-ghc-nix", + "type": "github" + } + }, + "root": { + "inputs": { + "CHaP": "CHaP", + "flake-parts": "flake-parts", + "hackageNix": "hackageNix", + "haskellNix": "haskellNix", + "iohkNix": "iohkNix", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ] + } + }, + "secp256k1": { + "flake": false, + "locked": { + "lastModified": 1683999695, + "narHash": "sha256-9nJJVENMXjXEJZzw8DHzin1DkFkF8h9m/c6PuM7Uk4s=", + "owner": "bitcoin-core", + "repo": "secp256k1", + "rev": "acf5c55ae6a94e5ca847e07def40427547876101", + "type": "github" + }, + "original": { + "owner": "bitcoin-core", + "ref": "v0.3.2", + "repo": "secp256k1", + "type": "github" + } + }, + "sodium": { + "flake": false, + "locked": { + "lastModified": 1675156279, + "narHash": "sha256-0uRcN5gvMwO7MCXVYnoqG/OmeBFi8qRVnDWJLnBb9+Y=", + "owner": "input-output-hk", + "repo": "libsodium", + "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "libsodium", + "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", + "type": "github" + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1779755768, + "narHash": "sha256-XLsul3En+6EtiTvcL9uV+V5wQmL0m79/840uzm2woME=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "87da112372b268c4bd57080ddcc1b63d33a9a375", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..53408c587 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + inputs = { + CHaP = { + url = "github:intersectmbo/cardano-haskell-packages?ref=repo"; + flake = false; + }; + flake-parts.url = "github:hercules-ci/flake-parts"; + hackageNix = { + url = "github:input-output-hk/hackage.nix?ref=dc7cfd9bd2e8d0fc662c4bbec02ad36455758912"; + flake = false; + }; + haskellNix = { + url = "github:input-output-hk/haskell.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.hackage.follows = "hackageNix"; + }; + iohkNix.url = "github:input-output-hk/iohk-nix"; + nixpkgs.follows = "haskellNix/nixpkgs-unstable"; + self.submodules = true; + }; + + outputs = inputs: let + inherit ((import ./flake/lib.nix {inherit inputs;}).flake.lib) recursiveImports; + in + inputs.flake-parts.lib.mkFlake {inherit inputs;} { + imports = recursiveImports [./perSystem]; + systems = [ + "x86_64-linux" + # "aarch64-linux" + # "aarch64-darwin" + ]; + perSystem = {system, ...}: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + inherit (inputs.haskellNix) config; + overlays = [ + inputs.iohkNix.overlays.crypto + inputs.haskellNix.overlay + inputs.iohkNix.overlays.haskell-nix-extra + inputs.iohkNix.overlays.haskell-nix-crypto + inputs.iohkNix.overlays.cardano-lib + inputs.iohkNix.overlays.utils + ]; + }; + }; + }; + + nixConfig = { + extra-substituters = [ + "https://cache.iog.io" + ]; + extra-trusted-public-keys = [ + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + ]; + allow-import-from-derivation = true; + }; +} diff --git a/flake/lib.nix b/flake/lib.nix new file mode 100644 index 000000000..56279e7b2 --- /dev/null +++ b/flake/lib.nix @@ -0,0 +1,38 @@ +{inputs, ...}: { + flake.lib = inputs.nixpkgs.lib.extend (_self: lib: { + recursiveImports = let + # Recursively constructs an attrset of a given folder, recursing on + # directories, value of attrs is the filetype + getDir = dir: + lib.mapAttrs + ( + file: type: + if type == "directory" + then getDir "${dir}/${file}" + else type + ) + (builtins.readDir dir); + + # Collects all files of a directory as a list of strings of paths + files = path: + if lib.pathType path == "directory" + then + lib.collect lib.isString (lib.mapAttrsRecursive + (path: _type: lib.concatStringsSep "/" path) + (getDir path)) + else [path]; + + # Filters out files that don't end with .nix and also make the strings absolute path based + validFiles = path: + map + (file: + if lib.hasPrefix "/nix/store" file + then file + else path + "/${file}") + (lib.filter + (lib.hasSuffix ".nix") + (files path)); + in + lib.concatMap validFiles; + }); +} diff --git a/perSystem/devShells.nix b/perSystem/devShells.nix new file mode 100644 index 000000000..0559c7ad6 --- /dev/null +++ b/perSystem/devShells.nix @@ -0,0 +1,28 @@ +{ inputs, ... }: { + perSystem = { shellFor, pkgs, ... }: { + devShells.default = shellFor { + packages = p: [ p.ogmios ]; + + nativeBuildInputs = [ + pkgs.jq + pkgs.gh + ]; + + tools = { + cabal = "latest"; + ghcid = "latest"; + haskell-language-server = { + src = inputs.haskellNix.inputs."hls-2.10"; + configureArgs = "--disable-benchmarks --disable-tests"; + }; + }; + + shellHook = '' + export LANG="en_US.UTF-8" + git submodule update --init --recursive + ''; + + withHoogle = true; + }; + }; +} diff --git a/perSystem/hydraJobs.nix b/perSystem/hydraJobs.nix new file mode 100644 index 000000000..de9782dd9 --- /dev/null +++ b/perSystem/hydraJobs.nix @@ -0,0 +1,24 @@ +{ config, lib, withSystem, ... }: { + flake.hydraJobs = lib.genAttrs config.systems (lib.flip withSystem ( + { + config, + pkgs, + ... + }: let + required = {inherit (config) packages checks;}; + nonRequired = {inherit (config) devShells;}; + jobs = required // nonRequired; + in + jobs + // { + required = pkgs.releaseTools.aggregate { + name = "required"; + constituents = lib.collect lib.isDerivation required; + }; + nonrequired = pkgs.releaseTools.aggregate { + name = "nonrequired"; + constituents = lib.collect lib.isDerivation nonRequired; + }; + } + )); +} diff --git a/perSystem/packages.nix b/perSystem/packages.nix new file mode 100644 index 000000000..81e85a629 --- /dev/null +++ b/perSystem/packages.nix @@ -0,0 +1,11 @@ +{ + perSystem = { hsPkgs, ... }: + let + ogmios = hsPkgs.ogmios; + in + { + packages.ogmios = ogmios.components.library; + packages.ogmios-exe = ogmios.components.exes.ogmios; + checks.ogmios-unit = ogmios.checks.unit; + }; +} diff --git a/perSystem/project.nix b/perSystem/project.nix new file mode 100644 index 000000000..032f4269a --- /dev/null +++ b/perSystem/project.nix @@ -0,0 +1,69 @@ +{ inputs, self, ... }: + +{ + perSystem = { pkgs, lib, ... }: + let + project = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: { + src = pkgs.haskell-nix.haskellLib.cleanSourceWith { + name = "ogmios-src"; + src = self; + subDir = "server"; + # Filter out package.yaml files so plan-to-nix uses the + # pre-generated .cabal files instead. The package.yaml files + # reference ../../.hpack.config.yaml which is outside the + # server/ subDir and would cause hpack to fail. + filter = path: type: + builtins.all (x: x) [ + (baseNameOf path != "package.yaml") + ]; + }; + name = "ogmios"; + compiler-nix-name = lib.mkDefault "ghc984"; + + inputMap = { + "https://input-output-hk.github.io/cardano-haskell-packages" = inputs.CHaP; + }; + + sha256map = { + "https://github.com/CardanoSolutions/cardano-ledger.git"."5cca15a1f0629c11e8d4d4daeb73428684f9c34f" = "sha256-gRADCB04orqPB2Lkadus0C1O+/Nm5oJHuddXm8wgx5w="; + "https://github.com/CardanoSolutions/ouroboros-consensus.git"."5bbbf9c8b4cd3dc3e3a80d13ef54b3a2ee43a585" = "sha256-Pihx/gVf1GVGElAkMeu2AKtIpPfoCj4faQ0DTjajrqc="; + "https://github.com/CardanoSolutions/ouroboros-network.git"."d3477c4e6b3243f89afb974914ea423a75873fa0" = "sha256-eMfFcV6dFEm10yFyi0wKVE1c0ob4X8UmnhIp5A4W/bE="; + }; + + modules = [ + { + doHaddock = false; + packages.ogmios.ghcOptions = [ "-Werror" ]; + packages.ogmios.components.tests.unit.preCheck = '' + cp ${self}/server/ogmios.json . + cp ${self}/server/cardano.json . + + # Test.Path.Util.getProjectRoot uses TH `makeRelativeToProject ""` + # which bakes the compile-time absolute path + # /build/ogmios-src-test-unit-root/server into the binary. Recreate + # that path at runtime with the golden fixtures and the + # cardano-configurations submodule content. + mkdir -p /build/ogmios-src-test-unit-root/server/test + cp -r ${self}/server/test/golden /build/ogmios-src-test-unit-root/server/test/golden + cp -r ${self}/server/config /build/ogmios-src-test-unit-root/server/config + ''; + } + ({ pkgs, ... }: { + # Use the VRF fork of libsodium + packages = { + cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [ + [ pkgs.libsodium-vrf ] + ]; + cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [ + [ pkgs.libsodium-vrf pkgs.secp256k1 pkgs.libblst ] + ]; + }; + }) + ]; + }); + in + { + _module.args.hsPkgs = project.hsPkgs; + _module.args.shellFor = args: project.shellFor args; + }; +} diff --git a/server/test/unit/Ogmios/Data/JsonSpec.hs b/server/test/unit/Ogmios/Data/JsonSpec.hs index 1d5358336..28167c7c6 100644 --- a/server/test/unit/Ogmios/Data/JsonSpec.hs +++ b/server/test/unit/Ogmios/Data/JsonSpec.hs @@ -395,7 +395,7 @@ spec = do fail "successfully decoded an invalid payload (as Conway Utxo)?" specify "Golden: Script_Native_0.json" $ do - json <- decodeFileThrow "Script_native_0.json" + json <- decodeFileThrow "Script_Native_0.json" case traverse @[] (Json.parse (decodeScript @BabbageEra)) json of Json.Error e -> fail (show e)