{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, rust-overlay }: let inherit (nixpkgs) lib; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" "armv7l-linux" ]; forAllSystems = f: lib.genAttrs systems (system: let pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; }; rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages; toolchain = rust-bin.stable.latest.default.override { extensions = [ "rust-src" "rust-analyzer" "rust-std" ]; }; in f system pkgs toolchain); in { devShells = forAllSystems (system: pkgs: toolchain: { default = pkgs.mkShell { nativeBuildInputs = [ toolchain pkgs.cargo-edit ]; RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; }); packages = forAllSystems (system: pkgs: toolchain: let rustPlatform = pkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; }; cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./.cargo ./Cargo.toml ./Cargo.lock ./LICENSE ./README.md ./build.rs ./examples ./rustfmt.toml ./src ]; }; in { default = self.packages.${system}.example-binaries; example-binaries = rustPlatform.buildRustPackage { pname = "empidee-example-bins"; inherit (cargoToml.package) version; inherit src; cargoLock.lockFile = ./Cargo.lock; cargoBuildFlags = [ "--examples" ]; # TODO: avoid the binary variant with the hash at the end postInstall = '' find "$releaseDir"/examples -type f -executable -exec install -Dt "$out/bin" {} \; ''; doCheck = true; useNextest = true; }; }); }; }