Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable wasm target in Rust toolchain in Nix Flake #927

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions flake.lock

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

36 changes: 18 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
url = github:nix-community/fenix;
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = github:nmattia/naersk;
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs :
Expand All @@ -23,26 +27,20 @@
pkgs = inputs.nixpkgs.legacyPackages.${system};

cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustToolChainTOML = builtins.fromTOML (builtins.readFile ./rust-toolchain.toml);

name = cargoTOML.package.name;
# This is the program version.
version = cargoTOML.package.version;
# This selects a nightly Rust version, based on the date.
nightly-date = pkgs.lib.strings.removePrefix "nightly-" rustToolChainTOML.toolchain.channel;
# This is the hash of the Rust toolchain at nightly-date, required for reproducibility.
nightly-sha256 = "sha256-CNMj0ouNwwJ4zwgc/gAeTYyDYe0botMoaj/BkeDTy4M=";


# This instantiates a new Rust version based on nightly-date.
nightlyRustPlatform = pkgs.makeRustPlatform {
inherit
(inputs.fenix.packages.${system}.toolchainOf {
channel = "nightly";
date = nightly-date;
sha256 = nightly-sha256;
})
cargo rustc;

# Override the toolchain from Rust toolchain file
fenix = inputs.fenix.packages.${system};
toolchain = fenix.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-CNMj0ouNwwJ4zwgc/gAeTYyDYe0botMoaj/BkeDTy4M=";
};
naersk' = pkgs.callPackage inputs.naersk {
cargo = toolchain;
rustc = toolchain;
};

# This is a mock git program, which just returns the commit-substr value.
Expand Down Expand Up @@ -83,7 +81,7 @@
&& builtins.all (name: builtins.baseNameOf path != name) ignoreList;
in
rec {
defaultPackage = nightlyRustPlatform.buildRustPackage {
defaultPackage = naersk'.buildPackage {
pname = name;
inherit version;

Expand All @@ -108,8 +106,10 @@

LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
PROTOC = "${pkgs.protobuf}/bin/protoc";
SKIP_WASM_BUILD = 1;

# Either this or `singleStep = true` is needed to build.
# See https://github.com/nix-community/naersk/issues/133
copySources = ["runtime/development"];

doCheck = false;
};
Expand Down