From 2ce38e36e0a0568a08fe7bb56e7aa01ae18bc318 Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Fri, 30 Aug 2024 09:26:06 -0600 Subject: [PATCH 1/6] Added agda and dependencies to Nix developement shell. --- flake.lock | 93 +++++++++++++++++++-------------- flake.nix | 5 +- formal-spec/leios-spec.agda-lib | 2 +- nix/agda.nix | 87 ++++++++++++++++++++++++++++++ nix/outputs.nix | 5 +- nix/shell.nix | 57 ++++++++++++++------ 6 files changed, 185 insertions(+), 64 deletions(-) create mode 100644 nix/agda.nix diff --git a/flake.lock b/flake.lock index 7536de25..81f3cfdb 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1720157709, - "narHash": "sha256-9GZS2x9ZcaMncOAdVtHi+bXIi3amdOOgGCFjRZuO9sw=", + "lastModified": 1724604182, + "narHash": "sha256-gQmj2hHwEvS29Gf+juG95T7Qt5LfzDJKzdPajcuHZgs=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "2bfd58f7293b0c66eafeab9b905ba5e680aeab41", + "rev": "3a25be01c845e86092e514403882ac74141ac3da", "type": "github" }, "original": { @@ -279,11 +279,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1720139837, - "narHash": "sha256-sHzBEROaMR3fpBcajRh44FiaQf8F5+frPfgUMmslUkQ=", + "lastModified": 1724632371, + "narHash": "sha256-8MKEmQeJ4ft4PEcU85sCr+DqTc7wpLLV3Wt8jC9PZ+Q=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "b7a8cc3e5e94cd79ac8b52e46f85b4279e4d6c33", + "rev": "28717c62d061f1936eb96b4c5814b7df0c31fa0d", "type": "github" }, "original": { @@ -330,16 +330,17 @@ "nixpkgs-2211": "nixpkgs-2211", "nixpkgs-2305": "nixpkgs-2305", "nixpkgs-2311": "nixpkgs-2311", + "nixpkgs-2405": "nixpkgs-2405", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1720140618, - "narHash": "sha256-NUOHsXOoB+JBopuQpTTfn0zGfbfg49i3f5VlQIU0ATQ=", + "lastModified": 1724633441, + "narHash": "sha256-jPVqNPQabeEIGUxyCMyOmer3JwSdHdleGGLwydrPvf0=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "eb6200ccc683803154f8d8226a12f26857275f2e", + "rev": "00ca0e2522e2ec124bf4ed5285685e524fbe38ee", "type": "github" }, "original": { @@ -578,11 +579,11 @@ "sphinxcontrib-haddock": "sphinxcontrib-haddock" }, "locked": { - "lastModified": 1720207747, - "narHash": "sha256-ISZAoaeRMrTYmhkH96w2Ua/5SsVY+ja2MpW0ZKkHbWo=", + "lastModified": 1724699322, + "narHash": "sha256-H+d9HhoKZ7yItB4DqWxTEN+P5xtBnrNTYi3hXMakjzI=", "owner": "input-output-hk", "repo": "iogx", - "rev": "a6ad5dc3a956cb17b0cbee308d5b1788eb42f431", + "rev": "9720ba9bcaf738f65fbc530e427caea7bcc0d7d1", "type": "github" }, "original": { @@ -602,11 +603,11 @@ "sodium": "sodium" }, "locked": { - "lastModified": 1719443312, - "narHash": "sha256-JNDuUSmV/o5ck1CfnBtX8GJE/Pli4zYE73LZZ7u0E2Q=", + "lastModified": 1721825987, + "narHash": "sha256-PPcma4tjozwXJAWf+YtHUQUulmxwulVlwSQzKItx/n8=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "b4025c38b609c6fb99762e2a6201e4e3488a39d3", + "rev": "eb61f2c14e1f610ec59117ad40f8690cddbf80cb", "type": "github" }, "original": { @@ -675,11 +676,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1712990762, - "narHash": "sha256-hO9W3w7NcnYeX8u8cleHiSpK2YJo7ecarFTUlbybl7k=", + "lastModified": 1720642556, + "narHash": "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is=", "owner": "nlewo", "repo": "nix2container", - "rev": "20aad300c925639d5d6cbe30013c8357ce9f2a2e", + "rev": "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4", "type": "github" }, "original": { @@ -786,11 +787,11 @@ }, "nixpkgs-2305": { "locked": { - "lastModified": 1701362232, - "narHash": "sha256-GVdzxL0lhEadqs3hfRLuj+L1OJFGiL/L7gCcelgBlsw=", + "lastModified": 1705033721, + "narHash": "sha256-K5eJHmL1/kev6WuqyqqbS1cdNnSidIZ3jeqJ7GbrYnQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d2332963662edffacfddfad59ff4f709dde80ffe", + "rev": "a1982c92d8980a0114372973cbdfe0a307f1bdea", "type": "github" }, "original": { @@ -802,11 +803,11 @@ }, "nixpkgs-2311": { "locked": { - "lastModified": 1701386440, - "narHash": "sha256-xI0uQ9E7JbmEy/v8kR9ZQan6389rHug+zOtZeZFiDJk=", + "lastModified": 1719957072, + "narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "293822e55ec1872f715a66d0eda9e592dc14419f", + "rev": "7144d6241f02d171d25fba3edeaf15e0f2592105", "type": "github" }, "original": { @@ -816,6 +817,22 @@ "type": "github" } }, + "nixpkgs-2405": { + "locked": { + "lastModified": 1720122915, + "narHash": "sha256-Nby8WWxj0elBu1xuRaUcRjPi/rU3xVbkAt2kj4QwX2U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "835cf2d3f37989c5db6585a28de967a667a75fb1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, @@ -850,33 +867,33 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1718811006, - "narHash": "sha256-0Y8IrGhRmBmT7HHXlxxepg2t8j1X90++qRN3lukGaIk=", + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "03d771e513ce90147b65fe922d87d3a0356fc125", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-unstable": { "locked": { - "lastModified": 1694822471, - "narHash": "sha256-6fSDCj++lZVMZlyqOe9SIOL8tYSBz1bI8acwovRwoX8=", + "lastModified": 1720181791, + "narHash": "sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", + "rev": "4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", - "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", "type": "github" } }, @@ -936,11 +953,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1719259945, - "narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=", + "lastModified": 1724440431, + "narHash": "sha256-9etXEOUtzeMgqg1u0wp+EdwG7RpmrAZ2yX516bMj2aE=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07", + "rev": "c8a54057aae480c56e28ef3e14e4960628ac495b", "type": "github" }, "original": { @@ -1007,11 +1024,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1720138986, - "narHash": "sha256-+A0QV5ttTNRhlLD/o2l8VjVYE6Xk3X+I2r9b9mlrgw8=", + "lastModified": 1724631220, + "narHash": "sha256-aXkNOrKlGKFO4BfPMo28Br0+A5arKJYCZvbAyj0d3Yk=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "0cfa5e0a9804966c8feb8227d57149348ff79f2c", + "rev": "73edb7f9d4b83b19246ab92592e0e7699faddcd9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9bfdc668..fbc2c3f5 100644 --- a/flake.nix +++ b/flake.nix @@ -6,10 +6,6 @@ inputs = { iogx = { url = "github:input-output-hk/iogx"; - # inputs.hackage.follows = "hackage"; - # inputs.CHaP.follows = "CHaP"; - # inputs.haskell-nix.follows = "haskell-nix"; - # inputs.nixpkgs.follows = "nixpkgs"; }; # nixpkgs.follows = "haskell-nix/nixpkgs"; @@ -28,6 +24,7 @@ # url = "github:input-output-hk/haskell.nix"; # inputs.hackage.follows = "hackage"; # }; + }; diff --git a/formal-spec/leios-spec.agda-lib b/formal-spec/leios-spec.agda-lib index d5eba400..a6d38adb 100644 --- a/formal-spec/leios-spec.agda-lib +++ b/formal-spec/leios-spec.agda-lib @@ -3,6 +3,6 @@ depend: standard-library standard-library-classes standard-library-meta + formal-ledger include: . - ../../formal-ledger-specifications/src/ \ No newline at end of file diff --git a/nix/agda.nix b/nix/agda.nix new file mode 100644 index 00000000..51ef6575 --- /dev/null +++ b/nix/agda.nix @@ -0,0 +1,87 @@ +{ pkgs, lib, inputs, ... }: + +let + + locales = { + LANG = "en_US.UTF-8"; + LC_ALL = "en_US.UTF-8"; + LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" + then "${pkgs.glibcLocales}/lib/locale/locale-archive" + else ""; + }; + + customAgda = pkgs; + + agdaStdlib = customAgda.agdaPackages.standard-library; + + agdaStdlibClasses = customAgda.agdaPackages.mkDerivation { + inherit (locales) LANG LC_ALL LOCALE_ARCHIVE; + pname = "agda-stdlib-classes"; + version = "2.0"; + src = pkgs.fetchFromGitHub { + repo = "agda-stdlib-classes"; + owner = "omelkonian"; + rev = "v2.0"; + sha256 = "sha256-PcieRRnctjCzFCi+gUYAgyIAicMOAZPl8Sw35fZdt0E="; + }; + meta = { }; + libraryFile = "agda-stdlib-classes.agda-lib"; + everythingFile = "Classes.agda"; + buildInputs = [ agdaStdlib ]; + }; + + agdaStdlibMeta = customAgda.agdaPackages.mkDerivation { + inherit (locales) LANG LC_ALL LOCALE_ARCHIVE; + pname = "agda-stdlib-meta"; + version = "2.0"; + src = pkgs.fetchFromGitHub { + repo = "stdlib-meta"; + owner = "input-output-hk"; + rev = "4fc4b1ed6e47d180516917d04be87cbacbf7d314"; + sha256 = "T+9vwccbDO1IGBcGLjgV/fOt+IN14KEV9ct/J6nQCsM="; + }; + meta = { }; + libraryFile = "agda-stdlib-meta.agda-lib"; + everythingFile = "Main.agda"; + buildInputs = [ agdaStdlib agdaStdlibClasses ]; + }; + + formalLedger = customAgda.agdaPackages.mkDerivation { + inherit (locales) LANG LC_ALL LOCALE_ARCHIVE; + pname = "formal-ledger"; + version = "1d77a35a"; + src = pkgs.fetchFromGitHub { + repo = "formal-ledger-specifications"; + owner = "IntersectMBO"; + rev = "1d77a35ab1820c123790e5138d85325d33787e86"; + sha256 = "0d15aysxdmn31aj982gr63d40q606dqvq0k4y4rwa9kpmjgadjaq"; + }; + meta = { }; + preConfigure = '' + cat << EOI > formal-ledger.agda-lib + name: formal-ledger + depend: + standard-library + standard-library-classes + standard-library-meta + include: src + EOI + mv src/Everything.agda . + ''; + libraryFile = "formal-ledger.agda-lib"; + everythingFile = "Everything.agda"; + buildInputs = [ agdaStdlib agdaStdlibClasses agdaStdlibMeta ]; + }; + + agdaWithPkgs = p: customAgda.agda.withPackages { pkgs = p; ghc = pkgs.ghc; }; + +in +rec { + inherit agdaStdlib agdaStdlibClasses agdaStdlibMeta formalLedger; + agdaWithDeps = agdaWithPkgs [ + agdaStdlib + agdaStdlibClasses + agdaStdlibMeta + formalLedger + ]; +} diff --git a/nix/outputs.nix b/nix/outputs.nix index 48c87c80..1d908890 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -7,8 +7,5 @@ let in [ - ( - # Docs for project.flake: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#mkhaskellprojectoutflake - project.flake - ) + (project.flake) ] diff --git a/nix/shell.nix b/nix/shell.nix index 1adf23c5..aaeacbe6 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -8,29 +8,40 @@ # project. cabalProject: +let + + agda = import ./agda.nix {inherit pkgs lib inputs;}; + emacsWithPackages = pkgs.emacs.pkgs.withPackages (epkgs: [ epkgs.agda2-mode pkgs.mononoki ]); + +in + { name = "nix-shell"; - # prompt = null; + packages = [ + agda.agdaWithDeps + emacsWithPackages + ]; - # welcomeMessage = null; + # Agda environment variables. + env.AGDA_STDLIB = "${agda.agdaStdlib}/standard-library.agda-lib"; + env.AGDA_STDLIB_CLASSES = "${agda.agdaStdlibClasses}/standard-library-classes.agda-lib"; + env.AGDA_STDLIB_META = "${agda.agdaStdlibMeta}/standard-library-meta.agda-lib"; + env.FORMAL_LEDGER_LIB = "${agda.formalLedger}/formal-ledger.agda-lib"; - # packages = []; +# prompt = "[ouroboros-leios]$ "; - # scripts = { - # foo = { - # description = ""; - # group = "general"; - # enabled = true; - # exec = '' - # echo "Hello, World!" - # ''; - # }; - # }; + welcomeMessage = '' + Welcome to Ouroboros Leios! - # env = { - # KEY = "VALUE"; - # }; + Locations of Agda libraries: + ${agda.agdaStdlib}/standard-library.agda-lib + ${agda.agdaStdlibClasses}/standard-library-classes.agda-lib + ${agda.agdaStdlibMeta}/standard-library-meta.agda-lib + ${agda.formalLedger}/formal-ledger.agda-lib + + Run 'emacs' to edit .agda files. + ''; # shellHook = ""; @@ -52,6 +63,17 @@ cabalProject: # purs-tidy = null; }; + # scripts = { + # foo = { + # description = ""; + # group = "general"; + # enabled = true; + # exec = '' + # echo "Hello, World!" + # ''; + # }; + # }; + # preCommit = { # cabal-fmt.enable = false; # cabal-fmt.extraOptions = ""; @@ -74,5 +96,6 @@ cabalProject: # purs-tidy.enable = false; # purs-tidy.extraOptions = ""; # }; + } - \ No newline at end of file + From e995c46589f600fde9a66dabfbd257d4ff0be5a5 Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Fri, 30 Aug 2024 09:50:11 -0600 Subject: [PATCH 2/6] Added Nix derivation for Leios spec. --- formal-spec/Leios/SimpleSpec.agda | 2 ++ nix/agda.nix | 25 +++++++++++++++++++++++-- nix/outputs.nix | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/formal-spec/Leios/SimpleSpec.agda b/formal-spec/Leios/SimpleSpec.agda index dee18ed9..65e590b1 100644 --- a/formal-spec/Leios/SimpleSpec.agda +++ b/formal-spec/Leios/SimpleSpec.agda @@ -1,3 +1,5 @@ +{-# OPTIONS --allow-unsolved-metas #-} + module Leios.SimpleSpec where open import Ledger.Prelude diff --git a/nix/agda.nix b/nix/agda.nix index 51ef6575..abb9b51d 100644 --- a/nix/agda.nix +++ b/nix/agda.nix @@ -73,15 +73,36 @@ let buildInputs = [ agdaStdlib agdaStdlibClasses agdaStdlibMeta ]; }; + leiosSpec = customAgda.agdaPackages.mkDerivation { + inherit (locales) LANG LC_ALL LOCALE_ARCHIVE; + pname = "leios-spec"; + name = "leios-spec"; # FIXME: Why is this entry needed? + src = ../formal-spec; + meta = { }; + preConfigure = '' + cat << EOI > Everything.agda + module Everything where + import CategoricalCrypto + import Leios.Network + import Leios.SimpleSpec + EOI + ls + ''; + libraryFile = "formal-spec/leios-spec.agda-lib"; + everythingFile = "Everything.agda"; + buildInputs = [ agdaStdlib agdaStdlibClasses agdaStdlibMeta formalLedger ]; + }; + agdaWithPkgs = p: customAgda.agda.withPackages { pkgs = p; ghc = pkgs.ghc; }; in -rec { - inherit agdaStdlib agdaStdlibClasses agdaStdlibMeta formalLedger; +{ + inherit agdaStdlib agdaStdlibClasses agdaStdlibMeta formalLedger ; agdaWithDeps = agdaWithPkgs [ agdaStdlib agdaStdlibClasses agdaStdlibMeta formalLedger ]; + leiosSpec = leiosSpec; } diff --git a/nix/outputs.nix b/nix/outputs.nix index 1d908890..c4cdbb5e 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -3,9 +3,13 @@ let project = repoRoot.nix.project; + agda = import ./agda.nix {inherit pkgs lib inputs;}; in [ (project.flake) + { + packages.leiosSpec = agda.leiosSpec; + } ] From 9f8769b39749e5becd91a725ae29b89a98ff1dbb Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Fri, 30 Aug 2024 09:51:49 -0600 Subject: [PATCH 3/6] Added typechecking of Leios spec to CI. --- .github/workflows/ci.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7eb06e4e..362e9371 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,6 +13,26 @@ on: - main jobs: + typecheck: + name: Typecheck specification + runs-on: ubuntu-22.04 + steps: + - name: 📥 Checkout repository + uses: actions/checkout@v4 + - name: 🛠️ Install Nix + uses: cachix/install-nix-action@v21 + with: + nix_path: nixpkgs=channel:nixos-unstable + install_url: https://releases.nixos.org/nix/nix-2.10.3/install + extra_nix_config: | + allowed-uris = ${{ env.ALLOWED_URIS }} + trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }} + substituters = ${{ env.SUBSTITUTERS }} + experimental-features = nix-command flakes + - name: 🏗️ Build specification + run: | + nix build --show-trace --accept-flake-config .#leiosSpec + compile: name: Build libraries runs-on: ubuntu-22.04 From c6a97ecf34834a9a8ff64cd9855dcfec45ad34d0 Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Fri, 30 Aug 2024 10:03:53 -0600 Subject: [PATCH 4/6] Updated logbook. --- Logbook.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Logbook.md b/Logbook.md index 2ba81cec..10aab417 100644 --- a/Logbook.md +++ b/Logbook.md @@ -1,3 +1,30 @@ +## 2024-08-30 + +### Nix and CI support for Leios specification + +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. + +```console +$ nix develop + +Welcome to Ouroboros Leios! + +Locations of Agda libraries: + /nix/store/1yxiwwy44xxxgzdmvyjizq53w9cfinkn-standard-library-2.0/standard-library.agda-lib + /nix/store/ppsczpm7l2gx1zd3cx2brv49069krzzh-agda-stdlib-classes-2.0/standard-library-classes.agda-lib + /nix/store/gkci6kgv4v9qw2rh5gc0s26g53b253jy-agda-stdlib-meta-2.0/standard-library-meta.agda-lib + /nix/store/2gk6rvsplxww4i8dnflxbd319lfxdcvv-formal-ledger-1d77a35a/formal-ledger.agda-lib + +Run 'emacs' to edit .agda files. + + +Type 'info' to see what's inside this shell. + +$ cd formal-spec + +$ emacs Leios/SimpleSpec.agda +``` + ## 2024-07-26 ### Running `ouroborous-net-viz` in the browser From 056940d373885f6472224e01716288bee1c6f880 Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Mon, 16 Sep 2024 09:53:14 -0600 Subject: [PATCH 5/6] Added caching of nix store, fixes #14. --- .github/workflows/ci.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 362e9371..d5c3d5ad 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,13 @@ jobs: steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + - name: 💾 Cache Nix store + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: @@ -29,9 +36,15 @@ jobs: trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }} substituters = ${{ env.SUBSTITUTERS }} experimental-features = nix-command flakes + - name: 💾➤ Import Nix store cache + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" - name: 🏗️ Build specification run: | nix build --show-trace --accept-flake-config .#leiosSpec + - name: ➤💾 Export Nix store cache + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" compile: name: Build libraries @@ -39,6 +52,13 @@ jobs: steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + - name: 💾 Cache Nix store + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: @@ -49,12 +69,18 @@ jobs: trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }} substituters = ${{ env.SUBSTITUTERS }} experimental-features = nix-command flakes + - name: 💾➤ Import Nix store cache + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" - name: 🏗️ Build `exe:leios` run: | nix build --show-trace --accept-flake-config .#leios - name: 🏗️ Build `exe:ouroboros-net-vis` run: | nix build --show-trace --accept-flake-config .#ouroboros-net-vis + - name: ➤💾 Export Nix store cache + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" tests: if: true @@ -63,6 +89,13 @@ jobs: steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + - name: 💾 Cache Nix store + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /tmp/nixcache + key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: @@ -73,9 +106,15 @@ jobs: trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }} substituters = ${{ env.SUBSTITUTERS }} experimental-features = nix-command flakes + - name: 💾➤ Import Nix store cache + if: "steps.nix-cache.outputs.cache-hit == 'true'" + run: "nix-store --import < /tmp/nixcache" - name: 🔬 Test with `leios-sim-test` run: | nix run --accept-flake-config .#leios-sim-test + - name: ➤💾 Export Nix store cache + if: "steps.nix-cache.outputs.cache-hit != 'true'" + run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache" build-docusaurus: runs-on: ubuntu-22.04 From 36024694b7872115953ca9b4f1600b2724c431ef Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Mon, 16 Sep 2024 10:09:09 -0600 Subject: [PATCH 6/6] Separated nix caches. --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d5c3d5ad..0bf2f2eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,8 +24,8 @@ jobs: id: nix-cache with: path: /tmp/nixcache - key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} - restore-keys: ${{ runner.os }}-nix- + key: ${{ runner.os }}-nix-typecheck-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix-typecheck- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: @@ -57,8 +57,8 @@ jobs: id: nix-cache with: path: /tmp/nixcache - key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} - restore-keys: ${{ runner.os }}-nix- + key: ${{ runner.os }}-nix-compile-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix-compile- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: @@ -94,8 +94,8 @@ jobs: id: nix-cache with: path: /tmp/nixcache - key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} - restore-keys: ${{ runner.os }}-nix- + key: ${{ runner.os }}-nix-tests-${{ hashFiles('flake.lock') }} + restore-keys: ${{ runner.os }}-nix-tests- - name: 🛠️ Install Nix uses: cachix/install-nix-action@v21 with: