How can I make a nix file for Horse Tab?

I’m trying to make a nix file for Horse Tab

I have

with import <nixpkgs> { };

let
  horsetab = 
    rustPlatform.buildRustPackage rec {
      pname = "horsetab";

      src = fetchFromGitHub {
        owner = "ChrisVilches";
        repo = "horsetab";
        rev = "7f3a5cdc38a3d52248f376ad0c4259d13a80212a";
        sha256
 = "sha256-8Nv7GLx4hT18E1kTVTvF84Tk/SmReExMh1b+YIe2g4E=";
      };

      cargoSha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # This still needs to be replaced

      nativeBuildInputs = [ pkg-config ];
      buildInputs = [ openssl xorg.libX11 xorg.libXcursor xorg.libXrandr xorg.libXi ];
    };
in
mkShell {
  name = "horsetab-dev";
  buildInputs = [
    rustc
    cargo
    pkg-config
    openssl
    xorg.libX11
    xorg.libXcursor
    xorg.libXrandr
    xorg.libXi
    xorg.xorgproto
  ];

  shellHook = ''
    export PKG_CONFIG_PATH="${pkgs.xorg.libX11.dev}/lib/pkgconfig:${pkgs.xorg.libXcursor.dev}/lib/pkgconfig:${pkgs.xorg.libXrandr.dev}/lib/pkgconfig:${pkgs.xorg.libXi.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export LD_LIBRARY_PATH="${pkgs.xorg.libX11}/lib:${pkgs.xorg.libXcursor}/lib:${pkgs.xorg.libXrandr}/lib:${pkgs.xorg.libXi}/lib:$LD_LIBRARY_PATH"
    echo "HorseTab development environment"
    echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
    echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
    if [ ! -d "horsetab" ]; then
      echo "Cloning HorseTab repository..."
      git clone https://github.com/ChrisVilches/horsetab.git
    fi
    cd horsetab
    echo "Run 'cargo build' to compile the project"
  '';
}

, but I get:


  --- stderr
  thread 'main' panicked at /home/b0ef/.cargo/registry/src/index.crates.io-6f17d22bba15001f/x11-2.21.0/build.rs:42:14:
  called `Result::unwrap()` on an `Err` value: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "x11" "x11 >= 1.4.99.1"` did not exit successfully: exit status: 1
  error: could not find system library 'x11' required by the 'x11' crate

  --- stderr
  Package x11 was not found in the pkg-config search path.
  Perhaps you should add the directory containing `x11.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'x11' found
  Package x11 was not found in the pkg-config search path.
  Perhaps you should add the directory containing `x11.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'x11' found

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Did you look into bindgenHook for packaging?

Also, you should be using the horsetab derivation (it’s currently unused) rather than the shell you have (which only contains some of its dependencies, and some envvars that you shouldn’t set).