nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 103 lines 2.7 kB view raw
1{ 2 lib, 3 llvmPackages, 4 fetchFromGitHub, 5 makeBinaryWrapper, 6 which, 7 nix-update-script, 8}: 9 10let 11 inherit (llvmPackages) stdenv; 12in 13stdenv.mkDerivation (finalAttrs: { 14 pname = "odin"; 15 version = "dev-2025-07"; 16 17 src = fetchFromGitHub { 18 owner = "odin-lang"; 19 repo = "Odin"; 20 tag = finalAttrs.version; 21 hash = "sha256-4jhxvQHirNm4B4Wf5Ak0lhAbwaRw6ajWA0JhIn1NYwM="; 22 }; 23 24 patches = [ 25 ./darwin-remove-impure-links.patch 26 # The default behavior is to use the statically linked Raylib libraries, 27 # but GLFW still attempts to load Xlib at runtime, which won't normally be 28 # available on Nix based systems. Instead, use the "system" Raylib version, 29 # which can be provided by a pure Nix expression, for example in a shell. 30 ./system-raylib.patch 31 ]; 32 33 postPatch = '' 34 # Odin is still using 'arm64-apple-macos' as the target name on 35 # aarch64-darwin architectures. This results in a warning whenever the 36 # Odin compiler runs a build. Replacing the target in the Odin compiler 37 # removes the nix warning when the Odin compiler is ran on aarch64-darwin. 38 substituteInPlace src/build_settings.cpp \ 39 --replace-fail "arm64-apple-macosx" "arm64-apple-darwin" 40 41 rm -r vendor/raylib/{linux,macos,macos-arm64,wasm,windows} 42 43 patchShebangs --build build_odin.sh 44 ''; 45 46 LLVM_CONFIG = lib.getExe' llvmPackages.llvm.dev "llvm-config"; 47 48 dontConfigure = true; 49 50 buildFlags = [ "release" ]; 51 52 nativeBuildInputs = [ 53 makeBinaryWrapper 54 which 55 ]; 56 57 installPhase = '' 58 runHook preInstall 59 60 mkdir -p $out/bin 61 cp odin $out/bin/odin 62 63 mkdir -p $out/share 64 cp -r {base,core,vendor,shared} $out/share 65 66 wrapProgram $out/bin/odin \ 67 --prefix PATH : ${ 68 lib.makeBinPath ( 69 with llvmPackages; 70 [ 71 bintools 72 llvm 73 clang 74 lld 75 ] 76 ) 77 } \ 78 --set-default ODIN_ROOT $out/share 79 80 make -C "$out/share/vendor/cgltf/src/" 81 make -C "$out/share/vendor/stb/src/" 82 make -C "$out/share/vendor/miniaudio/src/" 83 84 runHook postInstall 85 ''; 86 87 passthru.updateScript = nix-update-script { }; 88 89 meta = { 90 description = "Fast, concise, readable, pragmatic and open sourced programming language"; 91 downloadPage = "https://github.com/odin-lang/Odin"; 92 homepage = "https://odin-lang.org/"; 93 changelog = "https://github.com/odin-lang/Odin/releases/tag/${finalAttrs.version}"; 94 license = lib.licenses.bsd3; 95 mainProgram = "odin"; 96 maintainers = with lib.maintainers; [ 97 astavie 98 diniamo 99 ]; 100 platforms = lib.platforms.unix; 101 broken = stdenv.hostPlatform.isMusl; 102 }; 103})