diff --git a/.github/workflows/test-nix.yml b/.github/workflows/test-nix.yml index e63af3e..a49dda7 100644 --- a/.github/workflows/test-nix.yml +++ b/.github/workflows/test-nix.yml @@ -29,7 +29,6 @@ jobs: CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_TOKEN_HOLOCHAIN_OPEN_DEV }}" run: | cd ./nix/fixture - yes | nix flake update cachix watch-exec holochain-open-dev -- nix build -L .#my_zome.meta.debug cachix watch-exec holochain-open-dev -- nix build -L .#my_zome sha256sum result @@ -51,6 +50,10 @@ jobs: with: name: holochain-ci + - uses: cachix/cachix-action@v10 + with: + name: holochain-open-dev + - name: Install coreutils for macOS if: matrix.os == 'macos-latest' run: brew install coreutils @@ -58,7 +61,6 @@ jobs: - name: Build zomes run: | cd ./nix/fixture - yes | nix flake update nix build -L .#my_zome.meta.debug nix build -L .#my_zome sha256sum result diff --git a/flake.nix b/flake.nix index 24c5e9e..e54c8b4 100644 --- a/flake.nix +++ b/flake.nix @@ -42,9 +42,24 @@ filterDnas = filterByHolochainPackageType "dna"; filterHapps = filterByHolochainPackageType "happ"; - rustZome = { crateCargoToml, workspacePath, excludedCrates ? [] }: + rustZome = { crateCargoToml, holochain, workspacePath, excludedCrates ? [] }: let - system = "x86_64-linux"; + deterministicCraneLib = let + system = "x86_64-linux"; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; + + rustToolchain = pkgs.rust-bin.nightly."2024-01-29".minimal.override { + # Set the build targets supported by the toolchain, + # wasm32-unknown-unknown is required for trunk. + targets = [ "wasm32-unknown-unknown" ]; + }; + in + inputs.crane.lib.${system}.overrideToolchain rustToolchain; + + system = holochain.legacyPackages.cowsay.system; pkgs = import inputs.nixpkgs { inherit system; overlays = [ (import inputs.rust-overlay) ]; @@ -59,7 +74,7 @@ in pkgs.callPackage ./nix/zome.nix { - inherit craneLib crateCargoToml excludedCrates workspacePath; + inherit deterministicCraneLib craneLib crateCargoToml excludedCrates workspacePath; }; sweettest = { holochain, dna, workspacePath, crateCargoToml }: let diff --git a/nix/fixture/flake.lock b/nix/fixture/flake.lock index 311d500..fd64eef 100644 --- a/nix/fixture/flake.lock +++ b/nix/fixture/flake.lock @@ -717,7 +717,7 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-WXZBLFHhN58QcK1zogs8LA+LmQeCSz3Uo1XsTvwLMio=", + "narHash": "sha256-tGdMa5qZOHvnpo3VE55aW/37bxlMUHsvNsFz6uoxKtU=", "path": "../..", "type": "path" }, diff --git a/nix/fixture/zome/zome.nix b/nix/fixture/zome/zome.nix index 16afb09..b40a1ab 100644 --- a/nix/fixture/zome/zome.nix +++ b/nix/fixture/zome/zome.nix @@ -8,6 +8,7 @@ }: { packages.my_zome = inputs.hcUtils.outputs.lib.rustZome { workspacePath = rootPath; + holochain = inputs'.holochain; crateCargoToml = ./Cargo.toml; }; checks.my_zome = inputs.hcUtils.outputs.lib.sweettest { diff --git a/nix/zome.nix b/nix/zome.nix index 7447071..1c1e476 100644 --- a/nix/zome.nix +++ b/nix/zome.nix @@ -2,7 +2,7 @@ runCommandLocal, runCommandNoCC, binaryen, - callPackage, + deterministicCraneLib, craneLib, workspacePath, crateCargoToml, @@ -31,7 +31,7 @@ let cargoToml = crateCargoToml; cargoLock = workspacePath + /Cargo.lock; cargoArtifacts = wasmDeps; - cargoExtraArgs = "-p ${crate} --locked -v"; + cargoExtraArgs = "-p ${crate} --locked"; pname = crate; version = cargoToml.package.version; }); @@ -42,14 +42,31 @@ let } '' cp ${wasm}/lib/${crate}.wasm $out ''; + + deterministicWasm = + let + wasmDeps = deterministicCraneLib.buildDepsOnly (commonArgs // { + inherit cargoExtraArgs; + pname = "happ-workspace"; + version = "workspace"; + }); + wasm = deterministicCraneLib.buildPackage (commonArgs // { + cargoToml = crateCargoToml; + cargoLock = workspacePath + /Cargo.lock; + cargoArtifacts = wasmDeps; + cargoExtraArgs = "-p ${crate} --locked"; + pname = crate; + version = cargoToml.package.version; + }); + in + runCommandLocal "${crate}-deterministic" { + meta = { + holochainPackageType = "zome"; + }; + } '' + cp ${wasm}/lib/${crate}.wasm $out + ''; in - # callPackage ./deterministic-zome.nix { - # inherit workspacePath crateCargoToml; - # meta = { - # inherit debug; - # holochainPackageType = "zome"; - # }; - # } runCommandNoCC crate { meta = { inherit debug; @@ -57,5 +74,5 @@ in }; buildInputs = [ binaryen ]; } '' - wasm-opt --strip-debug -Oz -o $out ${debug} + wasm-opt --strip-debug -Oz -o $out ${deterministicWasm} ''