79 lines
1.5 KiB
Nix
79 lines
1.5 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
makeWrapper,
|
|
scdoc,
|
|
qbe,
|
|
harec,
|
|
tzdata,
|
|
python3,
|
|
hareAs,
|
|
hareCc,
|
|
hareLd,
|
|
}:
|
|
let
|
|
arch = stdenv.hostPlatform.uname.processor;
|
|
qbePlatform = {
|
|
x86_64 = "amd64_apple";
|
|
aarch64 = "arm64_apple";
|
|
}.${arch};
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "hare";
|
|
version = "0.24";
|
|
src = builtins.fetchGit {
|
|
url = "https://github.com/hshq/harelang";
|
|
ref = "master";
|
|
rev = "30d097a7c7f3ccf9e4fc783d1cdae1fd506673c7";
|
|
};
|
|
doCheck = true;
|
|
|
|
nativeBuildInputs = [
|
|
harec
|
|
makeWrapper
|
|
qbe
|
|
scdoc
|
|
python3
|
|
];
|
|
|
|
buildInputs = [
|
|
harec
|
|
qbe
|
|
tzdata
|
|
];
|
|
|
|
makeFlags = [
|
|
"HARECACHE=.harecache"
|
|
"PREFIX=${builtins.placeholder "out"}"
|
|
"ARCH=${arch}"
|
|
"VERSION=${finalAttrs.version}-nixpkgs"
|
|
"QBEFLAGS=-t${qbePlatform}"
|
|
"CC=${hareCc}/bin/hare-cc"
|
|
"AS=${hareAs}/bin/hare-as"
|
|
"LD=${hareLd}/bin/hare-ld"
|
|
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
|
|
# not follow the FHS.
|
|
"HAREPATH=$(SRCDIR)/hare/stdlib"
|
|
];
|
|
|
|
postConfigure = ''
|
|
ln -s configs/darwin.mk config.mk
|
|
sed -i 's/ @#/ /' Makefile
|
|
sed -i 's/ @/ /' Makefile
|
|
sed -i 's/ @/ /' makefiles/darwin.aarch64.mk
|
|
'';
|
|
|
|
postFixup = ''
|
|
wrapProgram $out/bin/hare \
|
|
--prefix PATH : ${lib.makeBinPath [harec qbe]} \
|
|
--set CC ${hareCc}/bin/hare-cc \
|
|
--set AS ${hareAs}/bin/hare-as \
|
|
--set LD ${hareLd}/bin/hare-ld
|
|
|
|
wrapProgram $out/bin/haredoc \
|
|
--prefix PATH : ${lib.makeBinPath [scdoc]}
|
|
'';
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
})
|