Skip to content

Commit 7b93cef

Browse files
Baltolirv-auditor
andauthored
Set up Nix flake build (#622)
* Initial draft of flake from previous PR * Working flake * Run Nix build in CI * Set Version: 0.1.42 * Push to Cachix * Update flake inputs with K * Typo * Formatting * Fix test derivation --------- Co-authored-by: devops <[email protected]>
1 parent 4f5c9fa commit 7b93cef

File tree

10 files changed

+796
-20
lines changed

10 files changed

+796
-20
lines changed

.github/workflows/master-push.yml

+44
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,47 @@ jobs:
3434
-H "X-GitHub-Api-Version: 2022-11-28" \
3535
https://api.github.com/repos/runtimeverification/devops/dispatches \
3636
-d '{"event_type":"on-demand-test","client_payload":{"repo":"runtimeverification/wasm-semantics","version":"'${version}'"}}'
37+
38+
nix-cache:
39+
name: 'Populate Nix Cache'
40+
strategy:
41+
matrix:
42+
include:
43+
- runner: normal
44+
- runner: macos-13
45+
- runner: ARM64
46+
runs-on: ${{ matrix.runner }}
47+
steps:
48+
- name: 'Check out code'
49+
uses: actions/checkout@v3
50+
with:
51+
ref: ${{ github.event.push.head.sha }}
52+
fetch-depth: 0
53+
- name: 'Upgrade bash'
54+
if: ${{ contains(matrix.os, 'macos') }}
55+
run: brew install bash
56+
- name: 'Install Nix'
57+
if: ${{ matrix.runner == 'macos-13' }}
58+
uses: cachix/install-nix-action@v19
59+
with:
60+
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
61+
extra_nix_config: |
62+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
63+
- name: 'Install Cachix'
64+
if: ${{ matrix.runner == 'macos-13' }}
65+
uses: cachix/cachix-action@v12
66+
with:
67+
name: k-framework
68+
signingKey: ${{ secrets.CACHIX_SIGNING_KEY }}
69+
skipPush: true
70+
- name: 'Build and cache KWASM'
71+
uses: workflow/[email protected]
72+
env:
73+
GC_DONT_GC: 1
74+
CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
75+
with:
76+
packages: jq
77+
script: |
78+
kwasm=$(nix build --extra-experimental-features 'nix-command flakes' .#kwasm --json | jq -r '.[].outputs | to_entries[].value')
79+
drv=$(nix-store --query --deriver ${kwasm})
80+
nix-store --query --requisites --include-outputs ${drv} | cachix push k-framework

.github/workflows/test-pr.yml

+40
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,43 @@ jobs:
107107
if: always()
108108
run: |
109109
docker stop --time=0 kwasm-ci-prove-${GITHUB_SHA}
110+
111+
nix:
112+
name: 'Nix'
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
include:
117+
- runner: normal
118+
- runner: macos-13
119+
- runner: ARM64
120+
needs: pykwasm-code-quality-checks
121+
runs-on: ${{ matrix.runner }}
122+
timeout-minutes: 60
123+
steps:
124+
- name: 'Check out code'
125+
uses: actions/checkout@v3
126+
with:
127+
# Check out pull request HEAD instead of merge commit.
128+
ref: ${{ github.event.pull_request.head.sha }}
129+
- name: 'Install Nix'
130+
if: ${{ matrix.runner == 'macos-13' }}
131+
uses: cachix/install-nix-action@v25
132+
with:
133+
install_url: https://releases.nixos.org/nix/nix-2.19.3/install
134+
extra_nix_config: |
135+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
136+
substituters = http://cache.nixos.org https://cache.iog.io
137+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
138+
- name: 'Install Cachix'
139+
if: ${{ matrix.runner == 'macos-13' }}
140+
uses: cachix/cachix-action@v14
141+
with:
142+
name: k-framework
143+
authToken: ${{ secrets.CACHIX_PUBLIC_TOKEN }}
144+
- name: 'Build KWASM'
145+
run: GC_DONT_GC=1 nix build .#kwasm --extra-experimental-features 'nix-command flakes' --print-build-logs
146+
- name: 'Build KWASM-Pyk'
147+
run: GC_DONT_GC=1 nix build .#kwasm-pyk --extra-experimental-features 'nix-command flakes' --print-build-logs
148+
- name: 'Test KWASM'
149+
run: GC_DONT_GC=1 nix build .#kwasm-test --extra-experimental-features 'nix-command flakes' --print-build-logs

.github/workflows/update-version.yml

+7
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ jobs:
3030
sed -i 's!pyk = { git = "https://github.com/runtimeverification/k.git", tag="[v0-9\.]*", subdirectory = "pyk" }!pyk = { git = "https://github.com/runtimeverification/k.git", tag="'${K_VERSION}'", subdirectory = "pyk" }!' pykwasm/pyproject.toml
3131
poetry -C pykwasm update
3232
git add pykwasm/ && git commit -m "pykwasm/: sync poetry files ${K_VERSION}" || true
33+
- name: 'Update Nix flake inputs'
34+
run: |
35+
K_VERSION=v"$(cat deps/k_release)"
36+
sed -i 's! k-framework.url = "github:runtimeverification/k/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+"! k-framework.url = "github:runtimeverification/k/'"v${K_VERSION}"'"!' flake.nix
37+
sed -i 's! pyk.url = "github:runtimeverification/k/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+?dir=pyk"! pyk.url = "github:runtimeverification/k/'"v${K_VERSION}"'?dir=pyk"!' flake.nix
38+
nix flake update
39+
git add flake.nix flake.lock && git commit -m 'flake.{nix,lock}: update Nix derivations' || true
3340
- name: 'Push updates'
3441
run: git push

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
.kprove*
99
.kompile*
1010

11+
.envrc
12+
result

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ all: build
1010
# Building Definition
1111
# -------------------
1212

13+
ifneq ($(NIX),1)
1314
POETRY := poetry -C pykwasm
1415
POETRY_RUN := $(POETRY) run --
1516
KDIST := $(POETRY_RUN) kdist
17+
endif
1618

1719
.PHONY: pykwasm
1820
pykwasm:

0 commit comments

Comments
 (0)