push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
diff --git a/time/chrono/+freebsd.ha b/time/chrono/+freebsd.ha
index af49080e..3dde7963 100644
--- a/time/chrono/+freebsd.ha
+++ b/time/chrono/+freebsd.ha
@@ -2,8 +2,8 @@
// (c) Hare authors <https://harelang.org>
def LOCALTIME_PATH: str = "/etc/localtime";
-def TZDB_PATH: str = "/usr/share/zoneinfo/";
+def TZDB_PATH: str = "@tzdata@/share/zoneinfo/";
// The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
// leap second data.
-export def UTC_LEAPSECS_PATH: str = "/var/db/ntpd.leap-seconds.list";
+export def UTC_LEAPSECS_PATH: str = "@tzdata@/share/zoneinfo/leap-seconds.list";
diff --git a/time/chrono/+linux.ha b/time/chrono/+linux.ha
index 2756fd6f..1ea22385 100644
--- a/time/chrono/+linux.ha
+++ b/time/chrono/+linux.ha
@@ -2,8 +2,8 @@
// (c) Hare authors <https://harelang.org>
def LOCALTIME_PATH: str = "/etc/localtime";
-def TZDB_PATH: str = "/usr/share/zoneinfo/";
+def TZDB_PATH: str = "@tzdata@/share/zoneinfo/";
// The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
// leap second data.
-export def UTC_LEAPSECS_PATH: str = "/usr/share/zoneinfo/leap-seconds.list";
+export def UTC_LEAPSECS_PATH: str = "@tzdata@/share/zoneinfo/leap-seconds.list";
diff --git a/time/chrono/+openbsd.ha b/time/chrono/+openbsd.ha
index 2756fd6f..1ea22385 100644
--- a/time/chrono/+openbsd.ha
+++ b/time/chrono/+openbsd.ha
@@ -2,8 +2,8 @@
// (c) Hare authors <https://harelang.org>
def LOCALTIME_PATH: str = "/etc/localtime";
-def TZDB_PATH: str = "/usr/share/zoneinfo/";
+def TZDB_PATH: str = "@tzdata@/share/zoneinfo/";
// The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
// leap second data.
-export def UTC_LEAPSECS_PATH: str = "/usr/share/zoneinfo/leap-seconds.list";
+export def UTC_LEAPSECS_PATH: str = "@tzdata@/share/zoneinfo/leap-seconds.list";

View File

@@ -0,0 +1,43 @@
diff --git a/Makefile b/Makefile
index 2482be1f..9d58bc81 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ all:
include config.mk
include makefiles/$(PLATFORM).$(ARCH).mk
-all: $(BINOUT)/hare $(BINOUT)/haredoc docs
+all: $(BINOUT)/hare docs
HARE_DEFINES = \
-D PLATFORM:str='"$(PLATFORM)"' \
@@ -79,11 +79,10 @@ docs: \
docs/haredoc.1 \
docs/hare-run.1 \
docs/hare-test.1 \
- docs/haredoc.5 \
docs/hare-module.5
-MAN1 = hare hare-build hare-cache hare-deps haredoc hare-run hare-test
-MAN5 = haredoc hare-module
+MAN1 = hare hare-build hare-cache hare-deps hare-run hare-test
+MAN5 = hare-module
bootstrap:
@BINOUT=$(BINOUT) ./scripts/genbootstrap
@@ -104,7 +103,6 @@ install-cmd:
'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1' \
'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man5'
install -m755 '$(BINOUT)/hare' '$(DESTDIR)$(BINDIR)/hare'
- install -m755 '$(BINOUT)/haredoc' '$(DESTDIR)$(BINDIR)/haredoc'
for i in $(MAN1); do install -m644 docs/$$i.1 '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
for i in $(MAN5); do install -m644 docs/$$i.5 '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
@@ -115,7 +113,6 @@ install-mods:
uninstall:
rm -- '$(DESTDIR)$(BINDIR)/hare'
- rm -- '$(DESTDIR)$(BINDIR)/haredoc'
for i in $(MAN1); do rm -- '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
for i in $(MAN5); do rm -- '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
rm -r -- '$(DESTDIR)$(STDLIB)'

View File

