62 lines
1.5 KiB
Nix
62 lines
1.5 KiB
Nix
{
|
|
description = "Rust-Hello";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
crate2nix = {
|
|
url = "github:nix-community/crate2nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = inputs @ {
|
|
crate2nix,
|
|
flake-utils,
|
|
nixpkgs,
|
|
rust-overlay,
|
|
...
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system: let
|
|
# Overlay pkgs with rust-bin
|
|
overlays = [(import rust-overlay)];
|
|
pkgs = import nixpkgs {
|
|
inherit system overlays;
|
|
};
|
|
|
|
# Use rust-bin to generate the toolchain from rust-toolchain.toml
|
|
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
|
|
buildRustCrateForPkgs = _:
|
|
pkgs.buildRustCrate.override {
|
|
rustc = rust-toolchain; # Use rustc from toolchain
|
|
cargo = rust-toolchain; # Use cargo from toolchain
|
|
};
|
|
|
|
# Cargo.nix for IFD
|
|
generatedCargoNix = crate2nix.tools.${system}.generatedCargoNix {
|
|
name = "rustnix";
|
|
src = ./.;
|
|
};
|
|
|
|
cargoNix = import generatedCargoNix {
|
|
inherit pkgs buildRustCrateForPkgs;
|
|
};
|
|
in {
|
|
packages = rec {
|
|
hello = cargoNix.rootCrate.build;
|
|
default = hello;
|
|
};
|
|
|
|
devShell = pkgs.mkShell {
|
|
buildInputs = [rust-toolchain];
|
|
};
|
|
}
|
|
);
|
|
}
|