todoodoo/flake.nix
2024-08-09 11:41:15 +02:00

113 lines
2.7 KiB
Nix

{
description = "ToDooDoo";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
fenix,
}:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f (
let
pkgs = import nixpkgs { inherit system; };
fenix' = (import fenix { inherit system pkgs; });
toolchain = fenix'.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-3jVIIf5XPnUU1CRaTyAiO0XHVbJl12MSx3eucTXCjtE=";
};
buildInputs = with pkgs; [
rust-analyzer
rustfmt
clippy
clang
mold
pkg-config
libGLU
libGL
libxkbcommon
wayland
];
in
{
inherit pkgs toolchain buildInputs;
}
)
);
in
{
formatter = forEachSupportedSystem (
{ pkgs, ... }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper
);
devShells = forEachSupportedSystem (
{
pkgs,
toolchain,
buildInputs,
}:
{
default = pkgs.mkShell {
buildInputs = buildInputs ++ [ toolchain ];
env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (buildInputs)}";
};
};
}
);
packages = forEachSupportedSystem (
{
pkgs,
toolchain,
buildInputs,
}:
{
default = (
let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
in
rustPlatform.buildRustPackage {
inherit buildInputs;
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
}
);
}
);
};
}