Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Mar 7, 2024
1 parent a3559e3 commit 59bd06d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,14 +50,17 @@ 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

- 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
Expand Down
21 changes: 18 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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) ];
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nix/fixture/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nix/fixture/zome/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
37 changes: 27 additions & 10 deletions nix/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
runCommandLocal,
runCommandNoCC,
binaryen,
callPackage,
deterministicCraneLib,
craneLib,
workspacePath,
crateCargoToml,
Expand Down Expand Up @@ -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;
});
Expand All @@ -42,20 +42,37 @@ 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;
holochainPackageType = "zome";
};
buildInputs = [ binaryen ];
} ''
wasm-opt --strip-debug -Oz -o $out ${debug}
wasm-opt --strip-debug -Oz -o $out ${deterministicWasm}
''

0 comments on commit 59bd06d

Please sign in to comment.