Including SDL2.dev in build environment

Hi there!

I’m trying to update the nixpkg for basiliskii to the latest version, and I’m getting stuck with dependencies.

The configure script needs access to sdl2-config which is located in SDL2 (or SDL2.dev I believe) however it does not get detected by configure:

configure: error: You need SDL Audio to use BINCUE support.

I’ve tried:

  • adding SDL2.dev to buildInputs and nativeBuildInputs
  • adding the following to env:
    • SDL_CONFIG = “${SDL2.dev}/bin/sdl2-config”;
    • PATH = lib.makeBinPath [ SDL2.dev ];

If I create a nix-shell with SDL2, the binary does show up there.

I’m relatively new to creating packages, any advice would be appreciated.

Thanks,
Dan

Here is the entire package.nix:

{ stdenv
, lib
, fetchFromGitHub
, autoconf
, automake
, pkg-config
, SDL2
, SDL2_sound
, gtk2
, mpfr
, libICE
, ncurses
, readline
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "basiliskii";
  version = "unstable-2025-02-10";

  src = fetchFromGitHub {
    owner = "cebix";
    repo = "macemu";
	rev = "96e512bd6376e78a2869f16dcc8a9028bce5ee72";
    hash = "sha256-ZWE51cRAKj8YFkiBHtd1/M5bWElbdNC30gmYk/cmxEo=";
  };
  sourceRoot = "${finalAttrs.src.name}/BasiliskII/src/Unix";
  patches = [ ];
  nativeBuildInputs = [
    autoconf
    automake
    pkg-config
	SDL2
	SDL2_sound
	SDL2.dev
  ];
  buildInputs = [
    SDL2
	SDL2_sound
	SDL2.dev
    gtk2
    mpfr
	libICE
	ncurses
	readline
  ];
  
   
  env = {
    #SDL_CONFIG = "${SDL2.dev}/bin/sdl2-config";
	PATH = lib.makeBinPath [ SDL2.dev ];
  };
  
  # was in preConfigure before autogen:
  preConfigure = ''
    NO_CONFIGURE=1 ./autogen.sh
  '';
  configureFlags = [
    "--enable-sdl-video"
    "--enable-sdl-audio"
    "--with-bincue"
  ];

  meta = with lib; {
    description = "68k Macintosh emulator";
    homepage = "https://basilisk.cebix.net/";
    license = licenses.gpl2;
    maintainers = with maintainers; [  ];
    platforms = platforms.linux;
    mainProgram = "BasiliskII";
  };
})

Add "--with-sdl2" to configureFlags.

Also:

  • You don’t need to mess with PATH here.
  • You don’t need to include .dev for anything in buildInputs. The .dev is implied.
  • Any libraries you want your program to use at run time go in buildInputs, not nativeBuildInputs.
2 Likes

Beauty, thanks a lot rhendric!