Skip to content

Commit

Permalink
Share workspace deps to reduce build overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Mar 14, 2024
1 parent fc8190e commit 21b40d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
9 changes: 9 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@
pkgs.statix
];
};

packages = {
default = config.workspace.workspace;
inherit (config.workspace) workspace;
};

checks = {
inherit (config.workspace) workspace_clippy;
};
};
};
}
26 changes: 3 additions & 23 deletions nix/modules/scenario.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,15 @@
let
inherit (config.rustHelper) craneLib;

opensslStatic =
if system == "x86_64-darwin"
then pkgs.openssl # pkgsStatic is considered a cross build and this is not yet supported
else pkgs.pkgsStatic.openssl;

mkPackage = { name }: craneLib.buildPackage {
mkPackage = { name }: craneLib.buildPackage (config.workspace.commonArgs // {
pname = name;
version = config.rustHelper.findCrateVersion ../../scenarios/${name}/Cargo.toml;

src = craneLib.cleanCargoSource (craneLib.path ./../..);
strictDeps = true;
inherit (config.workspace) cargoArtifacts;

cargoExtraArgs = "-p ${name}";
SKIP_HAPP_BUILD = "1";

buildInputs = with pkgs; [
# Some Holochain crates link against openssl
openssl
opensslStatic
];

nativeBuildInputs = with pkgs; [
# To build openssl-sys
perl
pkg-config
# Because the holochain_client depends on Kitsune/tx5
go
];
};
});
in
{
options.scenarioHelper = lib.mkOption { type = lib.types.raw; };
Expand Down
14 changes: 7 additions & 7 deletions nix/modules/workspace.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
src = craneLib.cleanCargoSource (craneLib.path ./../..);
strictDeps = true;

cargoExtraArgs = "--locked --workspace";
SKIP_HAPP_BUILD = "1";

buildInputs = with pkgs; [
# Some Holochain crates link against openssl
openssl
Expand All @@ -38,19 +41,16 @@
inherit cargoArtifacts;
});

workspaceClippy = craneLib.cargoClippy (commonArgs // {
workspace_clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features -- --deny warnings";
});
in
{
packages = {
default = workspace;
inherit workspace;
};
options.workspace = lib.mkOption { type = lib.types.raw; };

checks = {
inherit workspaceClippy;
config.workspace = {
inherit commonArgs cargoArtifacts workspace workspace_clippy;
};
};
}
8 changes: 4 additions & 4 deletions nix/modules/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
let
packageName = if kind == "integrity" then "${name}_${kind}" else name;
in
craneLib.buildPackage {
craneLib.buildPackage (config.workspace.commonArgs // {
pname = "${name}_${kind}";
version = config.rustHelper.findCrateVersion ../../zomes/${name}/${kind}/Cargo.toml;

src = craneLib.cleanCargoSource (craneLib.path ./../..);
strictDeps = true;
inherit (config.workspace) cargoArtifacts;

doCheck = false;

cargoExtraArgs = "-p ${packageName} --lib --target wasm32-unknown-unknown";
};
});
};
};
}

0 comments on commit 21b40d8

Please sign in to comment.