{ 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"; }; outputs = { self, nixpkgs, fenix, flake-utils }: let mkWiringOp = { fetchFromGitHub, lib }: fetchFromGitHub { owner = "orangepi-xunlong"; repo = "wiringOP"; rev = "d7bb9d97db265476e6afa8186f2406642e6946be"; hash = "sha256-jVfNb0YqaYFd2r5zupy8C1Q1jDAfetPRVKbhtyMBLtg="; }; in 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 ''; wiringop = pkgs.callPackage mkWiringOp { }; 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; }; }) // { 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; }; }