{ description = "the"; inputs = { nixpkgs.url = github:nixos/nixpkgs/release-22.05; rust-overlay.url = github:oxalica/rust-overlay; utils.url = github:numtide/flake-utils; crane.url = github:ipetkov/crane; crane.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, utils, rust-overlay, crane }: utils.lib.eachDefaultSystem (system: let overlays =[ rust-overlay.overlays.default ]; pkgs = import nixpkgs { inherit system overlays; }; tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; }; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; nativeDeps = with pkgs; [ pkg-config lld cmake ]; deps = with pkgs; [ openssl fontconfig ]; libPath = with pkgs; with xorg; lib.makeLibraryPath [ libX11 libXcursor libXrandr libXi vulkan-loader ]; commonArgs = { inherit (tomlInfo) pname version; src = craneLib.cleanCargoSource ./.; buildInputs = deps; nativeBuildInputs = nativeDeps; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; in rec { devShell = pkgs.mkShell rec { buildInputs = [ toolchain pkgs.rust-analyzer pkgs.wasm-pack ] ++ deps; nativeBuildInputs = nativeDeps; LD_LIBRARY_PATH = "${libPath}"; }; packages = rec { bhaang = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); default = bhaang; patched = default.overrideAttrs (_: { fixupPhase = '' patchelf \ --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "${libPath}" $out/bin/bhaang ''; }); }; defaultPackage = packages.default; } ); }