From 63c1d89dda72d94b8cf54136e2fd6414cf33290d Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sun, 24 Dec 2023 04:58:13 +0200 Subject: [PATCH] Attempt fixing the backup and restore scripts This has required to eschew the `wrapProgram` script as they then go on to figure out their "installed" location via `dirname` which now points to the nixstore location. Thus leading to the backup being bogus and also not written. Fortunately all of the interesting programs are shell scripts, so we can just prepend some text to them. Another issue was that we were deleting the `lst` file that OH was relying on to clean up the backup afterwards. --- flake.lock | 12 ++++++------ openhab.nix | 15 ++++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 8768e3b..3c63b1a 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690716044, - "narHash": "sha256-5rhZK0YMQOK+FaOC72leFXUFuCBxKH5SRzUQqpePqQE=", + "lastModified": 1703383890, + "narHash": "sha256-3LNEli9ET6L+bdj7fxo4yLOKnfAYSGxUMBWt0Yx7oUQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b1b263e5f7f899704c6b592f2096bc8f719dc181", + "rev": "6586ea5fb647f22ff7f671003a888ffbc0950a7e", "type": "github" }, "original": { diff --git a/openhab.nix b/openhab.nix index 2bf944f..090d44f 100644 --- a/openhab.nix +++ b/openhab.nix @@ -7,6 +7,8 @@ lib, makeWrapper, procps, + zip, + unzip, stdenv, }: @@ -23,7 +25,7 @@ in stdenv.mkDerivation rec { nativeBuildInputs = [ makeWrapper ]; buildInputs = [ bash ]; outputs = [ "out" ]; - extraPath = lib.makeBinPath [ jdk-openhab gawk coreutils procps ]; + extraPath = lib.makeBinPath [ jdk-openhab gawk coreutils procps zip unzip ]; wrappedExecutables = [ "start.sh" "start_debug.sh" @@ -53,12 +55,15 @@ in stdenv.mkDerivation rec { "$out/"*.bat \ "$out/runtime/bin/"*.bat \ "$out/runtime/bin/"*.ps1 \ - "$out/runtime/bin/"*.psm1 \ - "$out/runtime/bin/"*.lst + "$out/runtime/bin/"*.psm1 for exe in $wrappedExecutables; do - echo "Wrapping $exe…" - wrapProgram $out/$exe --prefix PATH ':' $extraPath + echo "Rewriting $exe…" + cat - $out/$exe > "$out/$exe".new << EOF + #!${bash}/bin/sh + export PATH="\''$PATH:$extraPath" + EOF + mv "$out/$exe".new "$out/$exe" done runHook postInstall