Files
rust-flake-template/flake.nix
T
GarandPLG 6e4c509ad3 Add clap CLI, logging, and update Nix flake
Introduce a clap‑based command line interface and file logging using
simplelog. Add the corresponding dependencies (clap, log, simplelog) and
a release profile with LTO and stripping. Refactor the Nix flake:
update default.nix metadata, improve devShell, add update script and
metadata, and adjust flake.nix outputs accordingly. Update Cargo.lock
to reflect new crates.
2026-06-30 12:27:15 +02:00

85 lines
2.0 KiB
Nix

{
description = "Basic rust flake for development and production";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs = {
nixpkgs.follows = "nixpkgs";
fenix.follows = "fenix";
};
};
};
outputs = {
self,
nixpkgs,
naersk,
fenix,
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
rustToolchain = fenix.packages.${system}.stable.toolchain;
naerskLib = pkgs.callPackage naersk {
cargo = rustToolchain;
rustc = rustToolchain;
};
cargoToml = fromTOML (builtins.readFile ./Cargo.toml);
packageVersion = cargoToml.package.version;
in {
packages.${system} = {
default = pkgs.callPackage ./default.nix {};
develop = naerskLib.buildPackage {
name = "rust-flake-template";
src = ./.;
# buildInputs = with pkgs; [];
nativeBuildInputs = with pkgs; [pkg-config];
# postInstall = ''
# cp -r statics $out/bin
# '';
};
};
devShells.${system}.default = pkgs.mkShell {
env = {
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
# LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; []);
};
buildInputs = [
rustToolchain
# pkgs.
];
nativeBuildInputs = with pkgs; [pkg-config];
shellHook = ''
echo "rust-flake-template v${packageVersion}"
echo ""
echo "Commands:"
echo " nix update flake - Update flakes versions"
echo " nix build - Build production version"
echo " nix run - Run production version"
echo " nix build .#develop - Build development version"
echo " nix run .#develop - Run development version"
echo ""
cargo run -- -h
'';
};
};
}