From d2b58b8a8ba87c22debfbddc29642c2bf5a39f67 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Wed, 22 Feb 2023 02:23:37 +0200 Subject: [PATCH] Add OH-addons package --- openhab-addons.nix | 9 +++++++++ openhab-addons.sha256 | 1 + openhab.nix | 9 ++++++--- openhab.sha256 | 1 + sha256 | 1 - update.sh | 20 ++++++++++++++++++++ version | 2 +- 7 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 openhab-addons.nix create mode 100644 openhab-addons.sha256 create mode 100644 openhab.sha256 delete mode 100644 sha256 create mode 100755 update.sh diff --git a/openhab-addons.nix b/openhab-addons.nix new file mode 100644 index 0000000..a3ec4e5 --- /dev/null +++ b/openhab-addons.nix @@ -0,0 +1,9 @@ +{ fetchurl }: + +let + version = builtins.readFile ./version; + sha256 = builtins.readFile ./openhab-addons.sha256; +in fetchurl { + url = "https://github.com/openhab/openhab-distro/releases/download/${version}/openhab-addons-${version}.kar"; + inherit sha256; +} diff --git a/openhab-addons.sha256 b/openhab-addons.sha256 new file mode 100644 index 0000000..e1a1662 --- /dev/null +++ b/openhab-addons.sha256 @@ -0,0 +1 @@ +730b96b8acf84f44ed9df46cd58f1bd2e6afd3b498abe62f796da074ca932594 \ No newline at end of file diff --git a/openhab.nix b/openhab.nix index 0af70f2..4f8344e 100644 --- a/openhab.nix +++ b/openhab.nix @@ -9,12 +9,15 @@ stdenv, }: -stdenv.mkDerivation rec { - pname = "openhab"; +let version = builtins.readFile ./version; + sha256 = builtins.readFile ./openhab.sha256; +in stdenv.mkDerivation rec { + inherit version; + pname = "openhab"; src = fetchurl { url = "https://github.com/openhab/openhab-distro/releases/download/${version}/openhab-${version}.tar.gz"; - sha256 = builtins.readFile ./sha256; + inherit sha256; }; nativeBuildInputs = [ makeWrapper ]; buildInputs = [ bash ]; diff --git a/openhab.sha256 b/openhab.sha256 new file mode 100644 index 0000000..5cbf250 --- /dev/null +++ b/openhab.sha256 @@ -0,0 +1 @@ +551451292ead9ca440b0d224d60d7f68629f9949dcec8874effa7991650e31df \ No newline at end of file diff --git a/sha256 b/sha256 deleted file mode 100644 index 6d40faf..0000000 --- a/sha256 +++ /dev/null @@ -1 +0,0 @@ -sha256-VRRRKS6tnKRAsNIk1g1/aGKfmUnc7Ih07/p5kWUOMd8= diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..a3ff803 --- /dev/null +++ b/update.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq ripgrep gawk + +set -eux + +readarray -t RELEASES <<<"$(curl https://api.github.com/repos/openhab/openhab-distro/tags | jq -r '.[].name' | rg '^\d+\.\d+\.\d+*$')" +MOST_RECENT=${RELEASES[0]} + +echo -n "$MOST_RECENT" > version +curl -L https://github.com/openhab/openhab-distro/releases/download/"$MOST_RECENT"/openhab-"$MOST_RECENT".tar.gz \ + | sha256sum \ + | cut -d" " -f1 \ + | tr -d '\n' \ + > openhab.sha256 + +curl -L https://github.com/openhab/openhab-distro/releases/download/"$MOST_RECENT"/openhab-addons-"$MOST_RECENT".kar \ + | sha256sum \ + | cut -d" " -f1 \ + | tr -d '\n' \ + > openhab-addons.sha256 diff --git a/version b/version index 4d9d11c..a423d42 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.4.2 +3.4.2 \ No newline at end of file