about summary refs log tree commit diff
path: root/pkgs/development/tools/just/setup-hook.sh
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-07-18 18:17:22 +0000
committerAlyssa Ross <hi@alyssa.is>2023-08-21 17:09:48 +0000
commit6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0 (patch)
tree74e2a4a9bd77e70be1edef98881a338152b9280c /pkgs/development/tools/just/setup-hook.sh
parent5d74a825b578781e1712f3f5a1e7265317aaaf39 (diff)
downloadnixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar.gz
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar.bz2
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar.lz
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar.xz
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.tar.zst
nixlib-6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0.zip
just.setupHook: init
Adapted from the Ninja setup hook.  This will mean that adding just to
nativeBuildInputs is enough to have a package be automatically built
with it, matching make, bmake, ninja, etc.

Currently, we have two packages in Nixpkgs that use just, dogdns and
kabeljau.  kabeljau follows the expected conventions, while dogdns
does not.  I expect there to be more packages using just in future,
following these conventions, because all of the packages in system76's
in-progress COSMIC desktop environment use just, and follow the
conventions.
Diffstat (limited to 'pkgs/development/tools/just/setup-hook.sh')
-rw-r--r--pkgs/development/tools/just/setup-hook.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/pkgs/development/tools/just/setup-hook.sh b/pkgs/development/tools/just/setup-hook.sh
new file mode 100644
index 000000000000..0ffcfc187ebf
--- /dev/null
+++ b/pkgs/development/tools/just/setup-hook.sh
@@ -0,0 +1,58 @@
+justBuildPhase() {
+    runHook preBuild
+
+    local flagsArray=($justFlags "${justFlagsArray[@]}")
+
+    echoCmd 'build flags' "${flagsArray[@]}"
+    just "${flagsArray[@]}"
+
+    runHook postBuild
+}
+
+justCheckPhase() {
+    runHook preCheck
+
+    if [ -z "${checkTarget:-}" ]; then
+        if just -n test >/dev/null 2>&1; then
+            checkTarget=test
+        fi
+    fi
+
+    if [ -z "${checkTarget:-}" ]; then
+        echo "no test target found in just, doing nothing"
+    else
+        local flagsArray=(
+            $justFlags "${justFlagsArray[@]}"
+            $checkTarget
+        )
+
+        echoCmd 'check flags' "${flagsArray[@]}"
+        just "${flagsArray[@]}"
+    fi
+
+    runHook postCheck
+}
+
+justInstallPhase() {
+    runHook preInstall
+
+    # shellcheck disable=SC2086
+    local flagsArray=($justFlags "${justFlagsArray[@]}" ${installTargets:-install})
+
+    echoCmd 'install flags' "${flagsArray[@]}"
+    just "${flagsArray[@]}"
+
+    runHook postInstall
+}
+
+if [ -z "${dontUseJustBuild-}" -a -z "${buildPhase-}" ]; then
+    buildPhase=justBuildPhase
+fi
+
+if [ -z "${dontUseJustCheck-}" -a -z "${checkPhase-}" ]; then
+    checkPhase=justCheckPhase
+fi
+
+if [ -z "${dontUseJustInstall-}" -a -z "${installPhase-}" ]; then
+    installPhase=justInstallPhase
+fi