Last active
January 10, 2024 01:15
-
-
Save haller33/0d87338cb002bb3215472f0b1496ca01 to your computer and use it in GitHub Desktop.
Nix Shell for Odin Programming Language with support for any* branch of the Main Project ( such as ex.: dev-2023-10 or master )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT License | |
# | |
# Copyright (c) 2023 haller33 | |
# | |
# 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. | |
# Go To New Repo in Flakes! | |
# the is now a new version of this shell using Flakes, that made this shell kind obsolete and major of development will move tho this new repo | |
# | |
# https://github.com/haller33/Odin-Flake | |
# | |
let | |
unstableTarball = | |
fetchTarball | |
https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz; | |
pkgs = import <nixpkgs> { }; | |
unstable = import unstableTarball {}; | |
in | |
with pkgs; | |
mkShell { | |
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${ | |
with pkgs; | |
pkgs.lib.makeLibraryPath [ libGL xorg.libX11 xorg.libXi SDL2 SDL vulkan-loader glfw ] | |
}"; | |
nativeBuildInputs = let | |
odin_neo = pkgs.odin.overrideAttrs (finalAttrs: previousAttrs: { | |
pname = "odin_neo"; | |
version = "master"; | |
src = fetchFromGitHub { | |
owner = "odin-lang"; | |
repo = "Odin"; | |
rev = finalAttrs.version; | |
hash = "sha256-nBq/R2BYqSpuo8H0DBE4cgkV5OxyK5zSnhzRTpAp/FQ="; | |
# name = "${finalAttrs.pname}-${finalAttrs.version}"; # not gona work . | |
}; | |
nativeBuildInputs = [ makeBinaryWrapper which ]; | |
buildInputs = lib.optional stdenv.isDarwin libiconv; | |
LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config"; | |
postPatch = lib.optionalString stdenv.isDarwin '' | |
sed -i src/main.cpp \ | |
-e 's|-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk|-syslibroot ${MacOSX-SDK}|' | |
'' + '' | |
sed -i build_odin.sh \ | |
-e 's/^GIT_SHA=.*$/GIT_SHA=/' \ | |
-e 's/LLVM-C/LLVM/' \ | |
-e 's/framework System/lSystem/' | |
patchShebangs build_odin.sh | |
''; | |
dontConfigure = true; | |
buildFlags = [ "release" ]; | |
preBuild = '' | |
echo "# for use of STB libraries" | |
cd vendor/stb/src | |
make | |
cd ../../.. | |
''; | |
installPhase = '' | |
runHook preInstall | |
mkdir -p $out/bin | |
cp odin $out/bin/odin | |
mkdir -p $out/share | |
cp -r core $out/share/core | |
cp -r vendor $out/share/vendor | |
wrapProgram $out/bin/odin \ | |
--prefix PATH : ${ | |
lib.makeBinPath (with llvmPackages; [ bintools llvm clang lld ]) | |
} \ | |
--set-default ODIN_ROOT $out/share | |
runHook postInstall | |
''; | |
}); | |
in [ odin_neo ] ++ [ | |
unstable.ols | |
# SDL | |
SDL2 | |
SDL | |
# GLFW | |
glfw | |
# vulkan | |
vulkan-headers | |
vulkan-loader | |
vulkan-tools | |
glxinfo | |
lld | |
gnumake | |
xorg.libX11.dev | |
xorg.libX11 | |
xorg.libXft | |
xorg.libXi | |
xorg.libXinerama | |
libGL | |
## not need because of vendor | |
# stb | |
# lua | |
valgrind | |
rr | |
# needed for raylib | |
xorg.libXcursor | |
xorg.libXrandr | |
xorg.libXinerama | |
]; | |
} |
just do
$ nix-shell
on the shell, to get access to the Odin with the branch you hanted
thanks @znaniye for helping with this shell! as well on beta-tester hehe
the is now a new version of this shell using Flakes, that made this shell kind obsolete and major of development will move tho this new repo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from the reference the hash sold be remove or edited since is from the hash, and it can change over time...