Created flake and added license.txt

This commit is contained in:
chrisbell committed 2026-11-01 23:07:19 -06:00
1 parent 013d9d5cf2
commit 4ad6685042
4 files changed
+261

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
.envrc
.direnv/
build/
+7
View File
@@ -0,0 +1,7 @@
Copyright (c) 2026 Bellsworne LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Generated
+63
View File
@@ -0,0 +1,63 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1793341285,
"narHash": "sha256-Y1CiZ4SoBUjLQyQM/pY+rS2dXD3CHLPstF0lmOc73D4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1c89083e451e891152365b799595cf7790a43325",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"odin-src": {
"flake": false,
"locked": {
"lastModified": 1791295716,
"narHash": "sha256-Y8Em52W3ntWXgnRiRAyhWv5Y6+3b/4bj2+TTIvtniYU=",
"owner": "odin-lang",
"repo": "Odin",
"rev": "84bc3fc2100b0f7880a3af37f71bccdcda41c6f9",
"type": "github"
},
"original": {
"owner": "odin-lang",
"ref": "dev-2026-10",
"repo": "Odin",
"type": "github"
}
},
"ols-src": {
"flake": false,
"locked": {
"lastModified": 1791685123,
"narHash": "sha256-tVg9g5aN4ovUElpDzTSLpTQUq3OEiYUaq3YO98ex8wA=",
"owner": "DanielGavin",
"repo": "ols",
"rev": "c96dea912cf8272da7bb01a68696af5dfe1269ca",
"type": "github"
},
"original": {
"owner": "DanielGavin",
"ref": "dev-2026-10",
"repo": "ols",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"odin-src": "odin-src",
"ols-src": "ols-src"
}
}
},
"root": "root",
"version": 7
}
+187
View File
@@ -0,0 +1,187 @@
{
description = "Regolith, a retained mode GUI library for Odin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Pinned to the latest monthly release tag
# If you change this, also change odinVersion below
odin-src = {
url = "github:odin-lang/Odin/dev-2026-10";
flake = false;
};
# OLS must match the Odin revision
ols-src = {
url = "github:DanielGavin/ols/dev-2026-10";
flake = false;
};
};
outputs = { self, nixpkgs, odin-src, ols-src }:
let
lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f:
lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
odinVersion = "2026-10";
build = pkgs:
let
llvmPackages = pkgs.llvmPackages_20;
odin = llvmPackages.stdenv.mkDerivation {
pname = "odin";
version = "dev-${odinVersion}";
src = odin-src;
nativeBuildInputs = [ pkgs.makeBinaryWrapper pkgs.which ];
buildInputs = [ llvmPackages.llvm ];
LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config";
# The build script stamps the version from the build date, which is
# meaningless inside the Nix sandbox. Stamp the tag instead.
postPatch = ''
substituteInPlace build_odin.sh \
--replace-fail '$(date +"%Y-%m")' '${odinVersion}'
patchShebangs build_odin.sh
'';
dontConfigure = true;
buildPhase = ''
runHook preBuild
./build_odin.sh release
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share
cp odin $out/bin/odin
for d in base core vendor shared; do
if [ -d "$d" ]; then cp -r "$d" $out/share/; fi
done
wrapProgram $out/bin/odin \
--prefix PATH : ${lib.makeBinPath [
llvmPackages.bintools
llvmPackages.clang
llvmPackages.lld
]} \
--set-default ODIN_ROOT $out/share
# Build the C parts of the vendor collection.
for v in stb cgltf miniaudio; do
d="$out/share/vendor/$v/src"
[ -d "$d" ] || continue
if [ -f "$d/Makefile" ] || [ -f "$d/makefile" ] || [ -f "$d/GNUmakefile" ]; then
make -C "$d"
elif [ -f "$d/build_$v.sh" ]; then
patchShebangs "$d/build_$v.sh"
(cd "$d" && "./build_$v.sh") || echo "vendor/$v: build script failed, skipping"
else
echo "vendor/$v/src: no known build entry point, skipping"
fi
done
runHook postInstall
'';
};
ols = pkgs.stdenv.mkDerivation {
pname = "ols";
version = "dev-${odinVersion}";
src = ols-src;
nativeBuildInputs = [ odin ];
dontConfigure = true;
postPatch = ''
patchShebangs build.sh odinfmt.sh
'';
buildPhase = ''
runHook preBuild
./build.sh
./odinfmt.sh
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 ols $out/bin/ols
install -Dm755 odinfmt $out/bin/odinfmt
runHook postInstall
'';
};
in
{ inherit odin ols llvmPackages; };
in
{
packages = forAllSystems (pkgs:
let p = build pkgs; in {
inherit (p) odin ols;
default = p.odin;
});
devShells = forAllSystems (pkgs:
let
p = build pkgs;
llvmPackages = p.llvmPackages;
runtimeLibs = with pkgs; [
sdl3
wayland
libxkbcommon
libdecor
vulkan-loader
libGL
];
in
{
default = (pkgs.mkShell.override { stdenv = llvmPackages.stdenv; }) {
name = "regolith";
packages = [
# Odin toolchain
p.odin
p.ols
llvmPackages.lld
llvmPackages.bintools
# Native build and runtime
pkgs.pkg-config
pkgs.sdl3
# WASM
pkgs.emscripten
pkgs.nodejs
pkgs.python3
# Lua tooling (the engine builds its own vendored Lua)
pkgs.lua5_4
pkgs.lua54Packages.luacheck
# Debugging
pkgs.gdb
pkgs.valgrind
pkgs.git
];
shellHook = ''
# Emscripten needs a writable cache, and the store is read only.
export EM_CACHE="$PWD/.cache/emscripten"
mkdir -p "$EM_CACHE"
# SDL3 dlopens these at runtime. nixpkgs SDL3 is patched to find
# most of them, this is a fallback for anything built outside Nix.
export LD_LIBRARY_PATH="${lib.makeLibraryPath runtimeLibs}:/run/opengl-driver/lib:''${LD_LIBRARY_PATH:-}"
'';
};
});
};
}