Merge pull request #170359 from AndersonTorres/new-harelang

Hare programming language: init
This commit is contained in:
Anderson Torres 2022-05-04 00:23:35 -03:00 committed by GitHub
commit abfd311791
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 166 additions and 0 deletions

View file

@ -0,0 +1,27 @@
## Template to generate config.mk via substitute-all
# set PREFIX externally
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
SRCDIR = $(PREFIX)/src
STDLIB = $(SRCDIR)/hare/stdlib
HAREPATH = $(SRCDIR)/hare/stdlib:$(SRCDIR)/hare/third-party
## Build configuration
# Platform to build for
PLATFORM = @platform@
ARCH = @arch@
# External tools and flags
HAREC = harec
HAREFLAGS = @hareflags@
QBE = qbe
AS = as
LD = ld
AR = ar
SCDOC = scdoc
# Where to store build artifacts
# set HARECACHE externally

View file

@ -0,0 +1,91 @@
{ lib
, stdenv
, fetchFromSourcehut
, binutils-unwrapped
, harec
, makeWrapper
, qbe
, scdoc
, substituteAll
}:
stdenv.mkDerivation rec {
pname = "hare";
version = "0.pre+date=2022-04-27";
src = fetchFromSourcehut {
name = pname + "-src";
owner = "~sircmpwn";
repo = pname;
rev = "1bfb2e6dee850c675a8831b41420800d3c62c2a0";
hash = "sha256-1b7U5u3PM3jmnH/OnY9O++GTPyVOdFkJ0fwJBoDZgSU=";
};
nativeBuildInputs = [
binutils-unwrapped
harec
makeWrapper
qbe
scdoc
];
buildInputs = [
binutils-unwrapped
harec
qbe
];
strictDeps = true;
configurePhase =
let
# https://harelang.org/platforms/
arch =
if stdenv.isx86_64 then "x86_64"
else if stdenv.isAarch64 then "aarch64"
else if stdenv.isRiscV64 then "riscv64"
else "unsupported";
platform =
if stdenv.isLinux then "linux"
else if stdenv.isFreeBSD then "freebsd"
else "unsupported";
hareflags = "";
config-file = substituteAll {
src = ./config-template.mk;
inherit arch platform hareflags;
};
in
''
runHook preConfigure
export HARECACHE="$NIX_BUILD_TOP/.harecache"
cat ${config-file} > config.mk
runHook postConfigure
'';
makeFlags = [
"PREFIX=${placeholder "out"}"
];
postInstall =
let
binPath = lib.makeBinPath [
binutils-unwrapped
harec
qbe
];
in
''
wrapProgram $out/bin/hare --prefix PATH : ${binPath}
'';
meta = with lib; {
homepage = "http://harelang.org/";
description =
"A systems programming language designed to be simple, stable, and robust";
license = licenses.gpl3Only;
maintainers = with maintainers; [ AndersonTorres ];
inherit (harec.meta) platforms badPlatforms;
};
}

View file

@ -0,0 +1,45 @@
{ lib
, stdenv
, fetchFromSourcehut
, qbe
}:
stdenv.mkDerivation rec {
pname = "harec";
version = "0.pre+date=2022-04-26";
src = fetchFromSourcehut {
name = pname + "-src";
owner = "~sircmpwn";
repo = pname;
rev = "e5fb5176ba629e98ace5fcb3aa427b2c25d8fdf0";
hash = "sha256-sqt3q6sarzrpyJ/1QYM1WTukrZpflAmAYq6pQwAwe18=";
};
nativeBuildInputs = [
qbe
];
buildInputs = [
qbe
];
# TODO: report upstream
hardeningDisable = [ "fortify" ];
strictDeps = true;
doCheck = true;
meta = with lib; {
homepage = "http://harelang.org/";
description = "Bootstrapping Hare compiler written in C for POSIX systems";
license = licenses.gpl3Only;
maintainers = with maintainers; [ AndersonTorres ];
# The upstream developers do not like proprietary operating systems; see
# https://harelang.org/platforms/
platforms = with platforms;
lib.intersectLists (freebsd ++ linux) (aarch64 ++ x86_64 ++ riscv64);
badPlatforms = with platforms; darwin;
};
}

View file

@ -6830,6 +6830,9 @@ with pkgs;
llvmPackages = llvmPackages_9;
};
harec = callPackage ../development/compilers/hare/harec.nix { };
hare = callPackage ../development/compilers/hare/hare.nix { };
ham = pkgs.perlPackages.ham;
hardinfo = callPackage ../tools/system/hardinfo { };