use flake-parts in rust template
This commit is contained in:
@@ -11,6 +11,8 @@ fi
|
||||
|
||||
watch_file nix/**
|
||||
watch_file -- **/*.nix
|
||||
watch_file Cargo.toml
|
||||
watch_file rust-toolchain.toml
|
||||
# Adding files to git includes them in a flake
|
||||
# But it is also a bit much reloading.
|
||||
# watch_file .git/index .git/HEAD
|
||||
|
||||
+28
-17
@@ -1,13 +1,13 @@
|
||||
{
|
||||
description = "Rust-Hello";
|
||||
description = "Rust-Package";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
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";
|
||||
@@ -15,20 +15,25 @@
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
flake-parts,
|
||||
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;
|
||||
};
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
perSystem = {
|
||||
pkgs,
|
||||
system,
|
||||
self',
|
||||
...
|
||||
}: let
|
||||
# Use rust-bin to generate the toolchain from rust-toolchain.toml
|
||||
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
@@ -48,14 +53,20 @@
|
||||
inherit pkgs buildRustCrateForPkgs;
|
||||
};
|
||||
in {
|
||||
packages = rec {
|
||||
hello = cargoNix.rootCrate.build;
|
||||
default = hello;
|
||||
# Overlay pkgs with rust-bin
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [(import rust-overlay)];
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
packages = {
|
||||
hello = cargoNix.rootCrate.build;
|
||||
default = self'.packages.hello;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [rust-toolchain];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.85.0"
|
||||
channel = "1.96.0"
|
||||
components = [ "rustfmt", "rustc-dev", "rust-analyzer", "rust-src"]
|
||||
|
||||
Reference in New Issue
Block a user