@@ -0,0 +1,24 @@
diff --git a/cmd/hare/build.ha b/cmd/hare/build.ha
index ce19af9e..8631b325 100644
--- a/cmd/hare/build.ha
+++ b/cmd/hare/build.ha
@@ -36,7 +36,7 @@ fn build(name: str, cmd: *getopt::command) (void | error) = {
case let ncpu: size =>
yield ncpu;
},
- version = build::get_version(os::tryenv("HAREC", "harec"))?,
+ version = build::get_version(os::tryenv("HAREC", "@harec_bin@"))?,
arch = arch,
platform = build::get_platform(os::sysname())?,
...
@@ -143,8 +143,8 @@ fn build(name: str, cmd: *getopt::command) (void | error) = {
set_arch_tags(&ctx.ctx.tags, arch);
ctx.cmds = ["",
- os::tryenv("HAREC", "harec"),
- os::tryenv("QBE", "qbe"),
+ os::tryenv("HAREC", "@harec_bin@"),
+ os::tryenv("QBE", "@qbe_bin@"),
os::tryenv("AS", arch.as_cmd),
os::tryenv("LD", arch.ld_cmd),
];

View File

@@ -0,0 +1,30 @@
diff --git a/mime/+freebsd.ha b/mime/+freebsd.ha
index e536d9bd..022f18c4 100644
--- a/mime/+freebsd.ha
+++ b/mime/+freebsd.ha
@@ -2,4 +2,4 @@
// (c) Hare authors <https://harelang.org>
// Path to the system MIME database.
-export def SYSTEM_DB: str = "/etc/mime.types";
+export def SYSTEM_DB: str = "@mailcap@/etc/mime.types";
diff --git a/mime/+linux.ha b/mime/+linux.ha
index e536d9bd..022f18c4 100644
--- a/mime/+linux.ha
+++ b/mime/+linux.ha
@@ -2,4 +2,4 @@
// (c) Hare authors <https://harelang.org>
// Path to the system MIME database.
-export def SYSTEM_DB: str = "/etc/mime.types";
+export def SYSTEM_DB: str = "@mailcap@/etc/mime.types";
diff --git a/mime/+openbsd.ha b/mime/+openbsd.ha
index 611b2dce..022f18c4 100644
--- a/mime/+openbsd.ha
+++ b/mime/+openbsd.ha
@@ -2,4 +2,4 @@
// (c) Hare authors <https://harelang.org>
// Path to the system MIME database.
-export def SYSTEM_DB: str = "/usr/share/misc/mime.types";
+export def SYSTEM_DB: str = "@mailcap@/etc/mime.types";

View File

@@ -0,0 +1,38 @@
{
lib,
file,
hare,
runCommandNoCC,
writeText,
}:
let
archs = lib.concatStringsSep " " (
map (lib.removeSuffix "-linux") (builtins.filter (lib.hasSuffix "-linux") hare.meta.platforms)
);
mainDotHare = writeText "main.ha" ''
export fn main() void = void;
'';
in
runCommandNoCC "${hare.pname}-cross-compilation-test"
{
nativeBuildInputs = [
hare
file
];
}
''
HARECACHE="$(mktemp -d)"
export HARECACHE
readonly binprefix="bin"
for a in ${archs}; do
outbin="$binprefix-$a"
set -x
hare build -o "$outbin" -q -R -a "$a" ${mainDotHare}
set +x
printf -- 'Built "%s" target\n' "$a"
done
file -- "$binprefix-"*
: 1>$out
''

View File

@@ -0,0 +1,56 @@
{
hare,
lib,
makeSetupHook,
makeWrapper,
runCommand,
stdenv,
writeShellApplication,
}:
let
arch = stdenv.targetPlatform.uname.processor;
harePropagationInputs = builtins.attrValues { inherit (hare) harec qbe; };
hareWrappedScript = writeShellApplication {
# `name` MUST be `hare`, since its role is to replace the hare binary.
name = "hare";
runtimeInputs = [ hare ];
excludeShellChecks = [ "SC2086" ];
# ''${cmd:+"$cmd"} is used on the default case to keep the same behavior as
# the hare binary: If "$cmd" is passed directly and it's empty, the hare
# binary will treat it as an unrecognized command.
text = ''
readonly cmd="$1"
shift
case "$cmd" in
"test"|"run"|"build") exec hare "$cmd" $NIX_HAREFLAGS "$@" ;;
*) exec hare ''${cmd:+"$cmd"} "$@"
esac
'';
};
hareWrapper = runCommand "hare-wrapper" { nativeBuildInputs = [ makeWrapper ]; } ''
mkdir -p $out/bin
install ${lib.getExe hareWrappedScript} $out/bin/hare
makeWrapper ${lib.getExe hare} $out/bin/hare-native \
--inherit-argv0 \
--unset AR \
--unset LD \
--unset CC
'';
in
makeSetupHook {
name = "hare-hook";
# The propagation of `qbe` and `harec` (harePropagationInputs) is needed for
# build frameworks like `haredo`, which set the HAREC and QBE env vars to
# `harec` and `qbe` respectively. We use the derivations from the `hare`
# package to assure that there's no different behavior between the `hareHook`
# and `hare` packages.
propagatedBuildInputs = [ hareWrapper ] ++ harePropagationInputs;
substitutions = {
hare_unconditional_flags = "-q -a${arch}";
hare_stdlib = "${hare}/src/hare/stdlib";
};
meta = {
description = "Setup hook for the Hare compiler";
inherit (hare.meta) badPlatforms platforms;
};
} ./setup-hook.sh

