balls
This commit is contained in:
103
flake.nix
Normal file
103
flake.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
description = "A Nix-flake-based Rust development environment with build and run support";
|
||||
|
||||
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 }:
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
rustToolchain =
|
||||
with fenix.packages.${prev.stdenv.hostPlatform.system};
|
||||
combine (with stable; [
|
||||
cargo
|
||||
rustc
|
||||
clippy
|
||||
rustfmt
|
||||
rust-src
|
||||
]);
|
||||
};
|
||||
|
||||
packages = forEachSupportedSystem ({ pkgs }: {
|
||||
default = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "whereAmI";
|
||||
version = "0.1.0";
|
||||
|
||||
# Keep Cargo.lock even if gitignored
|
||||
src = pkgs.lib.cleanSourceWith {
|
||||
src = ./.;
|
||||
filter = path: type:
|
||||
let
|
||||
name = pkgs.lib.baseNameOf path;
|
||||
in
|
||||
name == "Cargo.lock"
|
||||
|| pkgs.lib.cleanSourceFilter path type;
|
||||
};
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
pkgs.openssl
|
||||
];
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "A simple Rust program to show current location info";
|
||||
mainProgram = "whereAmI";
|
||||
license = licenses.mit;
|
||||
maintainers = [ ];
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
devShells = forEachSupportedSystem ({ pkgs }: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustToolchain
|
||||
openssl
|
||||
pkg-config
|
||||
cargo-deny
|
||||
cargo-edit
|
||||
cargo-watch
|
||||
rust-analyzer
|
||||
];
|
||||
|
||||
env = {
|
||||
# Needed for rust-analyzer stdlib discovery
|
||||
RUST_SRC_PATH =
|
||||
"${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user