2021-07-14 22:03:04 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2024-06-20 14:57:18 +00:00
|
|
|
, llvmPackages
|
2023-07-15 17:15:38 +00:00
|
|
|
, makeBinaryWrapper
|
2021-07-14 22:03:04 +00:00
|
|
|
, libiconv
|
2023-07-15 17:15:38 +00:00
|
|
|
, MacOSX-SDK
|
2024-06-05 15:53:02 +00:00
|
|
|
, Security
|
2023-07-15 17:15:38 +00:00
|
|
|
, which
|
2021-07-14 22:03:04 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (llvmPackages) stdenv;
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "odin";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "dev-2024-06";
|
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-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-Ba+244L855y+XzLcaf1fgQhHVDv2Q77GPapRAYmCQfg=";
|
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
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
Security
|
|
|
|
];
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config";
|
|
|
|
|
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
2024-05-15 15:35:15 +00:00
|
|
|
substituteInPlace src/linker.cpp \
|
|
|
|
--replace-fail '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' ${MacOSX-SDK}
|
|
|
|
'' + ''
|
|
|
|
substituteInPlace build_odin.sh \
|
|
|
|
--replace-fail '-framework System' '-lSystem'
|
2023-07-15 17:15:38 +00:00
|
|
|
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
|
2024-02-29 20:09:43 +00:00
|
|
|
cp -r base $out/share/base
|
2023-07-15 17:15:38 +00:00
|
|
|
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; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Fast, concise, readable, pragmatic and open sourced programming language";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "odin";
|
2021-07-14 22:03:04 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|