1
Fork 0

add linux pkgs

This commit is contained in:
Jan-Erik Rediger 2024-06-02 00:16:12 +02:00
parent eb444f84b7
commit e28ce4dc9b
5 changed files with 158 additions and 3 deletions

View file

@ -14,11 +14,11 @@
outputs = { nixpkgs, harec-src, hare-src, ... }:
let
supportedSystems = [ "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ];
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
in
{
devShells = forAllSystems (system:
devShells = nixpkgs.lib.genAttrs darwinSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
hare-as = pkgs.callPackage ./pkgs/darwin/hare-as.nix { };
@ -27,6 +27,20 @@
harec = pkgs.callPackage ./pkgs/darwin/harec.nix { inherit harec-src hare-as hare-cc hare-ld; };
hare = pkgs.callPackage ./pkgs/darwin/hare.nix { inherit hare-src harec hare-as hare-cc hare-ld; };
in
{
default = pkgs.mkShell {
buildInputs = [
harec
hare
];
};
}) //
nixpkgs.lib.genAttrs linuxSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
harec = pkgs.callPackage ./pkgs/linux/harec.nix { };
hare = pkgs.callPackage ./pkgs/linux/hare.nix { inherit harec; };
in
{
default = pkgs.mkShell {
buildInputs = [

View file

@ -0,0 +1,28 @@
diff --git a/time/chrono/+freebsd.ha b/time/chrono/+freebsd.ha
index 26d78ab1..6861bfe8 100644
--- a/time/chrono/+freebsd.ha
+++ b/time/chrono/+freebsd.ha
@@ -2,7 +2,7 @@
// (c) Hare authors <https://harelang.org>
def LOCALTIME_PATH: str = "/etc/localtime";
-def ZONEINFO_PREFIX: str = "/usr/share/zoneinfo/";
+def ZONEINFO_PREFIX: str = "@tzdata@/share/zoneinfo/";
// The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
// leap second data.
diff --git a/time/chrono/+linux.ha b/time/chrono/+linux.ha
index 600f606c..8d5617e2 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_FILE: str = "/usr/share/zoneinfo/leap-seconds.list";
+export def UTC_LEAPSECS_PATH: str = "@tzdata@/share/zoneinfo/leap-seconds.list";

70
pkgs/linux/hare.nix Normal file
View file

@ -0,0 +1,70 @@
{
stdenv,
lib,
makeWrapper,
scdoc,
substituteAll,
qbe,
harec,
binutils-unwrapped,
tzdata
}:
let
arch = stdenv.hostPlatform.uname.processor;
qbePlatform = {
x86_64 = "amd64_sysv";
aarch64 = "arm64";
riscv64 = "rv64";
}.${arch};
in
stdenv.mkDerivation (finalAttrs: {
pname = "hare";
version = "0.24";
src = builtins.fetchGit {
url = "https://git.sr.ht/~sircmpwn/hare";
ref = "master";
rev = "0cd51184a7acdfd4ef20195d1648622b04477293";
};
patches = [
];
nativeBuildInputs = [
harec
makeWrapper
qbe
scdoc
];
buildInputs = [
binutils-unwrapped
harec
qbe
tzdata
];
makeFlags = [
"HARECACHE=.harecache"
"PREFIX=${builtins.placeholder "out"}"
"ARCH=${arch}"
"VERSION=${finalAttrs.version}-nixpkgs"
"QBEFLAGS=-t${qbePlatform}"
"CC=${stdenv.cc.targetPrefix}cc"
"AS=${stdenv.cc.targetPrefix}as"
"LD=${stdenv.cc.targetPrefix}ld"
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
# not follow the FHS.
"HAREPATH=$(SRCDIR)/hare/stdlib"
];
postConfigure = ''
ln -s configs/linux.mk config.mk
'';
postFixup = ''
wrapProgram $out/bin/hare \
--prefix PATH : ${lib.makeBinPath [binutils-unwrapped harec qbe]}
'';
setupHook = ./setup-hook.sh;
})

34
pkgs/linux/harec.nix Normal file
View file

@ -0,0 +1,34 @@
{ lib, stdenv, qbe }:
let
arch = stdenv.hostPlatform.uname.processor;
qbePlatform = {
x86_64 = "amd64_sysv";
aarch64 = "arm64";
riscv64 = "rv64";
}.${arch};
in
stdenv.mkDerivation (finalAttrs: {
pname = "harec";
version = "0.24";
src = builtins.fetchGit {
url = "https://git.sr.ht/~sircmpwn/harec";
ref = "master";
rev = "3be960cf19ecf9528b8b3aaafc135229291e01b1";
};
buildInputs = [ qbe ];
nativeBuildInputs = [ qbe ];
makeFlags = [
"PREFIX=${builtins.placeholder "out"}"
"ARCH=${arch}"
"VERSION=${finalAttrs.version}-nixpkgs"
"QBEFLAGS=-t${qbePlatform}"
"CC=${stdenv.cc.targetPrefix}cc"
"AS=${stdenv.cc.targetPrefix}as"
"LD=${stdenv.cc.targetPrefix}ld"
];
postConfigure = ''
ln -s configs/linux.mk config.mk
'';
})

9
pkgs/linux/setup-hook.sh Normal file
View file

@ -0,0 +1,9 @@
addHarepath () {
for haredir in third-party stdlib; do
if [[ -d "$1/src/hare/$haredir" ]]; then
addToSearchPath HAREPATH "$1/src/hare/$haredir"
fi
done
}
addEnvHooks "$hostOffset" addHarepath