View File

@@ -0,0 +1,28 @@
{
hare,
runCommandNoCC,
writeText,
}:
let
mainDotHare = writeText "main.ha" ''
use fmt;
use mime;
export fn main() void = {
const ext = "json";
match(mime::lookup_ext(ext)) {
case let mime: const *mime::mimetype =>
fmt::printfln("Found mimetype for extension `{}`: {}", ext, mime.mime)!;
case null =>
fmt::fatalf("Could not find mimetype for `{}`", ext);
};
};
'';
in
runCommandNoCC "mime-module-test" { nativeBuildInputs = [ hare ]; } ''
HARECACHE="$(mktemp -d)"
export HARECACHE
readonly binout="test-bin"
hare build -qRo "$binout" ${mainDotHare}
./$binout
: 1>$out
''

View File

@@ -0,0 +1,177 @@
{
lib,
stdenv,
fetchFromSourcehut,
harec,
scdoc,
tzdata,
mailcap,
replaceVars,
callPackage,
enableCrossCompilation ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.is64bit),
pkgsCross,
x86_64PkgsCrossToolchain ? pkgsCross.gnu64,
aarch64PkgsCrossToolchain ? pkgsCross.aarch64-multiplatform,
riscv64PkgsCrossToolchain ? pkgsCross.riscv64,
}:
# There's no support for `aarch64` or `riscv64` for freebsd nor for openbsd on nix.
# See `lib.systems.doubles.aarch64` and `lib.systems.doubles.riscv64`.
assert
let
inherit (stdenv.hostPlatform) isLinux is64bit;
inherit (lib) intersectLists platforms concatStringsSep;
workingPlatforms = intersectLists platforms.linux (with platforms; x86_64 ++ aarch64 ++ riscv64);
in
lib.assertMsg (enableCrossCompilation -> isLinux && is64bit) ''
The cross-compilation toolchains may only be enabled on the following platforms:
${concatStringsSep "\n" workingPlatforms}
'';
let
inherit (harec) qbe;
buildArch = stdenv.buildPlatform.uname.processor;
arch = stdenv.hostPlatform.uname.processor;
platform = lib.toLower stdenv.hostPlatform.uname.system;
qbePlatform =
{
x86_64 = "amd64_sysv";
aarch64 = "arm64";
riscv64 = "rv64";
}
.${arch};
embeddedOnBinaryTools =
let
genPaths =
toolchain:
let
inherit (toolchain.stdenv.cc) targetPrefix;
inherit (toolchain.stdenv.targetPlatform.uname) processor;
in
{
"${processor}" = {
"ld" = lib.getExe' toolchain.buildPackages.binutils "${targetPrefix}ld";
"as" = lib.getExe' toolchain.buildPackages.binutils "${targetPrefix}as";
"cc" = lib.getExe' toolchain.stdenv.cc "${targetPrefix}cc";
};
};
in
builtins.foldl' (acc: elem: acc // (genPaths elem)) { } [
x86_64PkgsCrossToolchain
aarch64PkgsCrossToolchain
riscv64PkgsCrossToolchain
];
crossCompMakeFlags = builtins.filter (x: !(lib.hasPrefix (lib.toUpper buildArch) x)) [
"RISCV64_AS=${embeddedOnBinaryTools.riscv64.as}"
"RISCV64_CC=${embeddedOnBinaryTools.riscv64.cc}"
"RISCV64_LD=${embeddedOnBinaryTools.riscv64.ld}"
"AARCH64_AS=${embeddedOnBinaryTools.aarch64.as}"
"AARCH64_CC=${embeddedOnBinaryTools.aarch64.cc}"
"AARCH64_LD=${embeddedOnBinaryTools.aarch64.ld}"
"X86_64_AS=${embeddedOnBinaryTools.x86_64.as}"
"X86_64_CC=${embeddedOnBinaryTools.x86_64.cc}"
"X86_64_LD=${embeddedOnBinaryTools.x86_64.ld}"
];
in
stdenv.mkDerivation (finalAttrs: {
pname = "hare";
version = "0.24.2";
outputs = [
"out"
"man"
];
src = fetchFromSourcehut {
owner = "~sircmpwn";
repo = "hare";
rev = finalAttrs.version;
hash = "sha256-61lckI0F+Ez5LR/8g6ftS0W7Q/+EU/1flTDFleBg6pc=";
};
patches = [
# Replace FHS paths with nix store
(replaceVars ./001-tzdata.patch {
inherit tzdata;
})
# Don't build haredoc since it uses the build `hare` bin, which breaks
# cross-compilation.
./002-dont-build-haredoc.patch
# Hardcode harec and qbe.
(replaceVars ./003-hardcode-qbe-and-harec.patch {
harec_bin = lib.getExe harec;
qbe_bin = lib.getExe qbe;
})
# Use mailcap `/etc/mime.types` for Hare's mime module
(replaceVars ./004-use-mailcap-for-mimetypes.patch {
inherit mailcap;
})
];
nativeBuildInputs = [
harec
qbe
scdoc
];
buildInputs = [
harec
qbe
];
makeFlags = [
"HARECACHE=.harecache"
"PREFIX=${placeholder "out"}"
"ARCH=${arch}"
"VERSION=${finalAttrs.version}-nixpkgs"
"QBEFLAGS=-t${qbePlatform}"
"AS=${stdenv.cc.targetPrefix}as"
"LD=${stdenv.cc.targetPrefix}ld"
"${lib.toUpper buildArch}_AS=${embeddedOnBinaryTools.${buildArch}.as}"
"${lib.toUpper buildArch}_CC=${embeddedOnBinaryTools.${buildArch}.cc}"
"${lib.toUpper buildArch}_LD=${embeddedOnBinaryTools.${buildArch}.ld}"
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
# not follow the FHS.
"HAREPATH=$(SRCDIR)/hare/stdlib"
]
++ lib.optionals enableCrossCompilation crossCompMakeFlags;
enableParallelBuilding = true;
# Append the distribution name to the version
env.LOCALVER = "nixpkgs";
strictDeps = true;
doCheck = true;
postConfigure = ''
ln -s configs/${platform}.mk config.mk
'';
passthru = {
tests =
lib.optionalAttrs enableCrossCompilation {
crossCompilation = callPackage ./cross-compilation-tests.nix { hare = finalAttrs.finalPackage; };
}
// lib.optionalAttrs (stdenv.buildPlatform.canExecute stdenv.hostPlatform) {
mimeModule = callPackage ./mime-module-test.nix { hare = finalAttrs.finalPackage; };
}
//
lib.optionalAttrs (enableCrossCompilation && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
{
crossCompilation = callPackage ./cross-compilation-tests.nix { hare = finalAttrs.finalPackage; };
};
# To be propagated by `hareHook`.
inherit harec qbe;
};
meta = {
homepage = "https://harelang.org/";
description = "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;
};
})

