From 75e66dfc3ec2f1aebeda072b31467ec06b11bfc5 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Thu, 21 Sep 2023 23:23:32 -0400 Subject: [PATCH 1/3] speed up nickelWasm --- flake.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 143e1050bb..408aab72b3 100644 --- a/flake.nix +++ b/flake.nix @@ -618,9 +618,11 @@ nickel-lang-cli nickel-lang-core rustfmt; - # An optimizing release build is long: eschew optimizations in checks by - # building a dev profile - nickelWasm = buildNickelWasm { profile = "dev"; }; + # There's a tradeoff here: "release" build is in theory longer than + # "dev", but it hits the cache on dependencies so in practice it is + # shorter. Another option would be to compile a dev dependencies version + # of cargoArtifacts. But that almost doubles the cache space. + nickelWasm = buildNickelWasm { profile = "release"; }; inherit vscodeExtension; pre-commit = pre-commit-builder { }; }; From df6939114a10926d891438f89214a4cfebc97ba1 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Thu, 21 Sep 2023 23:25:41 -0400 Subject: [PATCH 2/3] build packages separately so all dependencies get cached --- flake.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 408aab72b3..618642a07b 100644 --- a/flake.nix +++ b/flake.nix @@ -268,7 +268,22 @@ # Build *just* the cargo dependencies, so we can reuse all of that work (e.g. via cachix) when running in CI cargoArtifacts = craneLib.buildDepsOnly { inherit pname src; - cargoExtraArgs = "${cargoBuildExtraArgs} --workspace --all-features"; + cargoExtraArgs = "${cargoBuildExtraArgs} --all-features"; + cargoBuildCommand = "cargoWorkspace build"; + cargoTestCommand = "cargoWorkspace test"; + cargoCheckCommand = "cargoWorkspace check"; + preBuild = '' + cargoWorkspace() { + command=$(shift) + for packageDir in $(${pkgs.yq}/bin/tomlq -r '.workspace.members[]' Cargo.toml); do + ( + cd $packageDir + pwd + cargoWithProfile $command "$@" + ) + done + } + ''; # pyo3 needs a Python interpreter in the build environment # https://pyo3.rs/v0.17.3/building_and_distribution#configuring-the-python-version buildInputs = [ pkgs.python3 ]; From f15f3a48dc55540c28079833c09bc6ca0618059c Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Fri, 22 Sep 2023 10:11:16 -0400 Subject: [PATCH 3/3] comment --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index 618642a07b..8a09bdf3e7 100644 --- a/flake.nix +++ b/flake.nix @@ -269,6 +269,12 @@ cargoArtifacts = craneLib.buildDepsOnly { inherit pname src; cargoExtraArgs = "${cargoBuildExtraArgs} --all-features"; + # If we build all the packages at once, feature unification takes + # over and we get libraries with different sets of features than + # we would get building them separately. Meaning that when we + # later build them separately, it won't hit the cache. So instead, + # we need to build each package separately when we are collecting + # dependencies. cargoBuildCommand = "cargoWorkspace build"; cargoTestCommand = "cargoWorkspace test"; cargoCheckCommand = "cargoWorkspace check";