Skip to content

Commit 30e43b3

Browse files
authored
Added formal spec to Nix shell and CI (#13)
* Added agda and dependencies to Nix developement shell. * Added Nix derivation for Leios spec. * Added typechecking of Leios spec to CI. * Updated logbook. * Added caching of nix store, fixes #14. * Separated nix caches.
1 parent 46a95bf commit 30e43b3

File tree

9 files changed

+298
-64
lines changed

9 files changed

+298
-64
lines changed

.github/workflows/ci.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,52 @@ on:
1313
- main
1414
jobs:
1515

16+
typecheck:
17+
name: Typecheck specification
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- name: 📥 Checkout repository
21+
uses: actions/checkout@v4
22+
- name: 💾 Cache Nix store
23+
uses: actions/[email protected]
24+
id: nix-cache
25+
with:
26+
path: /tmp/nixcache
27+
key: ${{ runner.os }}-nix-typecheck-${{ hashFiles('flake.lock') }}
28+
restore-keys: ${{ runner.os }}-nix-typecheck-
29+
- name: 🛠️ Install Nix
30+
uses: cachix/install-nix-action@v21
31+
with:
32+
nix_path: nixpkgs=channel:nixos-unstable
33+
install_url: https://releases.nixos.org/nix/nix-2.10.3/install
34+
extra_nix_config: |
35+
allowed-uris = ${{ env.ALLOWED_URIS }}
36+
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
37+
substituters = ${{ env.SUBSTITUTERS }}
38+
experimental-features = nix-command flakes
39+
- name: 💾➤ Import Nix store cache
40+
if: "steps.nix-cache.outputs.cache-hit == 'true'"
41+
run: "nix-store --import < /tmp/nixcache"
42+
- name: 🏗️ Build specification
43+
run: |
44+
nix build --show-trace --accept-flake-config .#leiosSpec
45+
- name: ➤💾 Export Nix store cache
46+
if: "steps.nix-cache.outputs.cache-hit != 'true'"
47+
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
48+
1649
compile:
1750
name: Build libraries
1851
runs-on: ubuntu-22.04
1952
steps:
2053
- name: 📥 Checkout repository
2154
uses: actions/checkout@v4
55+
- name: 💾 Cache Nix store
56+
uses: actions/[email protected]
57+
id: nix-cache
58+
with:
59+
path: /tmp/nixcache
60+
key: ${{ runner.os }}-nix-compile-${{ hashFiles('flake.lock') }}
61+
restore-keys: ${{ runner.os }}-nix-compile-
2262
- name: 🛠️ Install Nix
2363
uses: cachix/install-nix-action@v21
2464
with:
@@ -29,12 +69,18 @@ jobs:
2969
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
3070
substituters = ${{ env.SUBSTITUTERS }}
3171
experimental-features = nix-command flakes
72+
- name: 💾➤ Import Nix store cache
73+
if: "steps.nix-cache.outputs.cache-hit == 'true'"
74+
run: "nix-store --import < /tmp/nixcache"
3275
- name: 🏗️ Build `exe:leios`
3376
run: |
3477
nix build --show-trace --accept-flake-config .#leios
3578
- name: 🏗️ Build `exe:ouroboros-net-vis`
3679
run: |
3780
nix build --show-trace --accept-flake-config .#ouroboros-net-vis
81+
- name: ➤💾 Export Nix store cache
82+
if: "steps.nix-cache.outputs.cache-hit != 'true'"
83+
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
3884

3985
tests:
4086
if: true
@@ -43,6 +89,13 @@ jobs:
4389
steps:
4490
- name: 📥 Checkout repository
4591
uses: actions/checkout@v4
92+
- name: 💾 Cache Nix store
93+
uses: actions/[email protected]
94+
id: nix-cache
95+
with:
96+
path: /tmp/nixcache
97+
key: ${{ runner.os }}-nix-tests-${{ hashFiles('flake.lock') }}
98+
restore-keys: ${{ runner.os }}-nix-tests-
4699
- name: 🛠️ Install Nix
47100
uses: cachix/install-nix-action@v21
48101
with:
@@ -53,9 +106,15 @@ jobs:
53106
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
54107
substituters = ${{ env.SUBSTITUTERS }}
55108
experimental-features = nix-command flakes
109+
- name: 💾➤ Import Nix store cache
110+
if: "steps.nix-cache.outputs.cache-hit == 'true'"
111+
run: "nix-store --import < /tmp/nixcache"
56112
- name: 🔬 Test with `leios-sim-test`
57113
run: |
58114
nix run --accept-flake-config .#leios-sim-test
115+
- name: ➤💾 Export Nix store cache
116+
if: "steps.nix-cache.outputs.cache-hit != 'true'"
117+
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
59118

60119
build-docusaurus:
61120
runs-on: ubuntu-22.04

Logbook.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
## 2024-08-30
2+
3+
### Nix and CI support for Leios specification
4+
5+
The Nix flake now builds the Leios specification and the libraries upon which it depends. The type checking of the spec is now added to the CI.
6+
7+
```console
8+
$ nix develop
9+
10+
Welcome to Ouroboros Leios!
11+
12+
Locations of Agda libraries:
13+
/nix/store/1yxiwwy44xxxgzdmvyjizq53w9cfinkn-standard-library-2.0/standard-library.agda-lib
14+
/nix/store/ppsczpm7l2gx1zd3cx2brv49069krzzh-agda-stdlib-classes-2.0/standard-library-classes.agda-lib
15+
/nix/store/gkci6kgv4v9qw2rh5gc0s26g53b253jy-agda-stdlib-meta-2.0/standard-library-meta.agda-lib
16+
/nix/store/2gk6rvsplxww4i8dnflxbd319lfxdcvv-formal-ledger-1d77a35a/formal-ledger.agda-lib
17+
18+
Run 'emacs' to edit .agda files.
19+
20+
21+
Type 'info' to see what's inside this shell.
22+
23+
$ cd formal-spec
24+
25+
$ emacs Leios/SimpleSpec.agda
26+
```
27+
128
## 2024-07-26
229

330
### Running `ouroborous-net-viz` in the browser

flake.lock

+55-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
inputs = {
77
iogx = {
88
url = "github:input-output-hk/iogx";
9-
# inputs.hackage.follows = "hackage";
10-
# inputs.CHaP.follows = "CHaP";
11-
# inputs.haskell-nix.follows = "haskell-nix";
12-
# inputs.nixpkgs.follows = "nixpkgs";
139
};
1410

1511
# nixpkgs.follows = "haskell-nix/nixpkgs";
@@ -28,6 +24,7 @@
2824
# url = "github:input-output-hk/haskell.nix";
2925
# inputs.hackage.follows = "hackage";
3026
# };
27+
3128
};
3229

3330

formal-spec/Leios/SimpleSpec.agda

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# OPTIONS --allow-unsolved-metas #-}
2+
13
module Leios.SimpleSpec where
24

35
open import Ledger.Prelude

formal-spec/leios-spec.agda-lib

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ depend:
33
standard-library
44
standard-library-classes
55
standard-library-meta
6+
formal-ledger
67
include:
78
.
8-
../../formal-ledger-specifications/src/

0 commit comments

Comments
 (0)