Files
sumi/flake.nix

101 lines
2.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
description = "Go + raylib-go sketch project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
# Your Go module name (optional; buildGoModule can infer from go.mod)
pname = "sumi";
version = "0.1.0";
# Common native deps for raylib + windowing/audio.
# raylib itself in nixpkgs already brings many deps, but being explicit
# here makes devShell + builds more predictable.
nativeDeps = with pkgs; [
pkg-config
];
raylibDeps = with pkgs; [
raylib
# X11 stack (works under XWayland too)
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXrandr
# Wayland stack (raylib/glfw can use this depending on build/options)
wayland
libxkbcommon
# GL + audio
mesa
alsa-lib
pulseaudio
];
in
{
packages.default = pkgs.buildGoModule {
inherit pname version;
src = self;
# raylib-go uses CGO to link against libraylib
env.CGO_ENABLED = 1;
# GOFLAGS = [ "-mod=mod" ];
# proxyVendor = true;
nativeBuildInputs = nativeDeps;
buildInputs = raylibDeps;
# If your main package isnt at repo root, set this (examples):
# subPackages = [ "./cmd/sketch" ];
# First build will fail with a message containing the correct hash.
vendorHash = "sha256-pcNGzxHripkn9lX2R9O29nYvR+hWLxIev4KJmEhQwC8=";
# Optional: strip for smaller binaries
ldflags = [
"-s"
"-w"
];
doCheck = false;
};
devShells.default = pkgs.mkShell {
# Tools you want while hacking
packages = with pkgs; [
go
gopls
delve
gotools
];
nativeBuildInputs = nativeDeps;
buildInputs = raylibDeps;
# Helps CGO find headers/libs
shellHook = ''
export CGO_ENABLED=1
'';
};
}
);
}