This repository has been archived on 2024-09-29. You can view files and clone it, but cannot push or open issues or pull requests.
ambition/flake.nix
2023-11-26 21:32:11 +00:00

69 lines
1.9 KiB
Nix

{
description = "Rust development template using fenix";
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
utils,
fenix,
...
}:
utils.lib.eachDefaultSystem
(
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [fenix.overlays.default];
};
toolchain = pkgs.fenix.complete;
in rec
{
# Executed by `nix build`
packages.default =
(pkgs.makeRustPlatform {
# Use nightly rustc and cargo provided by fenix for building
inherit (toolchain) cargo rustc;
})
.buildRustPackage {
pname = "template";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
# For other makeRustPlatform features see:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#cargo-features-cargo-features
};
# Executed by `nix run`
apps.default = utils.lib.mkApp {drv = packages.default;};
# Used by `nix develop`
devShells.default = pkgs.mkShell {
# Use nightly cargo & rustc provided by fenix. Add for packages for the dev shell here
buildInputs = with pkgs; [
(with toolchain; [
cargo rustc rust-src clippy rustfmt # rust components
])
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature
libxkbcommon wayland # To use the wayland feature
mold
clang
pkg-config
];
# Specify the rust-src path (many editors rely on this)
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
};
}
);
}