Help packaging JoyShockMapper (cmake)

I created Init JoyShockMapper at v3.4.0 · Issue #209810 · NixOS/nixpkgs · GitHub when I ran up against a wall packaging JoyShockMapper for nixos. I don’t have a great understanding cmake or how the project is built, but I think I made some progress. I would love help finishing this!

pkgs.stdenv.mkDerivation rec {
  pname = "JoyShockMapper";
  version = "3.4.0";

  src = pkgs.fetchFromGitHub {
    owner = "Electronicks";
    repo = "JoyShockMapper";
    rev = "v${version}";
    sha256 = "sha256-BOXDqLvBIXD2nCoDHJxDdew5ATPlG6ZaMR+I+LQDbTE=";
  };

  buildInputs = with pkgs; [
    gnumake
    clang
    cmake
    gtk3
    libappindicator
    libevdev
    libusb1
    SDL2
    hidapi

    pcre2
    glib
    pkg-config
  ];

  nativeBuildInputs = with pkgs; [
    cmake pkg-config
  ];

  buildPhase = ''
    mkdir build
    cd build
    cmake .. -DCMAKE_CXX_COMPILER=clang++
    cmake --build .
  '';
}

Gives me an error and the warning Package 'mount', required by 'gio-2.0', not found but adding mount and gio to buildInputs did not solve the problem and I feel stuck :frowning:

Thanks for taking the time to read this!

1 Like

I’m not an expert on this either, but here are a few notes:

  • You don’t need to put the same things in nativeBuildInputs and buildInputs, except in very rare cases. cmake and pkg-config should be fine being only in nativeBuildInputs.
  • If cmake is in nativeBuildInputs, I believe the buildPhase will automatically use it. You shouldn’t need to override it. Your override may be clobbering things that would have made it work without hassle. If you need some extra commands to run, it’s usually better to put them in hooks rather than overriding phases wholesale.
  • gnumake is provided by stdenv automatically, and even if it wasn’t, it would go in nativeBuildInputs, not buildInputs. (Also, do you really need it in a cmake project?)

I agree with comments from tejing. Regarding the warning, I also get that one for another package I maintain (bespokesynth), but it compiles fine even with the warning and I never encountered any issue later… so it might not be what is stopping you.

In any case, I’d start with removing your buildPhase, cmake automatically configures everything for you.

Hosted by Flying Circus.