about summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorMalte Brandy <malte.brandy@maralorn.de>2022-03-07 23:22:59 +0100
committerMalte Brandy <malte.brandy@maralorn.de>2022-03-08 14:15:22 +0100
commite8cfe80ccc1dfba2fd14e40d003b08c5637fc76f (patch)
treed4bbf5741f06a49cd4e0b1410ecdc437125886c4 /pkgs/tools
parent54da1bc6928c903956f807b653cd93d539a99002 (diff)
downloadnixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar.gz
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar.bz2
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar.lz
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar.xz
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.tar.zst
nixlib-e8cfe80ccc1dfba2fd14e40d003b08c5637fc76f.zip
nix-output-monitor: Introduce update.sh
Diffstat (limited to 'pkgs/tools')
-rwxr-xr-xpkgs/tools/nix/nix-output-monitor/update.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/tools/nix/nix-output-monitor/update.sh b/pkgs/tools/nix/nix-output-monitor/update.sh
new file mode 100755
index 000000000000..938736e91942
--- /dev/null
+++ b/pkgs/tools/nix/nix-output-monitor/update.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p cabal2nix curl jq alejandra
+#
+# This script will update the nix-output-monitor derivation to the latest version using
+# cabal2nix.
+
+set -eo pipefail
+
+# This is the directory of this update.sh script.
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+derivation_file="${script_dir}/default.nix"
+
+# This is the latest released version of nix-output-monitor on GitHub.
+new_version=$(curl --silent "https://api.github.com/repos/maralorn/nix-output-monitor/releases" | jq '.[0].tag_name' --raw-output)
+
+echo "Updating nix-output-monitor to version $new_version."
+echo "Running cabal2nix and outputting to ${derivation_file}..."
+
+cat > "$derivation_file" << EOF
+# This file has been autogenerate with cabal2nix.
+# Update via ./update.sh"
+EOF
+cabal2nix --extra-arguments expect --extra-arguments runtimeShell --maintainer maralorn "https://github.com/maralorn/nix-output-monitor/archive/refs/tags/${new_version}.tar.gz" | head -n-1 >> "$derivation_file"
+cat >> "$derivation_file" << EOF
+    passthru.updateScript = ./update.sh;
+    testTarget = "unit-tests";
+    postInstall = ''
+        cat > \$out/bin/nom-build << EOF
+        #!\${runtimeShell}
+        \${expect}/bin/unbuffer nix-build "\\\$@" 2>&1 | exec \$out/bin/nom
+        EOF
+        chmod a+x \$out/bin/nom-build
+    '';
+}
+EOF
+
+alejandra "${derivation_file}" | cat
+
+echo "Finished."