nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromSourcehut
4, binutils-unwrapped
5, harec
6, makeWrapper
7, qbe
8, scdoc
9, substituteAll
10}:
11
12stdenv.mkDerivation rec {
13 pname = "hare";
14 version = "0.pre+date=2022-04-27";
15
16 src = fetchFromSourcehut {
17 name = pname + "-src";
18 owner = "~sircmpwn";
19 repo = pname;
20 rev = "1bfb2e6dee850c675a8831b41420800d3c62c2a0";
21 hash = "sha256-1b7U5u3PM3jmnH/OnY9O++GTPyVOdFkJ0fwJBoDZgSU=";
22 };
23
24 nativeBuildInputs = [
25 binutils-unwrapped
26 harec
27 makeWrapper
28 qbe
29 scdoc
30 ];
31
32 buildInputs = [
33 binutils-unwrapped
34 harec
35 qbe
36 ];
37
38 strictDeps = true;
39
40 configurePhase =
41 let
42 # https://harelang.org/platforms/
43 arch =
44 if stdenv.isx86_64 then "x86_64"
45 else if stdenv.isAarch64 then "aarch64"
46 else if stdenv.isRiscV64 then "riscv64"
47 else "unsupported";
48 platform =
49 if stdenv.isLinux then "linux"
50 else if stdenv.isFreeBSD then "freebsd"
51 else "unsupported";
52 hareflags = "";
53 config-file = substituteAll {
54 src = ./config-template.mk;
55 inherit arch platform hareflags;
56 };
57 in
58 ''
59 runHook preConfigure
60
61 export HARECACHE="$NIX_BUILD_TOP/.harecache"
62 cat ${config-file} > config.mk
63
64 runHook postConfigure
65 '';
66
67 makeFlags = [
68 "PREFIX=${placeholder "out"}"
69 ];
70
71 doCheck = true;
72
73 postInstall =
74 let
75 binPath = lib.makeBinPath [
76 binutils-unwrapped
77 harec
78 qbe
79 ];
80 in
81 ''
82 wrapProgram $out/bin/hare --prefix PATH : ${binPath}
83 '';
84
85 meta = with lib; {
86 homepage = "http://harelang.org/";
87 description =
88 "A systems programming language designed to be simple, stable, and robust";
89 license = licenses.gpl3Only;
90 maintainers = with maintainers; [ AndersonTorres ];
91 inherit (harec.meta) platforms badPlatforms;
92 };
93}