1
Fork 0
hare-nix/pkgs/hare.nix

87 lines
1.7 KiB
Nix

{
stdenv,
lib,
makeWrapper,
scdoc,
qbe,
harec,
tzdata,
python3,
substituteAll,
hare-as,
hare-cc,
hare-ld,
}:
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/badboy/harelang";
ref = "master";
rev = "f01ba5ce72cf1ff43acdc932492a656b76c5cb1d";
};
doCheck = true;
patches = [
(substituteAll {
src = ./001-tzdata.patch;
inherit tzdata;
})
];
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=${hare-cc}/bin/hare-cc"
"AS=${hare-as}/bin/hare-as"
"LD=${hare-ld}/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 ${hare-cc}/bin/hare-cc \
--set AS ${hare-as}/bin/hare-as \
--set LD ${hare-ld}/bin/hare-ld
wrapProgram $out/bin/haredoc \
--prefix PATH : ${lib.makeBinPath [scdoc]}
'';
setupHook = ./setup-hook.sh;
})