blob: 852b42f7deeb7abcefdc78421bdaaa2ae703dfe0 (
plain) (
blame)
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
65
66
67
68
69
|
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-mozilla = { url = "github:mozilla/nixpkgs-mozilla"; flake = false; };
crate2nix = { url = "github:kolloch/crate2nix/master"; flake = false; };
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs-mozilla, crate2nix, utils } @ inputs :
let
rustOverlay = (final: prev:
let
rustChannel = prev.rustChannelOf {
channel = "1.66.0";
sha256 = "S7epLlflwt0d1GZP44u5Xosgf6dRrmr8xxC+Ml2Pq7c=";
};
rust = rustChannel.rust.override {
targets = [ "x86_64-unknown-linux-musl" ];
};
in
{
rustc = rust;
cargo = rust;
}
);
rustDevOverlay = final: prev: {
# rust-analyzer needs core source
rustc-with-src = prev.rustc.override { extensions = [ "rust-src" ]; };
};
in
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import "${nixpkgs-mozilla}/rust-overlay.nix") rustOverlay rustDevOverlay ];
};
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ clang linuxHeaders ];
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
customBuildCrate = pkgs: pkgs.buildRustCrate.override {
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
rustables = attrs: {
nativeBuildInputs = nativeBuildInputs;
buildInputs = buildInputs;
LIBCLANG_PATH = LIBCLANG_PATH;
};
};
};
cargoNix = import ./Cargo.nix {
inherit pkgs;
buildRustCrateForPkgs = customBuildCrate;
release = false;
};
devShell = pkgs.mkShell {
name = "rustables";
nativeBuildInputs = nativeBuildInputs;
buildInputs = buildInputs;
LIBCLANG_PATH = LIBCLANG_PATH;
packages = with pkgs; [ rust-analyzer rustc-with-src ];
};
in {
defaultPackage = cargoNix.rootCrate.build;
devShells.default = devShell;
packages = {
rustables = cargoNix.rootCrate.build;
};
}
);
}
|