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

87 lines
1.7 KiB
Nix
Raw Normal View History

2024-05-14 19:06:04 +00:00
{
2024-05-14 19:02:43 +00:00
stdenv,
lib,
makeWrapper,
scdoc,
qbe,
harec,
2024-05-14 19:06:04 +00:00
tzdata,
python3,
2024-05-16 20:47:23 +00:00
substituteAll,
2024-05-16 20:47:23 +00:00
hare-as,
hare-cc,
hare-ld,
2024-05-14 19:02:43 +00:00
}:
let
arch = stdenv.hostPlatform.uname.processor;
qbePlatform = {
2024-05-14 19:06:04 +00:00
x86_64 = "amd64_apple";
aarch64 = "arm64_apple";
2024-05-14 19:02:43 +00:00
}.${arch};
in
stdenv.mkDerivation (finalAttrs: {
pname = "hare";
version = "0.24";
src = builtins.fetchGit {
2024-05-15 11:19:42 +00:00
url = "https://github.com/badboy/harelang";
2024-05-14 19:02:43 +00:00
ref = "master";
2024-05-15 11:19:42 +00:00
rev = "f01ba5ce72cf1ff43acdc932492a656b76c5cb1d";
2024-05-14 19:02:43 +00:00
};
doCheck = true;
2024-05-14 19:02:43 +00:00
2024-05-16 20:47:23 +00:00
patches = [
(substituteAll {
src = ./001-tzdata.patch;
inherit tzdata;
})
];
2024-05-14 19:02:43 +00:00
nativeBuildInputs = [
harec
makeWrapper
qbe
scdoc
2024-05-14 19:06:04 +00:00
python3
2024-05-14 19:02:43 +00:00
];
buildInputs = [
harec
qbe
tzdata
];
makeFlags = [
"HARECACHE=.harecache"
"PREFIX=${builtins.placeholder "out"}"
"ARCH=${arch}"
"VERSION=${finalAttrs.version}-nixpkgs"
"QBEFLAGS=-t${qbePlatform}"
2024-05-16 20:47:23 +00:00
"CC=${hare-cc}/bin/hare-cc"
"AS=${hare-as}/bin/hare-as"
"LD=${hare-ld}/bin/hare-ld"
2024-05-14 19:02:43 +00:00
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
# not follow the FHS.
"HAREPATH=$(SRCDIR)/hare/stdlib"
];
postConfigure = ''
2024-05-14 19:06:04 +00:00
ln -s configs/darwin.mk config.mk
sed -i 's/ @#/ /' Makefile
sed -i 's/ @/ /' Makefile
sed -i 's/ @/ /' makefiles/darwin.aarch64.mk
2024-05-14 19:02:43 +00:00
'';
postFixup = ''
wrapProgram $out/bin/hare \
2024-05-14 19:06:04 +00:00
--prefix PATH : ${lib.makeBinPath [harec qbe]} \
2024-05-16 20:47:23 +00:00
--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]}
2024-05-14 19:02:43 +00:00
'';
setupHook = ./setup-hook.sh;
})