From 6d2033e2b997b9cccbad098ff7b54fbc54c4d9f0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 18 Jul 2023 18:17:22 +0000 Subject: [PATCH] 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. --- pkgs/development/tools/just/default.nix | 2 + pkgs/development/tools/just/setup-hook.sh | 58 +++++++++++++++++++++++ pkgs/tools/networking/dogdns/default.nix | 4 ++ 3 files changed, 64 insertions(+) create mode 100644 pkgs/development/tools/just/setup-hook.sh diff --git a/pkgs/development/tools/just/default.nix b/pkgs/development/tools/just/default.nix index 5135ed30c993..0a4ba7c346f2 100644 --- a/pkgs/development/tools/just/default.nix +++ b/pkgs/development/tools/just/default.nix @@ -72,6 +72,8 @@ rustPlatform.buildRustPackage rec { --zsh completions/just.zsh ''; + setupHook = ./setup-hook.sh; + passthru.updateScript = nix-update-script { }; meta = with lib; { 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 diff --git a/pkgs/tools/networking/dogdns/default.nix b/pkgs/tools/networking/dogdns/default.nix index 1ec27bc22444..0677704b7ad5 100644 --- a/pkgs/tools/networking/dogdns/default.nix +++ b/pkgs/tools/networking/dogdns/default.nix @@ -41,6 +41,10 @@ rustPlatform.buildRustPackage rec { }; }; + dontUseJustBuild = true; + dontUseJustCheck = true; + dontUseJustInstall = true; + postPatch = '' # update Cargo.lock to work with openssl 3 ln -sf ${./Cargo.lock} Cargo.lock