View File

@@ -0,0 +1,36 @@
# shellcheck disable=SC2154,SC2034,SC2016
addHarepath() {
local -r thirdparty="${1-}/src/hare/third-party"
if [[ -d "$thirdparty" ]]; then
addToSearchPath HAREPATH "$thirdparty"
fi
}
# Hare's stdlib should come after its third party libs, since the latter may
# expand or shadow the former.
readonly hareSetStdlibPhase='
addToSearchPath HAREPATH "@hare_stdlib@"
'
readonly hareInfoPhase='
echoCmd "HARECACHE" "$HARECACHE"
echoCmd "HAREPATH" "$HAREPATH"
echoCmd "hare" "$(command -v hare)"
echoCmd "hare-native" "$(command -v hare-native)"
'
appendToVar prePhases hareSetStdlibPhase hareInfoPhase
readonly hare_unconditional_flags="@hare_unconditional_flags@"
case "${hareBuildType:-"release"}" in
"release") export NIX_HAREFLAGS="-R $hare_unconditional_flags" ;;
"debug") export NIX_HAREFLAGS="$hare_unconditional_flags" ;;
*)
printf -- 'Invalid hareBuildType: "%s"\n' "${hareBuildType-}"
exit 1
;;
esac
HARECACHE="$(mktemp -d)"
export HARECACHE
addEnvHooks "$hostOffset" addHarepath