about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2024-06-06 23:55:33 +0200
committerGitHub <noreply@github.com>2024-06-06 23:55:33 +0200
commit4f06a00fa9f3a42d2fdc3c591e48628dec588c2c (patch)
tree7d7aed2c5541d970222ef6ffb4c820c01b8429c7
parent6384cd9ba614868321b83e73b18978247d2fcd49 (diff)
parentcfa58200cd9958eea5221bf5dfcf82778a0e0220 (diff)
Merge pull request #295155 from onemoresuza/hare-hook
hareHook: init
-rw-r--r--doc/languages-frameworks/hare.section.md53
-rw-r--r--doc/languages-frameworks/index.md1
-rw-r--r--nixos/doc/manual/release-notes/rl-2411.section.md4
-rw-r--r--pkgs/by-name/bo/bonsai/package.nix31
-rw-r--r--pkgs/by-name/ha/hare/hook.nix56
-rw-r--r--pkgs/by-name/ha/hare/package.nix13
-rw-r--r--pkgs/by-name/ha/hare/setup-hook.sh39
-rw-r--r--pkgs/by-name/ha/harec/package.nix36
-rw-r--r--pkgs/by-name/ha/haredo/package.nix19
-rw-r--r--pkgs/by-name/ha/haredoc/package.nix34
-rw-r--r--pkgs/by-name/tr/treecat/package.nix30
-rw-r--r--pkgs/development/hare-third-party/hare-compress/default.nix18
-rw-r--r--pkgs/development/hare-third-party/hare-ev/default.nix22
-rw-r--r--pkgs/development/hare-third-party/hare-json/default.nix18
-rw-r--r--pkgs/development/hare-third-party/hare-png/default.nix20
-rw-r--r--pkgs/development/hare-third-party/hare-ssh/default.nix18
-rw-r--r--pkgs/development/hare-third-party/hare-toml/default.nix22
-rw-r--r--pkgs/tools/security/himitsu/default.nix30
-rw-r--r--pkgs/top-level/all-packages.nix4
19 files changed, 293 insertions, 175 deletions
diff --git a/doc/languages-frameworks/hare.section.md b/doc/languages-frameworks/hare.section.md
new file mode 100644
index 0000000000000..0ae8abeba45c1
--- /dev/null
+++ b/doc/languages-frameworks/hare.section.md
@@ -0,0 +1,53 @@
+# Hare {#sec-language-hare}
+
+## Building Hare programs with `hareHook` {#ssec-language-hare}
+
+The `hareHook` package sets up the environment for building Hare programs by
+doing the following:
+
+1. Setting the `HARECACHE`, `HAREPATH` and `NIX_HAREFLAGS` environment variables;
+1. Propagating `harec`, `qbe` and two wrapper scripts  for the hare binary.
+
+It is not a function as is the case for some other languages --- *e. g.*, Go or
+Rust ---, but a package to be added to `nativeBuildInputs`.
+
+## Attributes of `hareHook` {#hareHook-attributes}
+
+The following attributes are accepted by `hareHook`:
+
+1. `hareBuildType`: Either `release` (default) or `debug`. It controls if the
+   `-R` flag is added to `NIX_HAREFLAGS`.
+
+## Example for `hareHook` {#ex-hareHook}
+
+```nix
+{
+  hareHook,
+  lib,
+  stdenv,
+}: stdenv.mkDerivation {
+  pname = "<name>";
+  version = "<version>";
+  src = "<src>";
+
+  nativeBuildInputs = [ hareHook ];
+
+  meta = {
+    description = "<description>";
+    inherit (hareHook) badPlatforms platforms;
+  };
+}
+```
+
+## Cross Compilation {#hareHook-cross-compilation}
+
+`hareHook` should handle cross compilation out of the box. This is the main
+purpose of `NIX_HAREFLAGS`: In it, the `-a` flag is passed with the architecture
+of the `hostPlatform`.
+
+However, manual intervention may be needed when a binary compiled by the build
+process must be run for the build to complete --- *e. g.*, when using Hare's
+`hare` module for code generation.
+
+In those cases, `hareHook` provides the `hare-native` script, which is a wrapper
+around the hare binary for using the native (`buildPlatform`) toolchain.
diff --git a/doc/languages-frameworks/index.md b/doc/languages-frameworks/index.md
index 920e5e7bd431e..e8fee9c45216c 100644
--- a/doc/languages-frameworks/index.md
+++ b/doc/languages-frameworks/index.md
@@ -19,6 +19,7 @@ dotnet.section.md
 emscripten.section.md
 gnome.section.md
 go.section.md
