{ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, treefmt-nix, }: let supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; }); in { formatter = forEachSupportedSystem ( { pkgs }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper ); packages = forEachSupportedSystem ( { pkgs }: let system-map = { "x86_64-linux" = "amd64"; "aarch64-linux" = "arm64"; }; system = system-map.${pkgs.system}; hash-map = { "x86_64-linux" = "sha256-kDZYBSElpNkKxx4VXNa7d3WIv4EU8jgbWh731wChueQ="; "aarch64-linux" = "sha256-kDZYBSElpNkKxx4VXNa7d3WIv4EU8jgbWh731wChueQ="; }; hash = hash-map.${pkgs.system}; in { default = pkgs.stdenv.mkDerivation rec { pname = "spacetime-bin"; version = "v0.9.0-beta"; src = pkgs.fetchzip { url = "https://github.com/clockworklabs/SpacetimeDB/releases/download/${version}/spacetime.linux-${system}.tar.gz"; inherit hash; }; buildPhase = '' ls -la patchelf \ --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath ${pkgs.stdenv.cc.cc.lib}/lib64 \ ./spacetime mkdir -p $out/bin cp spacetime $out/bin/spacetime ''; }; } ); devShells = forEachSupportedSystem ( { pkgs }: { default = pkgs.mkShell { nativeBuildInputs = [ ]; buildInputs = [ ]; }; } ); }; }