Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 97 additions & 4 deletions pkgs/development/compilers/hare/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,100 @@
{ config, lib, pkgs }:
{ lib
, stdenv
, fetchFromSourcehut
, binutils-unwrapped
, harec
, makeWrapper
, qbe
, scdoc
}:

lib.makeScope pkgs.newScope (self: {
let
# We use harec's override of qbe until 1.2 is released, but the `qbe` argument
# is kept to avoid breakage.
qbe = harec.qbeUnstable;
in
stdenv.mkDerivation (finalAttrs: {
pname = "hare";
version = "unstable-2023-10-23";

harec = pkgs.callPackage ./harec { };
hare = pkgs.callPackage ./hare { };
src = fetchFromSourcehut {
owner = "~sircmpwn";
repo = "hare";
rev = "1048620a7a25134db370bf24736efff1ffcb2483";
hash = "sha256-slQPIhrcM+KAVAvjuRnqNdEAEr4Xa4iQNVEpI7Wl+Ks=";
};

nativeBuildInputs = [
binutils-unwrapped
harec
makeWrapper
qbe
scdoc
];

buildInputs = [
binutils-unwrapped
harec
qbe
];

# Append the distribution name to the version
env.LOCALVER = "nix";

configurePhase =
let
# https://harelang.org/platforms/
arch =
if stdenv.isx86_64 then "x86_64"
else if stdenv.isAarch64 then "aarch64"
else if stdenv.hostPlatform.isRiscV && stdenv.is64bit then "riscv64"
else "unsupported";
platform =
if stdenv.isLinux then "linux"
else if stdenv.isFreeBSD then "freebsd"
else "unsupported";
in
''
runHook preConfigure

cp config.example.mk config.mk
makeFlagsArray+=(
PREFIX="${builtins.placeholder "out"}"
HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)"
BINOUT="$(mktemp -d --tmpdir bin.XXXXXXXX)"
PLATFORM="${platform}"
ARCH="${arch}"
)

runHook postConfigure
'';

doCheck = true;

postFixup =
let
binPath = lib.makeBinPath [
binutils-unwrapped
harec
qbe
];
in
''
wrapProgram $out/bin/hare --prefix PATH : ${binPath}
'';

setupHook = ./setup-hook.sh;

strictDeps = true;
enableParallelBuilding = true;

meta = {
homepage = "https://harelang.org/";
description =
"A systems programming language designed to be simple, stable, and robust";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ onemoresuza ];
mainProgram = "hare";
inherit (harec.meta) platforms badPlatforms;
};
})
44 changes: 0 additions & 44 deletions pkgs/development/compilers/hare/hare/config-template.mk

This file was deleted.

98 changes: 0 additions & 98 deletions pkgs/development/compilers/hare/hare/default.nix

This file was deleted.

45 changes: 0 additions & 45 deletions pkgs/development/compilers/hare/harec/default.nix

This file was deleted.

63 changes: 63 additions & 0 deletions pkgs/development/compilers/harec/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{ lib
, stdenv
, fetchFromSourcehut
, qbe
, fetchgit
}:
let
# harec needs the dbgfile and dbgloc features implemented up to this commit.
# This can be dropped once 1.2 is released, for a possible release date see:
# https://lists.sr.ht/~mpu/qbe/%3CZPkmHE9KLohoEohE%40cloudsdale.the-delta.net.eu.org%3E
qbe' = qbe.overrideAttrs (_old: {
version = "1.1-unstable-2023-08-18";
src = fetchgit {
url = "git://c9x.me/qbe.git";
rev = "36946a5142c40b733d25ea5ca469f7949ee03439";
hash = "sha256-bqxWFP3/aw7kRoD6ictbFcjzijktHvh4AgWAXBIODW8=";
};
});
in
stdenv.mkDerivation (finalAttrs: {
pname = "harec";
version = "unstable-2023-10-22";

src = fetchFromSourcehut {
owner = "~sircmpwn";
repo = "harec";
rev = "64dea196ce040fbf3417e1b4fb11331688672aca";
hash = "sha256-2Aeb+OZ/hYUyyxx6aTw+Oxiac+p+SClxtg0h68ZBSHc=";
};

nativeBuildInputs = [
qbe'
];

buildInputs = [
qbe'
];

strictDeps = true;
enableParallelBuilding = true;

doCheck = true;

passthru = {
# We create this attribute so that the `hare` package can access the
# overwritten `qbe`.
qbeUnstable = qbe';
};

meta = {
homepage = "https://harelang.org/";
description = "Bootstrapping Hare compiler written in C for POSIX systems";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ onemoresuza ];
mainProgram = "harec";
# The upstream developers do not like proprietary operating systems; see
# https://harelang.org/platforms/
# UPDATE: https://github.com/hshq/harelang provides a MacOS port
platforms = with lib.platforms;
lib.intersectLists (freebsd ++ linux) (aarch64 ++ x86_64 ++ riscv64);
badPlatforms = lib.platforms.darwin;
};
})
1 change: 0 additions & 1 deletion pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ mapAliases ({

### H ###

inherit (harePackages) hare harec; # Added 2022-08-10
haxe_3_2 = throw "'haxe_3_2' has been removed because it is old and no longer used by any packages in nixpkgs"; # Added 2023-03-15
haxe_3_4 = throw "'haxe_3_4' has been removed because it is old and no longer used by any packages in nixpkgs"; # Added 2023-03-15
hepmc = throw "'hepmc' has been renamed to/replaced by 'hepmc2'"; # Converted to throw 2023-09-10
Expand Down
3 changes: 2 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9129,7 +9129,8 @@ with pkgs;
llvmPackages = llvmPackages_14;
};

harePackages = recurseIntoAttrs (callPackage ../development/compilers/hare { });
harePackages = recurseIntoAttrs (callPackage ./hare-packages.nix { });
inherit (harePackages) hare harec;

ham = pkgs.perlPackages.ham;

Expand Down
10 changes: 10 additions & 0 deletions pkgs/top-level/hare-packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ lib, newScope }:

lib.makeScope newScope (self:
let
inherit (self) callPackage;
in
{
harec = callPackage ../development/compilers/harec { };
hare = callPackage ../development/compilers/hare { };
})