+hare.section.md
 haskell.section.md
 hy.section.md
 idris.section.md
diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md
index f3135fbd18836..e9ef9c2e6d5c7 100644
--- a/nixos/doc/manual/release-notes/rl-2411.section.md
+++ b/nixos/doc/manual/release-notes/rl-2411.section.md
@@ -58,6 +58,10 @@
 
 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
 
+- `hareHook` has been added as the language framework for Hare. From now on, it,
+  not the `hare` package, should be added to `nativeBuildInputs` when building
+  Hare programs.
+
 - To facilitate dependency injection, the `imgui` package now builds a static archive using vcpkg' CMake rules.
   The derivation now installs "impl" headers selectively instead of by a wildcard.
   Use `imgui.src` if you just want to access the unpacked sources.
diff --git a/pkgs/by-name/bo/bonsai/package.nix b/pkgs/by-name/bo/bonsai/package.nix
index 6c5d9adb78b5e..98b19be7e6fce 100644
--- a/pkgs/by-name/bo/bonsai/package.nix
+++ b/pkgs/by-name/bo/bonsai/package.nix
@@ -1,9 +1,10 @@
-{ stdenv
-, lib
-, fetchFromSourcehut
-, gitUpdater
-, hare
-, hareThirdParty
+{
+  stdenv,
+  lib,
+  fetchFromSourcehut,
+  gitUpdater,
+  hareHook,
+  hareThirdParty,
 }:
 
 stdenv.mkDerivation (finalAttrs: {
@@ -18,30 +19,18 @@ stdenv.mkDerivation (finalAttrs: {
   };
 
   nativeBuildInputs = [
-    hare
+    hareHook
     hareThirdParty.hare-ev
     hareThirdParty.hare-json
   ];
 
-  makeFlags = [
-    "PREFIX=${builtins.placeholder "out"}"
-    "HARECACHE=.harecache"
-    "HAREFLAGS=-qa${stdenv.hostPlatform.uname.processor}"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   enableParallelBuilding = true;
 
   doCheck = true;
 
-  postPatch = ''
-    substituteInPlace Makefile \
-      --replace 'hare build' 'hare build $(HAREFLAGS)' \
-      --replace 'hare test' 'hare test $(HAREFLAGS)'
-  '';
-
-  passthru.updateScript = gitUpdater {
-    rev-prefix = "v";
-  };
+  passthru.updateScript = gitUpdater { rev-prefix = "v"; };
 
   meta = with lib; {
     description = "Finite State Machine structured as a tree";
diff --git a/pkgs/by-name/ha/hare/hook.nix b/pkgs/by-name/ha/hare/hook.nix
new file mode 100644
index 0000000000000..e5a9bad131aa4
--- /dev/null
+++ b/pkgs/by-name/ha/hare/hook.nix
@@ -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 = "A setup hook for the Hare compiler";
+    inherit (hare.meta) badPlatforms platforms;
+  };
+} ./setup-hook.sh
diff --git a/pkgs/by-name/ha/hare/package.nix b/pkgs/by-name/ha/hare/package.nix
index 5c8a80520937e..80c30e89a2b6c 100644
--- a/pkgs/by-name/ha/hare/package.nix
+++ b/pkgs/by-name/ha/hare/package.nix
@@ -3,7 +3,6 @@
   stdenv,
   fetchFromSourcehut,
   harec,
-  qbe,
   gitUpdater,
   scdoc,
   tzdata,
@@ -33,6 +32,7 @@ assert
   '';
 
 let
+  inherit (harec) qbe;
   buildArch = stdenv.buildPlatform.uname.processor;
   arch = stdenv.hostPlatform.uname.processor;
   platform = lib.toLower stdenv.hostPlatform.uname.system;
@@ -130,13 +130,6 @@ stdenv.mkDerivation (finalAttrs: {
     scdoc
   ];
 
-  # Needed for build frameworks like `haredo`, which set the HAREC and QBE env vars to `harec` and
-  # `qbe` respectively.
-  propagatedBuildInputs = [
-    harec
-    qbe
-  ];
-
   buildInputs = [
     harec
     qbe
@@ -171,8 +164,6 @@ stdenv.mkDerivation (finalAttrs: {
     ln -s configs/${platform}.mk config.mk
   '';
 
-  setupHook = ./setup-hook.sh;
-
   passthru = {
     updateScript = gitUpdater { };
     tests =
@@ -182,6 +173,8 @@ stdenv.mkDerivation (finalAttrs: {
       // lib.optionalAttrs (stdenv.buildPlatform.canExecute stdenv.hostPlatform) {
         mimeModule = callPackage ./mime-module-test.nix { hare = finalAttrs.finalPackage; };
       };
+    # To be propagated by `hareHook`.
+    inherit harec qbe;
   };
 
   meta = {
diff --git a/pkgs/by-name/ha/hare/setup-hook.sh b/pkgs/by-name/ha/hare/setup-hook.sh
index d2d2c34354d65..3a427fd70328f 100644
--- a/pkgs/by-name/ha/hare/setup-hook.sh
+++ b/pkgs/by-name/ha/hare/setup-hook.sh
@@ -1,9 +1,36 @@
-addHarepath () {
-    for haredir in third-party stdlib; do
-        if [[ -d "$1/src/hare/$haredir" ]]; then
-            addToSearchPath HAREPATH "$1/src/hare/$haredir"
-        fi
-    done
+# 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)"
+'
+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
diff --git a/pkgs/by-name/ha/harec/package.nix b/pkgs/by-name/ha/harec/package.nix
index e95ad7ed7095f..f0534064be3c8 100644
--- a/pkgs/by-name/ha/harec/package.nix
+++ b/pkgs/by-name/ha/harec/package.nix
@@ -1,17 +1,20 @@
-{ lib
-, stdenv
-, fetchFromSourcehut
-, qbe
-, gitUpdater
+{
+  fetchFromSourcehut,
+  gitUpdater,
+  lib,
+  qbe,
+  stdenv,
 }:
 let
   platform = lib.toLower stdenv.hostPlatform.uname.system;
   arch = stdenv.hostPlatform.uname.processor;
-  qbePlatform = {
-    x86_64 = "amd64_sysv";
-    aarch64 = "arm64";
-    riscv64 = "rv64";
-  }.${arch};
+  qbePlatform =
+    {
+      x86_64 = "amd64_sysv";
+      aarch64 = "arm64";
+      riscv64 = "rv64";
+    }
+    .${arch};
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "harec";
@@ -24,13 +27,9 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-NOfoCT/wKZ3CXYzXZq7plXcun+MXQicfzBOmetXN7Qs=";
   };
 
-  nativeBuildInputs = [
-    qbe
-  ];
+  nativeBuildInputs = [ qbe ];
 
-  buildInputs = [
-    qbe
-  ];
+  buildInputs = [ qbe ];
 
   makeFlags = [
     "PREFIX=${builtins.placeholder "out"}"
@@ -54,6 +53,8 @@ stdenv.mkDerivation (finalAttrs: {
 
   passthru = {
     updateScript = gitUpdater { };
+    # To be kept in sync with the hare package.
+    inherit qbe;
   };
 
   meta = {
@@ -65,7 +66,8 @@ stdenv.mkDerivation (finalAttrs: {
     # 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;
+    platforms =
+      with lib.platforms;
       lib.intersectLists (freebsd ++ openbsd ++ linux) (aarch64 ++ x86_64 ++ riscv64);
     badPlatforms = lib.platforms.darwin;
   };
diff --git a/pkgs/by-name/ha/haredo/package.nix b/pkgs/by-name/ha/haredo/package.nix
index e722d11eafd55..08592c674395a 100644
--- a/pkgs/by-name/ha/haredo/package.nix
+++ b/pkgs/by-name/ha/haredo/package.nix
@@ -2,16 +2,13 @@
   stdenv,
   lib,
   fetchFromSourcehut,
-  hare,
+  hareHook,
   scdoc,
   nix-update-script,
   makeWrapper,
   bash,
   substituteAll,
 }:
-let
-  arch = stdenv.hostPlatform.uname.processor;
-in
 stdenv.mkDerivation (finalAttrs: {
   pname = "haredo";
   version = "1.0.5";
@@ -37,27 +34,23 @@ stdenv.mkDerivation (finalAttrs: {
   ];
 
   nativeBuildInputs = [
-    hare
+    hareHook
     makeWrapper
     scdoc
   ];
 
   enableParallelChecking = true;
 
+  env.PREFIX = builtins.placeholder "out";
+
   doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
 
   dontConfigure = true;
 
-  preBuild = ''
-    HARECACHE="$(mktemp -d)"
-    export HARECACHE
-    export PREFIX=${builtins.placeholder "out"}
-  '';
-
   buildPhase = ''
     runHook preBuild
 
-    hare build -o bin/haredo -qRa${arch} ./src
+    hare build -o bin/haredo ./src
     scdoc <doc/haredo.1.scd >doc/haredo.1
 
     runHook postBuild
@@ -92,6 +85,6 @@ stdenv.mkDerivation (finalAttrs: {
     license = lib.licenses.wtfpl;
     maintainers = with lib.maintainers; [ onemoresuza ];
     mainProgram = "haredo";
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/by-name/ha/haredoc/package.nix b/pkgs/by-name/ha/haredoc/package.nix
index 2476e7d937c50..773b226316aee 100644
--- a/pkgs/by-name/ha/haredoc/package.nix
+++ b/pkgs/by-name/ha/haredoc/package.nix
@@ -1,33 +1,31 @@
-{ lib
-, stdenv
-, scdoc
-, hare
+{
+  lib,
+  stdenv,
+  scdoc,
+  hare,
+  hareHook,
 }:
-let
-  arch = stdenv.hostPlatform.uname.processor;
-in
 stdenv.mkDerivation {
   pname = "haredoc";
-  outputs = [ "out" "man" ];
+  outputs = [
+    "out"
+    "man"
+  ];
   inherit (hare) version src;
 
-  strictDeps = true;
-  enableParallelBuilding = true;
-
   nativeBuildInputs = [
     scdoc
-    hare
+    hareHook
   ];
 
-  preBuild = ''
-    HARECACHE="$(mktemp -d)"
-    export HARECACHE
-  '';
+  strictDeps = true;
+
+  enableParallelBuilding = true;
 
   buildPhase = ''
     runHook preBuild
 
-    hare build -qR -a ${arch} -o haredoc ./cmd/haredoc
+    hare build -o haredoc ./cmd/haredoc
     scdoc <docs/haredoc.1.scd >haredoc.1
     scdoc <docs/haredoc.5.scd >haredoc.5
 
@@ -50,6 +48,6 @@ stdenv.mkDerivation {
     license = lib.licenses.gpl3Only;
     maintainers = with lib.maintainers; [ onemoresuza ];
     mainProgram = "haredoc";
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 }
diff --git a/pkgs/by-name/tr/treecat/package.nix b/pkgs/by-name/tr/treecat/package.nix
index df184b9d10626..338e27af67d7b 100644
--- a/pkgs/by-name/tr/treecat/package.nix
+++ b/pkgs/by-name/tr/treecat/package.nix
@@ -1,15 +1,19 @@
-{ stdenv
-, fetchFromSourcehut
-, hare
-, haredo
-, lib
-, scdoc
+{
+  stdenv,
+  fetchFromSourcehut,
+  hareHook,
+  haredo,
+  lib,
+  scdoc,
 }:
 stdenv.mkDerivation (finalAttrs: {
   pname = "treecat";
   version = "1.0.2-unstable-2023-11-28";
 
-  outputs = [ "out" "man" ];
+  outputs = [
+    "out"
+    "man"
+  ];
 
   src = fetchFromSourcehut {
     owner = "~autumnull";
@@ -19,18 +23,14 @@ stdenv.mkDerivation (finalAttrs: {
   };
 
   nativeBuildInputs = [
-    hare
+    hareHook
     haredo
     scdoc
   ];
 
-  dontConfigure = true;
+  env.PREFIX = builtins.placeholder "out";
 
-  preBuild = ''
-    HARECACHE="$(mktemp -d)"
-    export HARECACHE
-    export PREFIX="${builtins.placeholder "out"}"
-  '';
+  dontConfigure = true;
 
   meta = {
     description = "Serialize a directory to a tree diagram, and vice versa";
@@ -42,6 +42,6 @@ stdenv.mkDerivation (finalAttrs: {
     license = lib.licenses.wtfpl;
     maintainers = with lib.maintainers; [ onemoresuza ];
     mainProgram = "treecat";
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/development/hare-third-party/hare-compress/default.nix b/pkgs/development/hare-third-party/hare-compress/default.nix
index cc52e3e47eab7..d9065f3bcd2c4 100644
--- a/pkgs/development/hare-third-party/hare-compress/default.nix
+++ b/pkgs/development/hare-third-party/hare-compress/default.nix
@@ -1,8 +1,14 @@
-{ lib, stdenv, hare, harec, fetchFromSourcehut }:
+{
+  lib,
+  stdenv,
+  hareHook,
+  harec,
+  fetchFromSourcehut,
+}:
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare-compress";
-  version = "unstable-2023-11-01";
+  version = "0-unstable-2023-11-01";
 
   src = fetchFromSourcehut {
     owner = "~sircmpwn";
@@ -11,12 +17,9 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-sz8xPBZaUFye3HH4lkRnH52ye451e6seZXN/qvg87jE=";
   };
 
-  nativeBuildInputs = [ hare ];
+  nativeBuildInputs = [ hareHook ];
 
-  makeFlags = [
-    "HARECACHE=.harecache"
-    "PREFIX=${builtins.placeholder "out"}"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   doCheck = true;
 
@@ -25,7 +28,6 @@ stdenv.mkDerivation (finalAttrs: {
     description = "Compression algorithms for Hare";
     license = with licenses; [ mpl20 ];
     maintainers = with maintainers; [ starzation ];
-
     inherit (harec.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/development/hare-third-party/hare-ev/default.nix b/pkgs/development/hare-third-party/hare-ev/default.nix
index ecde538823477..cb44606b29407 100644
--- a/pkgs/development/hare-third-party/hare-ev/default.nix
+++ b/pkgs/development/hare-third-party/hare-ev/default.nix
@@ -1,8 +1,9 @@
-{ stdenv
-, lib
-, fetchFromSourcehut
-, hare
-, unstableGitUpdater
+{
+  fetchFromSourcehut,
+  hareHook,
+  lib,
+  stdenv,
+  unstableGitUpdater,
 }:
 
 stdenv.mkDerivation {
@@ -16,14 +17,9 @@ stdenv.mkDerivation {
     hash = "sha256-SXExwDZKlW/2XYzmJUhkLWj6NF/znrv3vY9V0mD5iFQ=";
   };
 
-  nativeCheckInputs = [
-    hare
-  ];
+  nativeCheckInputs = [ hareHook ];
 
-  makeFlags = [
-    "HARECACHE=.harecache"
-    "PREFIX=${builtins.placeholder "out"}"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   doCheck = true;
 
@@ -34,6 +30,6 @@ stdenv.mkDerivation {
     homepage = "https://sr.ht/~sircmpwn/hare-ev";
     license = licenses.mpl20;
     maintainers = with maintainers; [ colinsane ];
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 }
diff --git a/pkgs/development/hare-third-party/hare-json/default.nix b/pkgs/development/hare-third-party/hare-json/default.nix
index c7a71f342967e..d78b384cb94b7 100644
--- a/pkgs/development/hare-third-party/hare-json/default.nix
+++ b/pkgs/development/hare-third-party/hare-json/default.nix
@@ -1,8 +1,14 @@
-{ lib, stdenv, hare, harec, fetchFromSourcehut }:
+{
+  fetchFromSourcehut,
+  hareHook,
+  harec,
+  lib,
+  stdenv,
+}:
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare-json";
-  version = "unstable-2023-03-13";
+  version = "0-unstable-2023-03-13";
 
   src = fetchFromSourcehut {
     owner = "~sircmpwn";
@@ -11,12 +17,9 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-Sx+RBiLhR3ftP89AwinVlBg0u0HX4GVP7TLmuofgC9s=";
   };
 
-  nativeBuildInputs = [ hare ];
+  nativeBuildInputs = [ hareHook ];
 
-  makeFlags = [
-    "HARECACHE=.harecache"
-    "PREFIX=${builtins.placeholder "out"}"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   doCheck = true;
 
@@ -25,7 +28,6 @@ stdenv.mkDerivation (finalAttrs: {
     description = "This package provides JSON support for Hare";
     license = with licenses; [ mpl20 ];
     maintainers = with maintainers; [ starzation ];
-
     inherit (harec.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/development/hare-third-party/hare-png/default.nix b/pkgs/development/hare-third-party/hare-png/default.nix
index 1218398f72b7b..fba410eb8ffdf 100644
--- a/pkgs/development/hare-third-party/hare-png/default.nix
+++ b/pkgs/development/hare-third-party/hare-png/default.nix
@@ -1,8 +1,14 @@
-{ lib, stdenv, hare, hareThirdParty, fetchFromSourcehut }:
+{
+  lib,
+  stdenv,
+  hareHook,
+  hareThirdParty,
+  fetchFromSourcehut,
+}:
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare-png";
-  version = "unstable-2023-09-09";
+  version = "0-unstable-2023-09-09";
 
   src = fetchFromSourcehut {
     owner = "~sircmpwn";
@@ -11,13 +17,10 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-Q7xylsLVd/sp57kv6WzC7QHGN1xOsm7YEsYCbY/zi1Q=";
   };
 
-  nativeBuildInputs = [ hare ];
+  nativeBuildInputs = [ hareHook ];
   propagatedBuildInputs = [ hareThirdParty.hare-compress ];
 
-  makeFlags = [
-    "PREFIX=${builtins.placeholder "out"}"
-    "HARECACHE=.harecache"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   doCheck = true;
 
@@ -26,7 +29,6 @@ stdenv.mkDerivation (finalAttrs: {
     description = "PNG implementation for Hare";
     license = with licenses; [ mpl20 ];
     maintainers = with maintainers; [ starzation ];
-
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/development/hare-third-party/hare-ssh/default.nix b/pkgs/development/hare-third-party/hare-ssh/default.nix
index d25669f366430..bf6e043fb977a 100644
--- a/pkgs/development/hare-third-party/hare-ssh/default.nix
+++ b/pkgs/development/hare-third-party/hare-ssh/default.nix
@@ -1,8 +1,13 @@
-{ lib, stdenv, hare, hareThirdParty, fetchFromSourcehut }:
+{
+  fetchFromSourcehut,
+  hareHook,
+  lib,
+  stdenv,
+}:
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare-ssh";
-  version = "unstable-2023-11-16";
+  version = "0-unstable-2023-11-16";
 
   src = fetchFromSourcehut {
     owner = "~sircmpwn";
@@ -11,12 +16,9 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-I43TLPoImBsvkgV3hDy9dw0pXVt4ezINnxFtEV9P2/M=";
   };
 
-  nativeBuildInputs = [ hare ];
+  nativeBuildInputs = [ hareHook ];
 
-  makeFlags = [
-    "PREFIX=${builtins.placeholder "out"}"
-    "HARECACHE=.harecache"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   doCheck = true;
 
@@ -26,6 +28,6 @@ stdenv.mkDerivation (finalAttrs: {
     license = with licenses; [ mpl20 ];
     maintainers = with maintainers; [ patwid ];
 
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/development/hare-third-party/hare-toml/default.nix b/pkgs/development/hare-third-party/hare-toml/default.nix
index ab760eb5fd24d..963158a6fbf8e 100644
--- a/pkgs/development/hare-third-party/hare-toml/default.nix
+++ b/pkgs/development/hare-third-party/hare-toml/default.nix
@@ -1,9 +1,10 @@
-{ stdenv
-, hare
-, scdoc
-, lib
-, fetchFromGitea
-, nix-update-script
+{
+  fetchFromGitea,
+  hareHook,
+  lib,
+  nix-update-script,
+  scdoc,
+  stdenv,
 }:
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare-toml";
@@ -19,13 +20,10 @@ stdenv.mkDerivation (finalAttrs: {
 
   nativeBuildInputs = [
     scdoc
-    hare
+    hareHook
   ];
 
-  makeFlags = [
-    "HARECACHE=.harecache"
-    "PREFIX=${builtins.placeholder "out"}"
-  ];
+  makeFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   checkTarget = "check_local";
 
@@ -40,6 +38,6 @@ stdenv.mkDerivation (finalAttrs: {
     homepage = "https://codeberg.org/lunacb/hare-toml";
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [ onemoresuza ];
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
 })
diff --git a/pkgs/tools/security/himitsu/default.nix b/pkgs/tools/security/himitsu/default.nix
index 3985a5c80a445..350a4112eefee 100644
--- a/pkgs/tools/security/himitsu/default.nix
+++ b/pkgs/tools/security/himitsu/default.nix
@@ -1,38 +1,34 @@
-{ lib
-, stdenv
-, fetchFromSourcehut
-, hare
-, scdoc
+{
+  fetchFromSourcehut,
+  hareHook,
+  lib,
+  scdoc,
+  stdenv,
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "himitsu";
   version = "0.7";
 
   src = fetchFromSourcehut {
-    name = pname + "-src";
     owner = "~sircmpwn";
-    repo = pname;
-    rev = version;
+    repo = "himitsu";
+    rev = finalAttrs.version;
     hash = "sha256-jDxQajc8Kyfihm8q3wCpA+WsbAkQEZerLckLQXNhTa8=";
   };
 
   nativeBuildInputs = [
-    hare
+    hareHook
     scdoc
   ];
 
-  preConfigure = ''
-    export HARECACHE=$(mktemp -d)
-  '';
-
-  installFlags = [ "PREFIX=" "DESTDIR=$(out)" ];
+  installFlags = [ "PREFIX=${builtins.placeholder "out"}" ];
 
   meta = with lib; {
     homepage = "https://himitsustore.org/";
     description = "A secret storage manager";
     license = licenses.gpl3Only;
     maintainers = with maintainers; [ auchter ];
-    inherit (hare.meta) platforms badPlatforms;
+    inherit (hareHook.meta) platforms badPlatforms;
   };
-}
+})
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index bfd89ef3adccf..a3e207242c668 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -25183,6 +25183,10 @@ with pkgs;
 
   leaps = callPackage ../development/tools/leaps { };
 
+  ### DEVELOPMENT / HARE
+
+  hareHook = callPackage ../by-name/ha/hare/hook.nix { };
+
   ### DEVELOPMENT / JAVA MODULES
 
   javaPackages = recurseIntoAttrs (callPackage ./java-packages.nix { });