{
  inputs = {
    nixpkgs.url      = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url  = "github:numtide/flake-utils";
    nixgl.url        = "github:guibou/nixGL";
  };

  outputs = { self, nixpkgs, flake-utils, nixgl, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        overlays = [ nixgl.overlay ];
        pkgs = import nixpkgs {
          inherit system overlays;
        };
        naga-cli = pkgs.rustPlatform.buildRustPackage rec {
          pname = "naga-cli";
          version = "v0.19.0";

          src = pkgs.fetchFromGitHub {
            name = "wgpu";
            owner = "gfx-rs";
            repo = "wgpu";
            rev = "a63bec8cd67b4abe3b9717e1926a94d1035b830a"; # trunk as of 2024-03-15
            hash = "sha256-AzsR24NAVYgrC/kWGXiWxyMERiLJ/Jink21P4oh8lOw=";
          };
          buildAndTestSubdir = "naga-cli";

          cargoLock = {
            lockFile = "${src}/Cargo.lock";
            allowBuiltinFetchGit = true;
          };
        };
      in
      {
        devShell = pkgs.mkShell {
          buildInputs = with pkgs; (if pkgs.system == "aarch64-darwin" || pkgs.system == "x86_64-darwin" then [
            pkg-config
            binutils
            curlMinimal
            clang
            bear
            naga-cli
            darwin.apple_sdk.frameworks.Kernel
            darwin.apple_sdk.frameworks.CoreVideo
            darwin.apple_sdk.frameworks.Metal
            darwin.apple_sdk.frameworks.MetalKit
            darwin.apple_sdk.frameworks.Cocoa
          ] else if pkgs.system == "x86_64-linux" then [
            pkg-config
            binutils
            clang
            bear
            naga-cli
            libGL
            mesa
            gf
            xorg.libX11
            xorg.libXi
            xorg.xinput
            xorg.libXcursor
            xorg.libXrandr
            xorg.libXinerama
            pkgs.nixgl.nixGLIntel
          ] 
          else throw "unsupported system" );
        };
      }
    );
}