{ inputs = { rust-overlay.url = "github:oxalica/rust-overlay/stable"; nixpkgs.follows = "rust-overlay/nixpkgs"; naersk = { url = "github:nix-community/naersk/master"; inputs.nixpkgs.follows = "rust-overlay/nixpkgs"; }; }; outputs = { nixpkgs, rust-overlay, naersk, ... }: let overlays = [ (import rust-overlay) (naersk.overlay) (import ./.nix/overlays.nix) ]; forAllSystems = f: nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ] ( system: f { pkgs = import nixpkgs { inherit overlays system; }; } ); in { inherit overlays; devShells = forAllSystems ( {pkgs, ...}: { default = with pkgs; mkShell { inputsFrom = [ fundamentum-edge ]; packages = [ bashInteractive coreutils diffutils grpcurl just cargo-readme ]; shellHook = '' # Avoid polluting home dir with local project stuff. if command -v git &> /dev/null; then CARGO_HOME="$(git rev-parse --show-toplevel)/.cargo" export CARGO_HOME export PATH=$PATH:$CARGO_HOME/bin fi ''; # As suggested in the tonic-build documentation: # # On NixOS, it is better to specify the location of `PROTOC` and `PROTOC_INCLUDE` explicitly. # The reason being that if `prost_build::compile_protos` fails to generate the resultant package, # the failure is not obvious until the `include!(concat!(env!("OUT_DIR"), "/resultant.rs"));` # fails with `No such file or directory` error. PROTOC = "${protobuf}/bin/protoc"; PROTOC_INCLUDE = "${protobuf}/include"; }; } ); packages = forAllSystems ( {pkgs, ...}: with pkgs; { default = fundamentum-edge; fundamentum-edge = fundamentum-edge; fundamentum-edge-windows = with pkgsCross.mingwW64.pkgsStatic; fundamentum-edge.override { rustTarget = "x86_64-pc-windows-gnu"; extraAttrs.CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS = "-L native=${windows.pthreads}/lib"; }; docker = fundamentum-edge-docker; } ); }; }