aoc2024/flake.nix

95 lines
2.7 KiB
Nix
Raw Normal View History

2024-12-02 06:25:29 +00:00
{
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 "");
2024-12-02 06:25:29 +00:00
devShells.default = pkgs.mkShell {
shellHook = ''
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
2024-12-12 11:59:51 +00:00
export RUST_LOG=info
'';
buildInputs = runtimeDeps;
nativeBuildInputs =
buildDeps ++ devDeps ++ [ (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)) ];
};
2024-12-02 06:25:29 +00:00
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.
};
};
}