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