95 lines
2.7 KiB
Nix
95 lines
2.7 KiB
Nix
{
|
|
description = "Description for the project";
|
|
|
|
inputs = {
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
treefmt.url = "github:numtide/treefmt-nix";
|
|
};
|
|
|
|
outputs =
|
|
inputs@{ flake-parts, ... }:
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
imports = [ inputs.treefmt.flakeModule ];
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"aarch64-darwin"
|
|
"x86_64-darwin"
|
|
];
|
|
perSystem =
|
|
{
|
|
config,
|
|
self',
|
|
inputs',
|
|
pkgs,
|
|
system,
|
|
...
|
|
}:
|
|
let
|
|
runtimeDeps = with pkgs; [
|
|
alsa-lib
|
|
speechd
|
|
];
|
|
buildDeps = with pkgs; [
|
|
pkg-config
|
|
rustPlatform.bindgenHook
|
|
];
|
|
devDeps = with pkgs; [ gdb ];
|
|
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
|
|
rustPackage =
|
|
features:
|
|
(pkgs.makeRustPlatform {
|
|
cargo = pkgs.rust-bin.stable.latest.minimal;
|
|
rustc = pkgs.rust-bin.stable.latest.minimal;
|
|
}).buildRustPackage
|
|
{
|
|
inherit (cargoToml.package) name version;
|
|
src = ./.;
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
buildFeatures = features;
|
|
buildInputs = runtimeDeps;
|
|
nativeBuildInputs = buildDeps;
|
|
# Uncomment if your cargo tests require networking or otherwise
|
|
# don't play nicely with the Nix build sandbox:
|
|
# doCheck = false;
|
|
};
|
|
|
|
in
|
|
{
|
|
_module.args.pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
overlays = [ (import inputs.rust-overlay) ];
|
|
};
|
|
|
|
packages.default = (rustPackage "");
|
|
devShells.default = pkgs.mkShell {
|
|
shellHook = ''
|
|
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
|
|
export RUST_LOG=info
|
|
'';
|
|
buildInputs = runtimeDeps;
|
|
nativeBuildInputs =
|
|
buildDeps ++ devDeps ++ [ (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)) ];
|
|
};
|
|
|
|
treefmt = {
|
|
projectRootFile = "./flake.nix";
|
|
programs = {
|
|
nixfmt.enable = true;
|
|
rustfmt.enable = true;
|
|
};
|
|
};
|
|
};
|
|
flake = {
|
|
# The usual flake attributes can be defined here, including system-
|
|
# agnostic ones like nixosModule and system-enumerating ones, although
|
|
# those are more easily expressed in perSystem.
|
|
|
|
};
|
|
};
|
|
}
|