diff --git a/.github/workflows/nix-check.yml b/.github/workflows/nix-check.yml new file mode 100644 index 00000000000..7071f849837 --- /dev/null +++ b/.github/workflows/nix-check.yml @@ -0,0 +1,49 @@ +name: Nix Flake Check + +on: + pull_request: + push: + branches: + - master + - 'release-*' + - 'dev-*' +permissions: + contents: read + +jobs: + flake-check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v9 + + - name: Enable flakes + uses: DeterminateSystems/magic-nix-cache-action@v2 + + - name: Check Nix flake inputs + run: nix flake check + + - name: Show flake metadata + if: always() # Run even if previous step fails + run: nix flake metadata + + - name: Validate flake outputs + if: always() # Run even if previous step fails + run: nix flake show + + - name: Check build in Nix dev shell + run: | + # Enter nix develop and run build commands + nix develop --command bash -c ' + # Install dependencies + yarn install + + # Build the project + yarn build + + # Build cosmic-swingset + cd packages/cosmic-swingset && make + ' diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..1d23a9ef874 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1739446958, + "narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2ff53fe64443980e139eaa286017f53f88336dd0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..0946fd371f7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,75 @@ +{ + description = "Agoric SDK Development Environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + # Custom Node.js 20.9.0 package + custom_node_20_9 = pkgs.stdenv.mkDerivation { + pname = "nodejs"; + version = "20.9.0"; + + src = pkgs.fetchurl { + url = "https://nodejs.org/dist/v20.9.0/node-v20.9.0-${if pkgs.stdenv.isDarwin then "darwin" else "linux"}-${if pkgs.stdenv.isAarch64 then "arm64" else "x64"}.tar.gz"; + sha256 = if pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64 then + "0snfsz2mmjdavi38nglayw5yia74q9h1xzz2ahpri8yqx1md9lii" # darwin-arm64 + else if pkgs.stdenv.isDarwin then + "1j6cw6i3hjqv8zk1nbsqg560k7rgcmyl9cfd4vlvn5wclzr76nzw" # darwin-x64 + else if pkgs.stdenv.isAarch64 then + "0skah3bal5irvramnfn86vgi0c375ywsyb4xaxmx3gvlnbpdp9yj" # linux-arm64 + else if (pkgs.stdenv.isLinux && !pkgs.stdenv.isAarch64) then + "0q3gy4z5b8dd0w37ya5wlkbv4xhyqa1s0zwh71258x5z5w4rz4gh" # linux-x64 + else + throw "Unsupported system: This derivation only supports Linux (x64/arm64) and Darwin (x64/arm64) systems"; + }; + + installPhase = '' + echo "installing nodejs" + mkdir -p $out + cp -r ./ $out/ + ''; + + + # Meta information for the package + meta = with pkgs.lib; { + description = "Node.js 20.9.0 JavaScript runtime"; + homepage = "https://nodejs.org"; + license = licenses.mit; + platforms = platforms.unix; + }; + }; + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + custom_node_20_9 + (yarn.override { nodejs = custom_node_20_9; }) + (python3.withPackages (ps: [ ps.distutils ])) + pkg-config + go_1_23 + gopls + delve + gcc + gnumake + protobuf + buf + git + ]; + + shellHook = '' + export PATH=$PATH:$HOME/go/bin + + echo "Node.js $(node --version)" + echo "NPM $(npm --version)" + echo "Yarn using Node.js $(yarn node -v)" + ''; + }; + } + ); +} diff --git a/patches/ava+5.3.1.patch b/patches/ava+5.3.1.patch index f3ccc74b2c5..98a788fbaf2 100644 --- a/patches/ava+5.3.1.patch +++ b/patches/ava+5.3.1.patch @@ -94,38 +94,6 @@ index 7630baa..78ced77 100644 notifyOfPeerFailure() { send({type: 'peer-failed'}); -diff --git a/node_modules/ava/lib/reporters/tap.js b/node_modules/ava/lib/reporters/tap.js -index b1989a4..fa1617f 100644 ---- a/node_modules/ava/lib/reporters/tap.js -+++ b/node_modules/ava/lib/reporters/tap.js -@@ -45,6 +45,10 @@ function dumpError(error) { - return object; - } - -+function durationOut(dur) { -+ return dur ? ` %ava-dur=${dur}ms` : ''; -+} -+ - export default class TapReporter { - constructor(options) { - this.i = 0; -@@ -96,6 +100,7 @@ export default class TapReporter { - } - - writeTest(evt, flags) { -+ evt.title += durationOut(evt.duration); - this.reportStream.write(supertap.test(this.prefixTitle(evt.testFile, evt.title), { - comment: evt.logs, - error: evt.err ? dumpError(evt.err) : null, -@@ -108,7 +113,7 @@ export default class TapReporter { - - writeCrash(evt, title) { - this.crashCount++; -- this.reportStream.write(supertap.test(title || evt.err.summary || evt.type, { -+ this.reportStream.write(supertap.test((title || evt.err.summary || evt.type) + durationOut(evt.duration), { - comment: evt.logs, - error: evt.err ? dumpError(evt.err) : null, - index: ++this.i, diff --git a/node_modules/ava/lib/worker/base.js b/node_modules/ava/lib/worker/base.js index cdd3c4a..4302a4a 100644 --- a/node_modules/ava/lib/worker/base.js