{ inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; }; }; }; outputs = { flake-utils, nixpkgs, rust-overlay, ... }: flake-utils.lib.eachDefaultSystem ( system: let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default.override { targets = [ "wasm32-unknown-unknown" ]; }; build_inputs = pkgs.lib.optionals pkgs.stdenv.isLinux ( with pkgs; [ alsa-lib libxkbcommon udev vulkan-loader wayland xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr ] ); native_build_inputs = with pkgs; [ cargo-auditable nodePackages.prettier pkg-config trunk wasm-bindgen-cli ]; code = pkgs.callPackage ./. { inherit pkgs system build_inputs native_build_inputs ; }; in rec { packages = code // { all = pkgs.symlinkJoin { name = "all"; paths = with code; [ example lib ]; }; example = pkgs.symlinkJoin { name = "example"; paths = with code; [ example ]; }; lib = pkgs.symlinkJoin { name = "lib"; paths = with code; [ lib ]; }; default = packages.all; override = packages.all; overrideDerivation = packages.all; }; devShells.default = pkgs.mkShell { buildInputs = (with pkgs; [ cargo-release cargo-watch rust-analyzer ]) ++ [ rustToolchain ] ++ build_inputs; nativeBuildInputs = native_build_inputs; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath build_inputs; }; formatter = pkgs.nixfmt-rfc-style; } ); }