71 lines
2.1 KiB
Nix
71 lines
2.1 KiB
Nix
{
|
|
description = "Project Tool";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = { nixpkgs, rust-overlay, ... }:
|
|
let
|
|
lib = nixpkgs.lib;
|
|
systems = ["x86_64-linux"];
|
|
forEachSystem = fn: lib.genAttrs systems (system: let
|
|
overlays = [ (import rust-overlay) ];
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
in fn { inherit pkgs rustToolchain; } );
|
|
in {
|
|
packages = forEachSystem ({ pkgs, rustToolchain }: let
|
|
rustPlatform = pkgs.makeRustPlatform {
|
|
cargo = rustToolchain;
|
|
rustc = rustToolchain;
|
|
};
|
|
|
|
manifest = lib.importTOML ./Cargo.toml;
|
|
packageName = manifest.package.name;
|
|
packageVersion = manifest.package.version;
|
|
|
|
package = rustPlatform.buildRustPackage {
|
|
nativeBuildInputs = [ rustToolchain ];
|
|
|
|
pname = packageName;
|
|
version = packageVersion;
|
|
src = lib.cleanSource ./.;
|
|
|
|
verbose = true;
|
|
|
|
cargoLock = {
|
|
lockFile = ./Cargo.lock;
|
|
allowBuiltinFetchGit = true;
|
|
};
|
|
|
|
meta = {
|
|
mainProgram = packageName;
|
|
};
|
|
};
|
|
in {
|
|
default = package;
|
|
${packageName} = package;
|
|
});
|
|
|
|
devShells = forEachSystem ({ pkgs, rustToolchain }: let
|
|
rustNightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith (t: t.minimal.override {
|
|
extensions = [ "rustfmt" ];
|
|
});
|
|
in {
|
|
default = pkgs.mkShell {
|
|
name = "projtool";
|
|
|
|
nativeBuildInputs = [
|
|
rustToolchain
|
|
rustNightlyToolchain
|
|
];
|
|
};
|
|
});
|
|
};
|
|
}
|