106 lines
2.4 KiB
Nix
106 lines
2.4 KiB
Nix
{
|
|
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 {
|
|
pname = "sumi";
|
|
version = "0.1.0";
|
|
|
|
src = pkgs.lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter =
|
|
path: type:
|
|
let
|
|
base = builtins.baseNameOf path;
|
|
in
|
|
base != "vendor" && base != ".git";
|
|
};
|
|
|
|
env.CGO_ENABLED = 1;
|
|
|
|
nativeBuildInputs = nativeDeps;
|
|
buildInputs = raylibDeps;
|
|
|
|
#vendorHash = "sha256-HDfllPEKJZOtkSoasS1yDCyZrWihlkBVRstLkF8AHd0=";
|
|
|
|
# use this every time there's vendor changeO
|
|
vendorHash = pkgs.lib.fakeHash;
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
];
|
|
doCheck = false;
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
# Tools you want while hacking
|
|
packages = with pkgs; [
|
|
go
|
|
gopls
|
|
delve
|
|
gotools
|
|
sqlite
|
|
];
|
|
|
|
nativeBuildInputs = nativeDeps;
|
|
buildInputs = raylibDeps;
|
|
|
|
# Helps CGO find headers/libs
|
|
shellHook = ''
|
|
export CGO_ENABLED=1
|
|
export XDG_SESSION_TYPE=x11
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
}
|