2021-07-14 22:03:04 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2023-07-15 17:15:38 +00:00
|
|
|
, llvmPackages_13
|
|
|
|
, makeBinaryWrapper
|
2021-07-14 22:03:04 +00:00
|
|
|
, libiconv
|
2023-07-15 17:15:38 +00:00
|
|
|
, MacOSX-SDK
|
|
|
|
, which
|
2021-07-14 22:03:04 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-07-15 17:15:38 +00:00
|
|
|
llvmPackages = llvmPackages_13;
|
2021-07-14 22:03:04 +00:00
|
|
|
inherit (llvmPackages) stdenv;
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "odin";
|
2024-02-07 01:22:34 +00:00
|
|
|
version = "dev-2024-02";
|
2021-07-14 22:03:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "odin-lang";
|
|
|
|
repo = "Odin";
|
2023-07-15 17:15:38 +00:00
|
|
|
rev = version;
|
2024-02-07 01:22:34 +00:00
|
|
|
hash = "sha256-v9A0+kgREXALhnvFYWtE0+H4L7CYnyje+d2W5+/ZvHA=";
|
2021-07-14 22:03:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2023-07-15 17:15:38 +00:00
|
|
|
makeBinaryWrapper which
|
2021-07-14 22:03:04 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = lib.optional stdenv.isDarwin libiconv;
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
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
|
2021-07-14 22:03:04 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"release"
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
cp odin $out/bin/odin
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
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
|
2021-07-14 22:03:04 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A fast, concise, readable, pragmatic and open sourced programming language";
|
|
|
|
homepage = "https://odin-lang.org/";
|
2023-07-15 17:15:38 +00:00
|
|
|
license = licenses.bsd3;
|
2023-11-16 04:20:00 +00:00
|
|
|
maintainers = with maintainers; [ luc65r astavie znaniye ];
|
2023-07-15 17:15:38 +00:00
|
|
|
platforms = platforms.x86_64 ++ [ "aarch64-darwin" ];
|
2021-07-14 22:03:04 +00:00
|
|
|
};
|
|
|
|
}
|