Files
whereAmI/flake.nix
2026-01-06 20:28:07 +00:00

100 lines
2.4 KiB
Nix

{
description = "A Nix-flake-based Rust development environment";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*"; # unstable
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.*";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, fenix, ... }@inputs:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
inherit system;
}
);
in
{
overlays.default = final: prev: {
rustToolchain =
with fenix.packages.${prev.stdenv.hostPlatform.system};
combine (
with stable;
[
clippy
rustc
cargo
rustfmt
rust-src
]
);
};
packages = forEachSupportedSystem ({ pkgs, system }:
{
default = pkgs.rustPlatform.buildRustPackage {
pname = "my-rust-project"; # change if needed
version = "0.1.0"; # change if needed
src = pkgs.lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
meta = with pkgs.lib; {
description = "My Rust project";
license = licenses.mit;
mainProgram = "whereAmI";
};
};
});
apps = forEachSupportedSystem ({ pkgs, system }:
{
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/whereAmI";
};
});
devShells = forEachSupportedSystem ({ pkgs, system }:
{
default = pkgs.mkShell {
packages = with pkgs; [
rustToolchain
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
];
env = {
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
};
});
};
}