wiringop-rs/flake.nix

70 lines
1.8 KiB
Nix
Raw Normal View History

2024-10-29 12:54:42 +00:00
{
description = "Rust library for interacting with wiringOP (Orange Pi fork of wiringPi)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
fenix.url = "github:nix-community/fenix";
naersk.url = "github:nix-community/naersk";
wiringop = {
url = "github:orangepi-xunlong/wiringOP";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, fenix, naersk, wiringop, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
target = "aarch64-unknown-linux-gnu";
pkgs = import nixpkgs {
inherit system;
overlays = [
fenix.overlays.default
];
};
devToolchain = with fenix.packages.${system}; combine [
stable.cargo
stable.rustc
stable.clippy
stable.rustfmt
targets.${target}.stable.rust-std
];
CARGO_BUILD_TARGET = target;
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER =
let
inherit (pkgs.pkgsCross.aarch64-multiplatform.stdenv) cc;
in
"${cc}/bin/${cc.targetPrefix}cc";
wiringop-headers = pkgs.runCommandLocal "wiringOP-headers" { } ''
mkdir -p $out/include
cp ${wiringop}/wiringPi/*.h $out/include
'';
LIBCLANG_PATH = "${pkgs.llvmPackages_18.clang-unwrapped.lib}/lib";
in
{
devShells.default =
pkgs.mkShell {
nativeBuildInputs = [
devToolchain
pkgs.llvmPackages_18.clang
];
buildInputs = [
wiringop-headers
pkgs.libxcrypt
];
WIRINGOP_PATH = "${wiringop}";
inherit LIBCLANG_PATH CARGO_BUILD_TARGET CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER;
};
});
}