Skip to content

Instantly share code, notes, and snippets.

@cdaringe
Last active August 6, 2025 02:49
Show Gist options
  • Save cdaringe/b68b0c273ba3e937e2bddb384d162b72 to your computer and use it in GitHub Desktop.
Save cdaringe/b68b0c273ba3e937e2bddb384d162b72 to your computer and use it in GitHub Desktop.
sm64coopdx nix file
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
# Build tools
pkgs.gnumake
pkgs.gcc
pkgs.python3
pkgs.pkg-config
pkgs.coreutils
pkgs.which
pkgs.SDL2
pkgs.glew
pkgs.libGL
pkgs.libGLU
pkgs.curl
# Audio (SDL2 handles this, but may need ALSA on Linux)
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.alsa-lib
pkgs.libpulseaudio
pkgs.procps # provides nproc command
];
shellHook = ''
export COMPILER=gcc
export CC=gcc
export CXX=clang++
# On macOS, use the system Xcode SDK for framework headers.
# XCode is now required, as OpenGL libs are distributed here.
if [[ "$OSTYPE" == "darwin"* ]]; then
XCODE_SDK_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
if [ -d "$XCODE_SDK_PATH" ]; then
echo "Using Xcode SDK at: $XCODE_SDK_PATH"
# Set SDK root for proper framework discovery
export SDKROOT="$XCODE_SDK_PATH"
# Add framework header paths for direct access (AudioToolbox/AudioToolbox.h, OpenGL/glu.h, etc.)
export EXTRA_INCLUDES="$XCODE_SDK_PATH/System/Library/Frameworks"
export CPPFLAGS="$CPPFLAGS -I$XCODE_SDK_PATH/System/Library/Frameworks"
# Add framework search path for linking
export LDFLAGS="$LDFLAGS -F$XCODE_SDK_PATH/System/Library/Frameworks"
# Also add usr/include for system headers
export CPPFLAGS="$CPPFLAGS -I$XCODE_SDK_PATH/usr/include"
else
echo "Warning: Xcode SDK not found at $XCODE_SDK_PATH"
echo "Please install Xcode or Xcode Command Line Tools"
fi
fi
echo "Nix development shell loaded!"
export BUILD_CMD="make clean && make COMPILER=clang OSX_BUILD=1 -j\$(nproc || sysctl -n hw.ncpu)"
echo "BUILD_CMD: $BUILD_CMD"
echo "Run it by calling 'build' in this shell."
function build {
eval "$BUILD_CMD"
}
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment