2023-12-31 22:49:37 +01:00
|
|
|
{
|
|
|
|
description = "A Nix-flake-based Rust development environment";
|
|
|
|
|
|
|
|
inputs = {
|
2024-05-02 20:39:19 +02:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
|
|
|
|
treefmt-nix = {
|
|
|
|
url = "github:numtide/treefmt-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-12-31 22:49:37 +01:00
|
|
|
};
|
|
|
|
|
2024-05-02 20:39:19 +02:00
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
treefmt-nix,
|
|
|
|
fenix,
|
|
|
|
}:
|
2023-12-31 22:49:37 +01:00
|
|
|
let
|
2024-05-02 20:39:19 +02:00
|
|
|
supportedSystems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
];
|
|
|
|
forEachSupportedSystem =
|
|
|
|
f:
|
|
|
|
nixpkgs.lib.genAttrs supportedSystems (
|
|
|
|
system:
|
|
|
|
f (
|
2023-12-31 22:49:37 +01:00
|
|
|
let
|
2024-05-02 20:39:19 +02:00
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
fenix' = (import fenix { inherit system pkgs; });
|
|
|
|
toolchain = fenix'.complete.withComponents (
|
|
|
|
(builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain.components
|
|
|
|
);
|
2023-12-31 22:49:37 +01:00
|
|
|
in
|
2024-05-02 20:39:19 +02:00
|
|
|
{
|
|
|
|
inherit pkgs toolchain;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
2023-12-31 22:49:37 +01:00
|
|
|
in
|
|
|
|
{
|
2024-05-02 20:39:19 +02:00
|
|
|
formatter = forEachSupportedSystem (
|
|
|
|
{ pkgs, ... }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper
|
|
|
|
);
|
|
|
|
devShells = forEachSupportedSystem (
|
|
|
|
{ pkgs, toolchain }:
|
|
|
|
{
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
nativeBuildInputs = [ toolchain ];
|
|
|
|
buildInputs = [ toolchain ];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
packages = forEachSupportedSystem (
|
|
|
|
{ pkgs, toolchain }:
|
|
|
|
{
|
|
|
|
default = (
|
|
|
|
let
|
|
|
|
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
|
|
|
|
rustPlatform = pkgs.makeRustPlatform {
|
|
|
|
cargo = toolchain;
|
|
|
|
rustc = toolchain;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
pname = manifest.name;
|
|
|
|
version = manifest.version;
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
src = pkgs.lib.cleanSource ./.;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2023-12-31 22:49:37 +01:00
|
|
|
};
|
|
|
|
}
|