Skip to content

Commit

Permalink
Simple nix setup (#180)
Browse files Browse the repository at this point in the history
* Provide a minimal working Nix setup
Minimal nix flake that only provides a development shell
for building the haskell and purescript projects
  • Loading branch information
gilligan authored Nov 28, 2024
1 parent e0b711e commit 02a6b48
Show file tree
Hide file tree
Showing 24 changed files with 7,769 additions and 2,689 deletions.
1 change: 0 additions & 1 deletion .ghcid

This file was deleted.

47 changes: 22 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
id-token: write
contents: read
runs-on: [ self-hosted, Linux ]
env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2024-11-14"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -25,9 +28,24 @@ jobs:
- name: Add signing key for nix
run: echo "${{ secrets.NIX_SIGNING_KEY }}" > "${{ runner.temp }}/nix-key"

- name: Run omnix to build all outputs
- name: Lint sources
run: |
nix run github:juspay/omnix -- ci -v > ${{ runner.temp }}/outputs
nix flake check
- name: Build onchain
run: |
cd onchain
nix develop --command "make"
- name: Build offchain
run: |
cd offchain
nix develop --command "make"
- name: Build raw scripts crate
run: |
cd raw-scripts
nix develop --command "make"
- name: Acquire AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -37,26 +55,5 @@ jobs:

- name: Copy nix scopes to nix cache
run: |
nix-store --stdin -q --deriver < ${{ runner.temp }}/outputs | nix-store --stdin -qR --include-outputs \
| nix copy --stdin --to \
"s3://cache.sc.iog.io?secret-key=${{ runner.temp }}/nix-key&region=$AWS_DEFAULT_REGION" \
&& rm ${{ runner.temp }}/outputs
test-x64-linux:
permissions:
id-token: write
contents: read
runs-on: [ self-hosted, Linux ]
needs:
- build-x64-linux
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ github.token }}
- name: Run tests
run: |
nix-build -A check.x86_64-linux.pre-commit-check
nix-build -A check.x86_64-linux.upToDatePlutusScriptCheck
nix-build -A check.x86_64-linux.upToDatePlutusScriptCheck
nix-build -A check.x86_64-linux.partner-chains-smart-contracts
nix build .#devShells.x86_64-linux.default --dry-run --json | jq -r '.[] | .drvPath + "^*"' \
| nix copy --stdin --to "s3://cache.sc.iog.io?secret-key=${{ runner.temp }}/nix-key&region=$AWS_DEFAULT_REGION"
23 changes: 1 addition & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
.PHONY: build-nix hoogle nix-build-library nix-build-executables \
nix-build-test requires_nix_shell ci-build-run format-staged \
.PHONY: requires_nix_shell format-staged \
unreachable-commit-staged format-whitespace-staged format-nix-staged \
format-hs-staged format-cabal-staged format-purs-staged format-js-staged \
format-dhall-staged check-format-hs-staged check-format-cabal-staged \
check-format-purs-staged check-format-js-staged check-format-dhall-staged \
check-format-nix-staged check-format-whitespace

# Generate TOC for README.md
# It has to be manually inserted into the README.md for now.
generate-readme-contents: requires_nix_shell
npx markdown-toc ./README.md --no-firsth1

# Attempt the CI locally
# TODO

# Build the library with nix.
nix-build-library:
@ nix build .#trustless-sidechain:lib:trustless-sidechain

current-system := $(shell nix eval --impure --expr builtins.currentSystem)

# Build the executables with nix (also builds the test suite).
nix-build-executables:
@ nix build -L .#check.${current-system}

# Build the tests with nix.
nix-build-test:
@ nix build -L .#trustless-sidechain:test:trustless-sidechain-test

# Target to use as dependency to fail if not inside nix-shell.
requires_nix_shell:
@ [ "$(IN_NIX_SHELL)" ] || { \
Expand Down
Loading

0 comments on commit 02a6b48

Please sign in to comment.