blob: ff46275c5fcae1e58595d29fc08e8c1d8642f5b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
{
# XXX: Change project description
description = "Rust project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, fenix, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages."${system}";
# XXX: Change target platform
rust-target = "x86_64-unknown-linux-gnu";
rust-toolchain = with fenix.packages."${system}"; let
rust-toolchain-spec = {
# XXX: Change compiler version
# see `toolchainOf` https://github.com/nix-community/fenix
# for supported options
channel = "nightly";
sha256 = "sha256-E4uFH1xyP6u3KhsYf3gnuqWyee61O9uoLLvBEIF1+ko=";
};
# Toolchain for the builder
host-toolchain = toolchainOf rust-toolchain-spec;
# Toolchain for the platform where the binary will run
# target-toolchain = targets."${rust-target}".toolchainOf rust-toolchain-spec;
in
combine [
# Build tools are taken from the host
host-toolchain.rustc
host-toolchain.cargo
host-toolchain.clippy
host-toolchain.rust-docs
# Standard library is taken from the target
host-toolchain.rust-std
host-toolchain.rust-src
];
in
{
devShells.default = pkgs.mkShell {
# XXX: Change to project name
name = "rust-project";
# Build tools
nativeBuildInputs = with pkgs; [
rust-toolchain
rust-analyzer
rustfmt
];
RUST_BACKTRACE = 1;
# CARGO_BUILD_TARGET = rust-target;
};
devShell = self.devShells."${system}".default;
});
}
|