Files
kt_log/flake.nix
T

122 lines
2.9 KiB
Nix

{
description = "Rust development environment for the kt_log console logging library";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self, ... }:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
f {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.self.overlays.default
];
};
}
);
in
{
templates = {
default = {
path = ./.;
description = "Rust library development environment using fenix";
};
};
overlays.default = _final: prev: {
rustToolchain =
with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
combine (
with stable;
[
cargo
clippy
rustc
rustfmt
rust-src
]
);
};
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
rustToolchain
git
gnumake
alejandra
statix
deadnix
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
pre-commit
];
env = {
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
shellHook = ''
if [ ! -d .git ]; then
git init
echo "✓ Initialized git repository"
fi
export PATH="$HOME/.cargo/bin:$PATH"
echo "[kt_log] Welcome to the Rust library development shell!"
echo "Tools: cargo, rustc, clippy, rustfmt, rust-analyzer"
echo "Run 'cargo test', 'cargo clippy', or 'cargo build' to work on the library."
'';
};
}
);
packages = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.rustPlatform.buildRustPackage {
pname = "kt_log";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
}
);
checks = forEachSupportedSystem (
{ pkgs }:
{
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
}
);
formatter = forEachSupportedSystem (
{ pkgs }:
pkgs.alejandra
);
};
}