diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-10T22·49+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-09-11T10·45+0000 |
commit | 5eda0fbd8668fceb9bfa01a03990b573e59cc17b (patch) | |
tree | c5e7c3a0d34a370c72d9b7aba48e61c2b8cd9d1a /corp | |
parent | f86327beac05de96e01ede78a3cfd4d57e8319a5 (diff) |
feat(corp/tvixbolt): add Nix build instructions r/4791
Now that tvix-eval has almost caught up, tvixbolt can be built in the depot tree. Change-Id: Ib26dd98727b110ad8d668aec60db99678644a167 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6491 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'corp')
-rw-r--r-- | corp/tvixbolt/Cargo.toml | 5 | ||||
-rw-r--r-- | corp/tvixbolt/default.nix | 76 |
2 files changed, 80 insertions, 1 deletions
diff --git a/corp/tvixbolt/Cargo.toml b/corp/tvixbolt/Cargo.toml index 5b5e955efcda..2e6c7932096f 100644 --- a/corp/tvixbolt/Cargo.toml +++ b/corp/tvixbolt/Cargo.toml @@ -10,10 +10,13 @@ yew = "0.19.3" codemap = "0.1.3" web-sys = "*" +# needs to be in sync with nixpkgs +wasm-bindgen = "= 0.2.82" + [dependencies.rnix] git = "https://github.com/nix-community/rnix-parser.git" rev = "97b438e34be5211a4b48aeed9cc3ded489b4d6da" [dependencies.tvix-eval] -path = "../tvix-eval/tvix/eval" +path = "../../tvix/eval" default-features = false diff --git a/corp/tvixbolt/default.nix b/corp/tvixbolt/default.nix new file mode 100644 index 000000000000..a55b249b5f26 --- /dev/null +++ b/corp/tvixbolt/default.nix @@ -0,0 +1,76 @@ +{ depot, lib, pkgs, ... }: + +let + wasmRust = pkgs.rust-bin.stable.latest.default.override { + targets = [ "wasm32-unknown-unknown" ]; + }; + + cargoToml = with builtins; fromTOML (readFile ./Cargo.toml); + + wasmBindgenMatch = + cargoToml.dependencies.wasm-bindgen == "= ${pkgs.wasm-bindgen-cli.version}"; + + assertWasmBindgen = assert (lib.assertMsg wasmBindgenMatch '' + Due to instability in the Rust WASM ecosystem, the trunk build + tool enforces that the Cargo-dependency version of `wasm-bindgen` + MUST match the version of the CLI supplied in the environment. + + This can get out of sync when nixpkgs is updated. To resolve it, + wasm-bindgen must be bumped in the Cargo.toml file and cargo needs + to be run to resolve the dependencies. + + Versions of `wasm-bindgen` in Cargo.toml: + + Expected: '= ${pkgs.wasm-bindgen-cli.version}' + Actual: '${cargoToml.dependencies.wasm-bindgen}' + ''); pkgs.wasm-bindgen-cli; + + deps = [ + pkgs.binaryen + pkgs.sass + pkgs.trunk + + wasmRust + assertWasmBindgen + ]; + + # Cargo.toml needs to be patched with the /nix/store source path of + # tvix-eval. + cargoTomlPatch = pkgs.writeText "tvix-eval-src.patch" '' + diff --git a/Cargo.toml b/Cargo.toml + index 2e6c793..67280e7 100644 + --- a/Cargo.toml + +++ b/Cargo.toml + @@ -18,5 +18,5 @@ git = "https://github.com/nix-community/rnix-parser.git" + rev = "97b438e34be5211a4b48aeed9cc3ded489b4d6da" + + [dependencies.tvix-eval] + -path = "../../tvix/eval" + +path = "${depot.tvix.eval.src}" + default-features = false + ''; + +in +pkgs.rustPlatform.buildRustPackage rec { + pname = "tvixbolt"; + version = "canon"; + src = lib.cleanSource ./.; + + cargoLock.lockFile = ./Cargo.lock; + cargoLock.outputHashes = { + "rnix-0.11.0-dev" = "sha256:1dd8gf2v4v6451r3n9iaks7bqk55izgblkqzymx77advpqwlpymq"; + }; + + patches = [ + cargoTomlPatch + ]; + + buildPhase = '' + export PATH=${lib.makeBinPath deps}:$PATH + mkdir home + export HOME=$PWD/home + trunk build --release -d $out + ''; + + dontInstall = true; +} |