{ nixConfig.extra-substituters = [ "https://wrpc.cachix.org" "https://wasmcloud.cachix.org" "https://nixify.cachix.org" "https://crane.cachix.org" "https://bytecodealliance.cachix.org" "https://nix-community.cachix.org" "https://cache.garnix.io" ]; nixConfig.extra-trusted-public-keys = [ "wrpc.cachix.org-1:J1xnzWo1nnhlzOmZCA10/5wz87LwCFwQtnqCibCy67w=" "wasmcloud.cachix.org-1:9gRBzsKh+x2HbVVspreFg/6iFRiD4aOcUQfXVDl3hiM=" "nixify.cachix.org-1:95SiUQuf8Ij0hwDweALJsLtnMyv/otZamWNRp1Q1pXw=" "crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" "bytecodealliance.cachix.org-1:0SBgh//n2n0heh0sDFhTm+ZKBRy2sInakzFGfzN531Y=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ]; inputs.nixify.inputs.nixlib.follows = "nixlib"; inputs.nixify.url = "github:rvolosatovs/nixify"; inputs.nixlib.url = "github:nix-community/nixpkgs.lib"; inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.wit-deps.inputs.nixify.follows = "nixify"; inputs.wit-deps.inputs.nixlib.follows = "nixlib"; inputs.wit-deps.url = "github:bytecodealliance/wit-deps/v0.3.5"; outputs = { nixify, nixlib, nixpkgs-unstable, wit-deps, ... }: with builtins; with nixlib.lib; with nixify.lib; rust.mkFlake { src = ./.; name = "wit-bindgen-wrpc"; overlays = [ wit-deps.overlays.default ( final: prev: { pkgsUnstable = import nixpkgs-unstable { inherit (final.stdenv.hostPlatform) system ; inherit (final) config ; }; } ) ]; excludePaths = [ ".envrc" ".github" ".gitignore" "flake.nix" "LICENSE" "README.md" ]; doCheck = false; # testing is performed in checks via `nextest` targets.arm-unknown-linux-gnueabihf = false; targets.arm-unknown-linux-musleabihf = false; targets.armv7-unknown-linux-gnueabihf = false; targets.armv7-unknown-linux-musleabihf = false; targets.powerpc64le-unknown-linux-gnu = false; targets.s390x-unknown-linux-gnu = false; targets.wasm32-unknown-unknown = false; targets.wasm32-wasi = false; clippy.allTargets = true; clippy.deny = ["warnings"]; clippy.workspace = true; test.allTargets = true; test.workspace = true; buildOverrides = { pkgs, pkgsCross ? pkgs, ... }: { buildInputs ? [], depsBuildBuild ? [], nativeBuildInputs ? [], nativeCheckInputs ? [], preCheck ? "", ... } @ args: with pkgs.lib; let darwin2darwin = pkgs.stdenv.hostPlatform.isDarwin && pkgsCross.stdenv.hostPlatform.isDarwin; depsBuildBuild' = depsBuildBuild ++ optional pkgs.stdenv.hostPlatform.isDarwin pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ++ optional darwin2darwin pkgs.xcbuild.xcrun; in { buildInputs = buildInputs ++ optional pkgs.stdenv.hostPlatform.isDarwin pkgs.libiconv; depsBuildBuild = depsBuildBuild'; } // optionalAttrs (args ? cargoArtifacts) { preCheck = '' export GOCACHE=$TMPDIR/gocache export GOMODCACHE=$TMPDIR/gomod export GOPATH=$TMPDIR/go export HOME=$TMPDIR/home '' + preCheck; depsBuildBuild = depsBuildBuild' ++ optionals darwin2darwin [ pkgs.darwin.apple_sdk.frameworks.CoreFoundation pkgs.darwin.apple_sdk.frameworks.CoreServices ]; nativeCheckInputs = nativeCheckInputs ++ [ pkgs.nats-server pkgs.pkgsUnstable.go ]; }; withPackages = { hostRustToolchain, packages, pkgs, ... }: let interpreters.aarch64-unknown-linux-gnu = "/lib/ld-linux-aarch64.so.1"; interpreters.riscv64gc-unknown-linux-gnu = "/lib/ld-linux-riscv64-lp64d.so.1"; interpreters.x86_64-unknown-linux-gnu = "/lib64/ld-linux-x86-64.so.2"; mkFHS = { name, src, interpreter, }: pkgs.stdenv.mkDerivation { inherit name src ; buildInputs = [ pkgs.patchelf ]; dontBuild = true; dontFixup = true; installPhase = '' runHook preInstall for p in $(find . -type f); do # https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header if head -c 4 $p | grep $'\x7FELF' > /dev/null; then patchelf --set-rpath /lib $p || true patchelf --set-interpreter ${interpreter} $p || true fi done mkdir -p $out cp -R * $out runHook postInstall ''; }; wit-bindgen-wrpc-aarch64-unknown-linux-gnu-fhs = mkFHS { name = "wit-bindgen-wrpc-aarch64-unknown-linux-gnu-fhs"; src = packages.wit-bindgen-wrpc-aarch64-unknown-linux-gnu; interpreter = interpreters.aarch64-unknown-linux-gnu; }; wit-bindgen-wrpc-riscv64gc-unknown-linux-gnu-fhs = mkFHS { name = "wit-bindgen-wrpc-riscv64gc-unknown-linux-gnu-fhs"; src = packages.wit-bindgen-wrpc-riscv64gc-unknown-linux-gnu; interpreter = interpreters.riscv64gc-unknown-linux-gnu; }; wit-bindgen-wrpc-x86_64-unknown-linux-gnu-fhs = mkFHS { name = "wit-bindgen-wrpc-x86_64-unknown-linux-gnu-fhs"; src = packages.wit-bindgen-wrpc-x86_64-unknown-linux-gnu; interpreter = interpreters.x86_64-unknown-linux-gnu; }; in packages // { inherit wit-bindgen-wrpc-aarch64-unknown-linux-gnu-fhs wit-bindgen-wrpc-riscv64gc-unknown-linux-gnu-fhs wit-bindgen-wrpc-x86_64-unknown-linux-gnu-fhs ; rust = hostRustToolchain; }; withDevShells = { devShells, pkgs, ... }: extendDerivations { buildInputs = [ pkgs.cargo-audit pkgs.nats-server pkgs.natscli pkgs.wit-deps pkgs.pkgsUnstable.go ]; } devShells; }; }