about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ha
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/by-name/ha')
-rw-r--r--nixpkgs/pkgs/by-name/ha/hare/001-tzdata.patch28
-rw-r--r--nixpkgs/pkgs/by-name/ha/hare/package.nix91
-rw-r--r--nixpkgs/pkgs/by-name/ha/hare/setup-hook.sh9
-rw-r--r--nixpkgs/pkgs/by-name/ha/harec/package.nix63
-rw-r--r--nixpkgs/pkgs/by-name/ha/haredo/package.nix71
-rw-r--r--nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh69
6 files changed, 331 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/ha/hare/001-tzdata.patch b/nixpkgs/pkgs/by-name/ha/hare/001-tzdata.patch
new file mode 100644
index 000000000000..bb510514eb53
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/hare/001-tzdata.patch
@@ -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 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.
+-export def UTC_LEAPSECS_FILE: str = "/usr/share/zoneinfo/leap-seconds.list";
++export def UTC_LEAPSECS_FILE: str = "@tzdata@/share/zoneinfo/leap-seconds.list";
diff --git a/nixpkgs/pkgs/by-name/ha/hare/package.nix b/nixpkgs/pkgs/by-name/ha/hare/package.nix
new file mode 100644
index 000000000000..c509955c6f09
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/hare/package.nix
@@ -0,0 +1,91 @@
+{ lib
+, stdenv
+, fetchFromSourcehut
+, binutils-unwrapped
+, harec
+, makeWrapper
+, qbe
+, scdoc
+, tzdata
+, substituteAll
+}:
+
+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;
+  # https://harelang.org/platforms/
+  arch = stdenv.hostPlatform.uname.processor;
+  platform = lib.strings.toLower stdenv.hostPlatform.uname.system;
+in
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hare";
+  version = "unstable-2023-11-27";
+
+  outputs = [ "out" "man" ];
+
+  src = fetchFromSourcehut {
+    owner = "~sircmpwn";
+    repo = "hare";
+    rev = "d94f355481a320fb2aec13ef62cb3bfe2416f5e4";
+    hash = "sha256-Mpl3VO4xvLCKHeYr/FPuS6jl8CkyeqDz18mQ6Zv05oc=";
+  };
+
+  patches = [
+    # Replace FHS paths with nix store
+    (substituteAll {
+      src = ./001-tzdata.patch;
+      inherit tzdata;
+    })
+  ];
+
+  nativeBuildInputs = [
+    harec
+    makeWrapper
+    qbe
+    scdoc
+  ];
+
+  buildInputs = [
+    binutils-unwrapped
+    harec
+    qbe
+    tzdata
+  ];
+
+  makeFlags = [
+    "HARECACHE=.harecache"
+    "PREFIX=${builtins.placeholder "out"}"
+    "PLATFORM=${platform}"
+    "ARCH=${arch}"
+  ];
+
+  enableParallelBuilding = true;
+
+  # Append the distribution name to the version
+  env.LOCALVER = "nixpkgs";
+
+  strictDeps = true;
+
+  doCheck = true;
+
+  preConfigure = ''
+    ln -s config.example.mk config.mk
+  '';
+
+  postFixup = ''
+    wrapProgram $out/bin/hare \
+      --prefix PATH : ${lib.makeBinPath [binutils-unwrapped harec qbe]}
+  '';
+
+  setupHook = ./setup-hook.sh;
+
+  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;
+  };
+})
diff --git a/nixpkgs/pkgs/by-name/ha/hare/setup-hook.sh b/nixpkgs/pkgs/by-name/ha/hare/setup-hook.sh
new file mode 100644
index 000000000000..d2d2c34354d6
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/hare/setup-hook.sh
@@ -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
diff --git a/nixpkgs/pkgs/by-name/ha/harec/package.nix b/nixpkgs/pkgs/by-name/ha/harec/package.nix
new file mode 100644
index 000000000000..cbcb53b1ac4e
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/harec/package.nix
@@ -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-11-29";
+
+  src = fetchFromSourcehut {
+    owner = "~sircmpwn";
+    repo = "harec";
+    rev = "ec3193e3870436180b0f3df82b769adc57a1c099";
+    hash = "sha256-HXQIgFC4YVDJjo5xbyg1ea3jWYKLEwKkD1KFzWFz9UI= ";
+  };
+
+  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;
+  };
+})
diff --git a/nixpkgs/pkgs/by-name/ha/haredo/package.nix b/nixpkgs/pkgs/by-name/ha/haredo/package.nix
new file mode 100644
index 000000000000..277250170e5d
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/haredo/package.nix
@@ -0,0 +1,71 @@
+{ stdenv
+, lib
+, fetchFromSourcehut
+, hare
+, scdoc
+, nix-update-script
+}:
+stdenv.mkDerivation (finalAttrs: {
+  pname = "haredo";
+  version = "1.0.5";
+
+  outputs = [ "out" "man" ];
+
+  src = fetchFromSourcehut {
+    owner = "~autumnull";
+    repo = "haredo";
+    rev = finalAttrs.version;
+    hash = "sha256-gpui5FVRw3NKyx0AB/4kqdolrl5vkDudPOgjHc/IE4U=";
+  };
+
+  nativeBuildInputs = [
+    hare
+    scdoc
+  ];
+
+  preBuild = ''
+    HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)"
+    export HARECACHE
+    export PREFIX=${builtins.placeholder "out"}
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    ./bootstrap.sh
+
+    runHook postBuild
+  '';
+
+  checkPhase = ''
+    runHook preCheck
+
+    ./bin/haredo test
+
+    runHook postCheck
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    ./bootstrap.sh install
+
+    runHook postInstall
+  '';
+
+  dontConfigure = true;
+  doCheck = true;
+
+  setupHook = ./setup-hook.sh;
+
+  passthru.updateScript = nix-update-script { };
+
+  meta = {
+    description = "A simple and unix-idiomatic build automator";
+    homepage = "https://sr.ht/~autumnull/haredo/";
+    license = lib.licenses.wtfpl;
+    maintainers = with lib.maintainers; [ onemoresuza ];
+    mainProgram = "haredo";
+    inherit (hare.meta) platforms badPlatforms;
+  };
+})
diff --git a/nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh b/nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh
new file mode 100644
index 000000000000..44eb453087db
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh
@@ -0,0 +1,69 @@
+haredoBuildPhase() {
+    runHook preBuild
+
+    local buildTargets jobs
+    read -ra buildTargets <<<"${haredoBuildTargets-}"
+    echoCmd "haredo build targets" "${buildTargets[@]}"
+    if [[ ! -v enableParallelBuilding || -n "${enableParallelBuilding-}" ]]; then
+        jobs="${NIX_BUILD_CORES}"
+    fi
+    haredo ${jobs:+"-j${jobs}"} "${buildTargets[@]}"
+
+    runHook postBuild
+}
+
+haredoCheckPhase() {
+    runHook preCheck
+
+    local checkTargets jobs
+
+    if [[ -n "${haredoCheckTargets:-}" ]]; then
+        read -ra checkTargets <<<"${haredoCheckTargets}"
+    else
+        for dofile in "check.do" "test.do"; do
+            [[ -r "${dofile}" ]] && {
+                checkTargets=("${dofile%".do"}")
+                break
+            }
+        done
+    fi
+
+    if [[ -z "${checkTargets:-}" ]]; then
+        printf -- 'haredoCheckPhase ERROR: no check targets were found' 1>&2
+        exit 1
+    else
+        echoCmd "haredo check targets" "${checkTargets[@]}"
+        if [[ ! -v enableParallelChecking || -n "${enableParallelChecking-}" ]]; then
+            jobs="${NIX_BUILD_CORES}"
+        fi
+        haredo ${jobs:+"-j${jobs}"} "${checkTargets[@]}"
+    fi
+
+    runHook postCheck
+}
+
+haredoInstallPhase() {
+    runHook preInstall
+
+    local installTargets jobs
+    read -ra installTargets <<<"${haredoInstallTargets:-"install"}"
+    echoCmd "haredo install targets" "${installTargets[@]}"
+    if [[ ! -v enableParallelInstalling || -n "${enableParallelInstalling-}" ]]; then
+        jobs="${NIX_BUILD_CORES}"
+    fi
+    haredo ${jobs:+"-j${jobs}"} "${installTargets[@]}"
+
+    runHook postInstall
+}
+
+if [[ -z "${dontUseHaredoBuild-}" && -z "${buildPhase-}" ]]; then
+    buildPhase="haredoBuildPhase"
+fi
+
+if [[ -z "${dontUseHaredoCheck-}" && -z "${checkPhase-}" ]]; then
+    checkPhase="haredoCheckPhase"
+fi
+
+if [[ -z "${dontUseHaredoInstall-}" && -z "${installPhase-}" ]]; then
+    installPhase="haredoInstallPhase"
+fi