From e6c228544d2651ed0a481f28bed75b73f49432e0 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Fri, 24 May 2024 09:04:46 -0300 Subject: harec: format with nixfmt-rfc-style --- pkgs/by-name/ha/harec/package.nix | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pkgs/by-name/ha/harec/package.nix b/pkgs/by-name/ha/harec/package.nix index e95ad7ed7095f..e3be45fef2c17 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"}" @@ -65,7 +64,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; }; -- cgit 1.4.1 From 3297bf3ba6a0fb6b12fa3527fbe25449f5f6e6e0 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Fri, 24 May 2024 09:06:47 -0300 Subject: harec: expose qbe through passthru harec and hare should always have the same qbe package. By exposing the latter under harec's passthru attribute and using it as hare's qbe, we assure that they will always hare the same qbe package even if there's a need for a local overlay. --- pkgs/by-name/ha/hare/package.nix | 2 +- pkgs/by-name/ha/harec/package.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ha/hare/package.nix b/pkgs/by-name/ha/hare/package.nix index 5c8a80520937e..faa766c056df5 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; diff --git a/pkgs/by-name/ha/harec/package.nix b/pkgs/by-name/ha/harec/package.nix index e3be45fef2c17..f0534064be3c8 100644 --- a/pkgs/by-name/ha/harec/package.nix +++ b/pkgs/by-name/ha/harec/package.nix @@ -53,6 +53,8 @@ stdenv.mkDerivation (finalAttrs: { passthru = { updateScript = gitUpdater { }; + # To be kept in sync with the hare package. + inherit qbe; }; meta = { -- cgit 1.4.1 From b0fcfa88cf11fe6e2546ff4a1452e96d4c7a41bb Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 19:58:37 -0300 Subject: hareHook: init Co-authored-by: Colin --- nixos/doc/manual/release-notes/rl-2411.section.md | 4 ++ pkgs/by-name/ha/hare/hook.nix | 56 +++++++++++++++++++++++ pkgs/by-name/ha/hare/package.nix | 11 +---- pkgs/by-name/ha/hare/setup-hook.sh | 39 +++++++++++++--- pkgs/top-level/all-packages.nix | 4 ++ 5 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 pkgs/by-name/ha/hare/hook.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 51904352b3b7e..cb8eb6dfb3be8 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -46,6 +46,10 @@ +- `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/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 faa766c056df5..80c30e89a2b6c 100644 --- a/pkgs/by-name/ha/hare/package.nix +++ b/pkgs/by-name/ha/hare/package.nix @@ -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/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2c8cad1325ba6..2e7ff897c020a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25196,6 +25196,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 { }); -- cgit 1.4.1 From 6893d370fc493cb5bba95f1d325a5293756c089a Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:13:39 -0300 Subject: haredoc: format with nixfmt-rfc-style --- pkgs/by-name/ha/haredoc/package.nix | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/ha/haredoc/package.nix b/pkgs/by-name/ha/haredoc/package.nix index 2476e7d937c50..021df50b0671d 100644 --- a/pkgs/by-name/ha/haredoc/package.nix +++ b/pkgs/by-name/ha/haredoc/package.nix @@ -1,24 +1,29 @@ -{ lib -, stdenv -, scdoc -, hare +{ + lib, + stdenv, + scdoc, + hare, }: 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 ]; + strictDeps = true; + + enableParallelBuilding = true; + preBuild = '' HARECACHE="$(mktemp -d)" export HARECACHE -- cgit 1.4.1 From 85b5260197dd9feb9b17b78e046890b51c173cec Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:14:30 -0300 Subject: haredoc: make use of hareHook --- pkgs/by-name/ha/haredoc/package.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/ha/haredoc/package.nix b/pkgs/by-name/ha/haredoc/package.nix index 021df50b0671d..773b226316aee 100644 --- a/pkgs/by-name/ha/haredoc/package.nix +++ b/pkgs/by-name/ha/haredoc/package.nix @@ -3,10 +3,8 @@ stdenv, scdoc, hare, + hareHook, }: -let - arch = stdenv.hostPlatform.uname.processor; -in stdenv.mkDerivation { pname = "haredoc"; outputs = [ @@ -17,22 +15,17 @@ stdenv.mkDerivation { nativeBuildInputs = [ scdoc - hare + hareHook ]; strictDeps = true; enableParallelBuilding = true; - preBuild = '' - HARECACHE="$(mktemp -d)" - export HARECACHE - ''; - buildPhase = '' runHook preBuild - hare build -qR -a ${arch} -o haredoc ./cmd/haredoc + hare build -o haredoc ./cmd/haredoc scdoc haredoc.1 scdoc haredoc.5 @@ -55,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; }; } -- cgit 1.4.1 From f1eabff06ec31bc63531d710338c4ce92c4e98d3 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:11:26 -0300 Subject: haredo: make use of hareHook --- pkgs/by-name/ha/haredo/package.nix | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) 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 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; }; }) -- cgit 1.4.1 From cadd323c202cf55b95b2d730f926c1a5c0e5bc09 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:11:11 -0300 Subject: treecat: format with nixfmt-rfc-style --- pkgs/by-name/tr/treecat/package.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/tr/treecat/package.nix b/pkgs/by-name/tr/treecat/package.nix index df184b9d10626..82e850025349d 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, + hare, + 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"; -- cgit 1.4.1 From 4a6c11900142e2476d3f3ae26dd2df6e4ae6135f Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:12:00 -0300 Subject: treecat: make use of hareHook --- pkgs/by-name/tr/treecat/package.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/tr/treecat/package.nix b/pkgs/by-name/tr/treecat/package.nix index 82e850025349d..338e27af67d7b 100644 --- a/pkgs/by-name/tr/treecat/package.nix +++ b/pkgs/by-name/tr/treecat/package.nix @@ -1,7 +1,7 @@ { stdenv, fetchFromSourcehut, - hare, + hareHook, haredo, lib, scdoc, @@ -23,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"; @@ -46,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; }; }) -- cgit 1.4.1 From 1ef1988149cd3f0172ae2ec244ed4b000f7c701e Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 11:57:02 -0300 Subject: hareThirdParty.hare-json: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-json/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-json/default.nix b/pkgs/development/hare-third-party/hare-json/default.nix index c7a71f342967e..b66f0df3acf9f 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, + hare, + harec, + lib, + stdenv, +}: stdenv.mkDerivation (finalAttrs: { pname = "hare-json"; - version = "unstable-2023-03-13"; + version = "0-unstable-2023-03-13"; src = fetchFromSourcehut { owner = "~sircmpwn"; @@ -25,7 +31,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; }; }) -- cgit 1.4.1 From 081396ca7dd0b7f2a8111a0f49ad9cc202923a92 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 12:01:57 -0300 Subject: hareThirdParty.hare-json: make use of hareHook --- pkgs/development/hare-third-party/hare-json/default.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-json/default.nix b/pkgs/development/hare-third-party/hare-json/default.nix index b66f0df3acf9f..d78b384cb94b7 100644 --- a/pkgs/development/hare-third-party/hare-json/default.nix +++ b/pkgs/development/hare-third-party/hare-json/default.nix @@ -1,6 +1,6 @@ { fetchFromSourcehut, - hare, + hareHook, harec, lib, stdenv, @@ -17,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; -- cgit 1.4.1 From 87168b4bab02a9599a2d49211e800c7815f26e75 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:04:51 -0300 Subject: hareThirdParty.hare-ev: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-ev/default.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-ev/default.nix b/pkgs/development/hare-third-party/hare-ev/default.nix index ecde538823477..41c9016c2d130 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, + hare, + lib, + stdenv, + unstableGitUpdater, }: stdenv.mkDerivation { @@ -16,9 +17,7 @@ stdenv.mkDerivation { hash = "sha256-SXExwDZKlW/2XYzmJUhkLWj6NF/znrv3vY9V0mD5iFQ="; }; - nativeCheckInputs = [ - hare - ]; + nativeCheckInputs = [ hare ]; makeFlags = [ "HARECACHE=.harecache" -- cgit 1.4.1 From 03622fdd0198c54a5529dcd0f6022b641cdf23ac Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:06:10 -0300 Subject: hareThirdParty.hare-ev: make use of hareHook --- pkgs/development/hare-third-party/hare-ev/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-ev/default.nix b/pkgs/development/hare-third-party/hare-ev/default.nix index 41c9016c2d130..cb44606b29407 100644 --- a/pkgs/development/hare-third-party/hare-ev/default.nix +++ b/pkgs/development/hare-third-party/hare-ev/default.nix @@ -1,6 +1,6 @@ { fetchFromSourcehut, - hare, + hareHook, lib, stdenv, unstableGitUpdater, @@ -17,12 +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; @@ -33,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; }; } -- cgit 1.4.1 From 8e0140c6767684daa011af0dcd9a36ae5a73a5d2 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:14:57 -0300 Subject: bonsai: format with nixfmt-rfc-style --- pkgs/by-name/bo/bonsai/package.nix | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/bo/bonsai/package.nix b/pkgs/by-name/bo/bonsai/package.nix index 6c5d9adb78b5e..645b2598de00d 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, + hare, + hareThirdParty, }: stdenv.mkDerivation (finalAttrs: { @@ -39,9 +40,7 @@ stdenv.mkDerivation (finalAttrs: { --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"; -- cgit 1.4.1 From d2cef6437cefd5ea75aba26fd1caaea2807e0a62 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:25:45 -0300 Subject: bonsai: make use of hareHook --- pkgs/by-name/bo/bonsai/package.nix | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pkgs/by-name/bo/bonsai/package.nix b/pkgs/by-name/bo/bonsai/package.nix index 645b2598de00d..98b19be7e6fce 100644 --- a/pkgs/by-name/bo/bonsai/package.nix +++ b/pkgs/by-name/bo/bonsai/package.nix @@ -3,7 +3,7 @@ lib, fetchFromSourcehut, gitUpdater, - hare, + hareHook, hareThirdParty, }: @@ -19,27 +19,17 @@ 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"; }; meta = with lib; { -- cgit 1.4.1 From 995664853d55e19e1b960060ceca3e3e57845b70 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:28:25 -0300 Subject: hareThirdParty.hare-compress: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-compress/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-compress/default.nix b/pkgs/development/hare-third-party/hare-compress/default.nix index cc52e3e47eab7..9cd508f52ced4 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, + hare, + harec, + fetchFromSourcehut, +}: stdenv.mkDerivation (finalAttrs: { pname = "hare-compress"; - version = "unstable-2023-11-01"; + version = "0-unstable-2023-11-01"; src = fetchFromSourcehut { owner = "~sircmpwn"; @@ -25,7 +31,6 @@ stdenv.mkDerivation (finalAttrs: { description = "Compression algorithms for Hare"; license = with licenses; [ mpl20 ]; maintainers = with maintainers; [ starzation ]; - inherit (harec.meta) platforms badPlatforms; }; }) -- cgit 1.4.1 From 93b01fe232b13e306393965f657fc5b733050b43 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:29:54 -0300 Subject: hareThirdParty.hare-compress: make use of hareHook --- pkgs/development/hare-third-party/hare-compress/default.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-compress/default.nix b/pkgs/development/hare-third-party/hare-compress/default.nix index 9cd508f52ced4..d9065f3bcd2c4 100644 --- a/pkgs/development/hare-third-party/hare-compress/default.nix +++ b/pkgs/development/hare-third-party/hare-compress/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, - hare, + hareHook, harec, fetchFromSourcehut, }: @@ -17,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; -- cgit 1.4.1 From 3653812becbe3719017c0c103edf9ff694f33313 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:26:34 -0300 Subject: hareThirdParty.hare-png: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-png/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-png/default.nix b/pkgs/development/hare-third-party/hare-png/default.nix index 1218398f72b7b..e6a15d740d3c9 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, + hare, + hareThirdParty, + fetchFromSourcehut, +}: stdenv.mkDerivation (finalAttrs: { pname = "hare-png"; - version = "unstable-2023-09-09"; + version = "0-unstable-2023-09-09"; src = fetchFromSourcehut { owner = "~sircmpwn"; @@ -26,7 +32,6 @@ stdenv.mkDerivation (finalAttrs: { description = "PNG implementation for Hare"; license = with licenses; [ mpl20 ]; maintainers = with maintainers; [ starzation ]; - inherit (hare.meta) platforms badPlatforms; }; }) -- cgit 1.4.1 From ea56874d33838f051061965fcf7f618712ec9689 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 16 May 2024 20:31:01 -0300 Subject: hareThirdParty.hare-png: make use of hareHook --- pkgs/development/hare-third-party/hare-png/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-png/default.nix b/pkgs/development/hare-third-party/hare-png/default.nix index e6a15d740d3c9..fba410eb8ffdf 100644 --- a/pkgs/development/hare-third-party/hare-png/default.nix +++ b/pkgs/development/hare-third-party/hare-png/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, - hare, + hareHook, hareThirdParty, fetchFromSourcehut, }: @@ -17,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; @@ -32,6 +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; }; }) -- cgit 1.4.1 From 2cb996b599be1f769077604a123d23d9ae534c3e Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:01:07 -0300 Subject: hareThirdParty.hare-toml: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-toml/default.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-toml/default.nix b/pkgs/development/hare-third-party/hare-toml/default.nix index ab760eb5fd24d..5c6d206b415fa 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, + hare, + lib, + nix-update-script, + scdoc, + stdenv, }: stdenv.mkDerivation (finalAttrs: { pname = "hare-toml"; -- cgit 1.4.1 From 676a48a5ea6aacefc45608b54e36085e304db7f9 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:01:58 -0300 Subject: hareThirdParty.hare-toml: make use of hareHook --- pkgs/development/hare-third-party/hare-toml/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-toml/default.nix b/pkgs/development/hare-third-party/hare-toml/default.nix index 5c6d206b415fa..963158a6fbf8e 100644 --- a/pkgs/development/hare-third-party/hare-toml/default.nix +++ b/pkgs/development/hare-third-party/hare-toml/default.nix @@ -1,6 +1,6 @@ { fetchFromGitea, - hare, + hareHook, lib, nix-update-script, scdoc, @@ -20,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"; @@ -41,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; }; }) -- cgit 1.4.1 From f3057406bf4a1247bb8a6bbf8f58eb38cc5f025d Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:07:07 -0300 Subject: hareThirdParty.hare-ssh: format with nixfmt-rfc-style --- pkgs/development/hare-third-party/hare-ssh/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-ssh/default.nix b/pkgs/development/hare-third-party/hare-ssh/default.nix index d25669f366430..87a34de0c32e7 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, + hare, + lib, + stdenv, +}: stdenv.mkDerivation (finalAttrs: { pname = "hare-ssh"; - version = "unstable-2023-11-16"; + version = "0-unstable-2023-11-16"; src = fetchFromSourcehut { owner = "~sircmpwn"; -- cgit 1.4.1 From 49ba155c4ae6417c80987f2d2d9c6a6e6949075e Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:07:53 -0300 Subject: hareThirdParty.hare-ssh: make use of hareHook --- pkgs/development/hare-third-party/hare-ssh/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/development/hare-third-party/hare-ssh/default.nix b/pkgs/development/hare-third-party/hare-ssh/default.nix index 87a34de0c32e7..bf6e043fb977a 100644 --- a/pkgs/development/hare-third-party/hare-ssh/default.nix +++ b/pkgs/development/hare-third-party/hare-ssh/default.nix @@ -1,6 +1,6 @@ { fetchFromSourcehut, - hare, + hareHook, lib, stdenv, }: @@ -16,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; @@ -31,6 +28,6 @@ stdenv.mkDerivation (finalAttrs: { license = with licenses; [ mpl20 ]; maintainers = with maintainers; [ patwid ]; - inherit (hare.meta) platforms badPlatforms; + inherit (hareHook.meta) platforms badPlatforms; }; }) -- cgit 1.4.1 From 8679a88fc9de9fdf6563c8b34955440a33b68b45 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Mon, 27 May 2024 13:58:47 -0300 Subject: himitsu: format with nixfmt-rfc-style --- pkgs/tools/security/himitsu/default.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/tools/security/himitsu/default.nix b/pkgs/tools/security/himitsu/default.nix index 3985a5c80a445..f3a10f66def60 100644 --- a/pkgs/tools/security/himitsu/default.nix +++ b/pkgs/tools/security/himitsu/default.nix @@ -1,19 +1,19 @@ -{ lib -, stdenv -, fetchFromSourcehut -, hare -, scdoc +{ + fetchFromSourcehut, + hare, + 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="; }; @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { export HARECACHE=$(mktemp -d) ''; - installFlags = [ "PREFIX=" "DESTDIR=$(out)" ]; + installFlags = [ "PREFIX=${builtins.placeholder "out"}" ]; meta = with lib; { homepage = "https://himitsustore.org/"; @@ -35,4 +35,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ auchter ]; inherit (hare.meta) platforms badPlatforms; }; -} +}) -- cgit 1.4.1 From 9167984ec0cb6c54f2bacb8909995614766c11d4 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 23 May 2024 20:17:13 -0300 Subject: himitsu: make use of hareHook --- pkgs/tools/security/himitsu/default.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/security/himitsu/default.nix b/pkgs/tools/security/himitsu/default.nix index f3a10f66def60..350a4112eefee 100644 --- a/pkgs/tools/security/himitsu/default.nix +++ b/pkgs/tools/security/himitsu/default.nix @@ -1,6 +1,6 @@ { fetchFromSourcehut, - hare, + hareHook, lib, scdoc, stdenv, @@ -18,14 +18,10 @@ stdenv.mkDerivation (finalAttrs: { }; nativeBuildInputs = [ - hare + hareHook scdoc ]; - preConfigure = '' - export HARECACHE=$(mktemp -d) - ''; - installFlags = [ "PREFIX=${builtins.placeholder "out"}" ]; meta = with lib; { @@ -33,6 +29,6 @@ stdenv.mkDerivation (finalAttrs: { description = "A secret storage manager"; license = licenses.gpl3Only; maintainers = with maintainers; [ auchter ]; - inherit (hare.meta) platforms badPlatforms; + inherit (hareHook.meta) platforms badPlatforms; }; }) -- cgit 1.4.1 From cfa58200cd9958eea5221bf5dfcf82778a0e0220 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Sat, 25 May 2024 11:34:14 -0300 Subject: doc/hare: init --- doc/languages-frameworks/hare.section.md | 53 ++++++++++++++++++++++++++++++++ doc/languages-frameworks/index.md | 1 + 2 files changed, 54 insertions(+) create mode 100644 doc/languages-frameworks/hare.section.md 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 = ""; + version = ""; + src = ""; + + nativeBuildInputs = [ hareHook ]; + + meta = { + 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 -- cgit 1.4.1