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";
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
outputs = { self, nixpkgs, fenix, flake-utils }:
|
2024-10-29 12:54:42 +00:00
|
|
|
let
|
2024-11-02 11:53:35 +00:00
|
|
|
mkWiringOp = { fetchFromGitHub, lib }: fetchFromGitHub {
|
|
|
|
owner = "orangepi-xunlong";
|
|
|
|
repo = "wiringOP";
|
|
|
|
rev = "d7bb9d97db265476e6afa8186f2406642e6946be";
|
|
|
|
hash = "sha256-jVfNb0YqaYFd2r5zupy8C1Q1jDAfetPRVKbhtyMBLtg=";
|
2024-10-29 12:54:42 +00:00
|
|
|
};
|
2024-11-02 11:53:35 +00:00
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
target = "aarch64-unknown-linux-gnu";
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
fenix.overlays.default
|
|
|
|
];
|
|
|
|
};
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
devToolchain = with fenix.packages.${system}; combine [
|
|
|
|
stable.cargo
|
|
|
|
stable.rustc
|
|
|
|
stable.clippy
|
|
|
|
stable.rustfmt
|
|
|
|
targets.${target}.stable.rust-std
|
|
|
|
];
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
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";
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
wiringop-headers = pkgs.runCommandLocal "wiringOP-headers" { } ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
cp ${wiringop}/wiringPi/*.h $out/include
|
|
|
|
'';
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
wiringop = pkgs.callPackage mkWiringOp { };
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
LIBCLANG_PATH = "${pkgs.llvmPackages_18.clang-unwrapped.lib}/lib";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
devShells.default =
|
|
|
|
pkgs.mkShell {
|
|
|
|
nativeBuildInputs = [
|
|
|
|
devToolchain
|
|
|
|
pkgs.llvmPackages_18.clang
|
|
|
|
];
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
buildInputs = [
|
|
|
|
wiringop-headers
|
|
|
|
pkgs.libxcrypt
|
|
|
|
];
|
2024-10-29 12:54:42 +00:00
|
|
|
|
2024-11-02 11:53:35 +00:00
|
|
|
WIRINGOP_PATH = "${wiringop}";
|
|
|
|
|
|
|
|
inherit LIBCLANG_PATH CARGO_BUILD_TARGET CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER;
|
|
|
|
};
|
|
|
|
}) // {
|
|
|
|
overlays.default = final: prev: {
|
|
|
|
wiringop = final.callPackage (import ./package.nix) { srcAll = final.callPackage mkWiringOp { }; };
|
|
|
|
};
|
|
|
|
|
|
|
|
packages.aarch64-linux.default =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
system = "aarch64-linux";
|
|
|
|
overlays = [ self.overlays.default ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
pkgs.wiringop;
|
|
|
|
};
|
2024-10-29 12:54:42 +00:00
|
|
|
}
|