nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 _experimental-update-script-combinators,
3 fetchFromSourcehut,
4 gitUpdater,
5 lib,
6 qbe,
7 stdenv,
8}:
9let
10 platform = lib.toLower stdenv.hostPlatform.uname.system;
11 arch = stdenv.hostPlatform.uname.processor;
12 qbePlatform =
13 {
14 x86_64 = "amd64_sysv";
15 aarch64 = "arm64";
16 riscv64 = "rv64";
17 }
18 .${arch};
19in
20stdenv.mkDerivation (finalAttrs: {
21 pname = "harec";
22 version = "0.24.2";
23
24 src = fetchFromSourcehut {
25 owner = "~sircmpwn";
26 repo = "harec";
27 rev = finalAttrs.version;
28 hash = "sha256-YCUBdPYr/44stW9k54QoUEhNkti6ULJkVBphx7xhmKo=";
29 };
30
31 nativeBuildInputs = [ qbe ];
32
33 buildInputs = [ qbe ];
34
35 makeFlags = [
36 "PREFIX=${placeholder "out"}"
37 "ARCH=${arch}"
38 "VERSION=${finalAttrs.version}-nixpkgs"
39 "QBEFLAGS=-t${qbePlatform}"
40 "CC=${stdenv.cc.targetPrefix}cc"
41 "AS=${stdenv.cc.targetPrefix}as"
42 "LD=${stdenv.cc.targetPrefix}ld"
43 ];
44
45 strictDeps = true;
46
47 enableParallelBuilding = true;
48
49 doCheck = true;
50
51 postConfigure = ''
52 ln -s configs/${platform}.mk config.mk
53 '';
54
55 passthru = {
56 updateScript = _experimental-update-script-combinators.sequence (
57 map (item: item.command) [
58 (gitUpdater {
59 attrPath = "harec";
60 ignoredVersions = [ "-rc[0-9]{1,}" ];
61 })
62 (gitUpdater {
63 attrPath = "hare";
64 url = "https://git.sr.ht/~sircmpwn/hare";
65 ignoredVersions = [ "-rc[0-9]{1,}" ];
66 })
67 ]
68 );
69 # To be kept in sync with the hare package.
70 inherit qbe;
71 };
72
73 meta = {
74 homepage = "https://harelang.org/";
75 description = "Bootstrapping Hare compiler written in C for POSIX systems";
76 license = lib.licenses.gpl3Only;
77 maintainers = [ ];
78 mainProgram = "harec";
79 # The upstream developers do not like proprietary operating systems; see
80 # https://harelang.org/platforms/
81 # UPDATE: https://github.com/hshq/harelang provides a MacOS port
82 platforms =
83 with lib.platforms;
84 lib.intersectLists (freebsd ++ openbsd ++ linux) (aarch64 ++ x86_64 ++ riscv64);
85 badPlatforms = lib.platforms.darwin;
86 };
87})