Fix overwritting OPEN_HAB env
This commit is contained in:
116
openhab.nix
116
openhab.nix
@@ -1,71 +1,75 @@
|
|||||||
{
|
{
|
||||||
bash,
|
bash,
|
||||||
coreutils,
|
coreutils,
|
||||||
fetchurl,
|
fetchurl,
|
||||||
gawk,
|
gawk,
|
||||||
jdk-openhab,
|
jdk-openhab,
|
||||||
lib,
|
lib,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
procps,
|
procps,
|
||||||
zip,
|
zip,
|
||||||
unzip,
|
unzip,
|
||||||
stdenv,
|
stdenv,
|
||||||
}:
|
gnused,
|
||||||
|
}: let
|
||||||
let
|
version = builtins.readFile ./version;
|
||||||
version = builtins.readFile ./version;
|
sha256 = builtins.readFile ./openhab.sha256;
|
||||||
sha256 = builtins.readFile ./openhab.sha256;
|
in
|
||||||
in stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
inherit version;
|
inherit version;
|
||||||
pname = "openhab";
|
pname = "openhab";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://github.com/openhab/openhab-distro/releases/download/${version}/openhab-${version}.tar.gz";
|
url = "https://github.com/openhab/openhab-distro/releases/download/${version}/openhab-${version}.tar.gz";
|
||||||
inherit sha256;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [makeWrapper gnused];
|
||||||
buildInputs = [ bash ];
|
buildInputs = [bash];
|
||||||
outputs = [ "out" ];
|
outputs = ["out"];
|
||||||
extraPath = lib.makeBinPath [ jdk-openhab gawk coreutils procps zip unzip ];
|
extraPath = lib.makeBinPath [jdk-openhab gawk coreutils procps zip unzip];
|
||||||
wrappedExecutables = [
|
wrappedExecutables = [
|
||||||
"start.sh"
|
"start.sh"
|
||||||
"start_debug.sh"
|
"start_debug.sh"
|
||||||
"runtime/bin/karaf"
|
"runtime/bin/karaf"
|
||||||
"runtime/bin/backup"
|
"runtime/bin/backup"
|
||||||
"runtime/bin/client"
|
"runtime/bin/client"
|
||||||
"runtime/bin/instance"
|
"runtime/bin/instance"
|
||||||
"runtime/bin/karaf"
|
"runtime/bin/karaf"
|
||||||
"runtime/bin/restore"
|
"runtime/bin/restore"
|
||||||
"runtime/bin/shell"
|
"runtime/bin/shell"
|
||||||
"runtime/bin/start"
|
"runtime/bin/start"
|
||||||
"runtime/bin/status"
|
"runtime/bin/status"
|
||||||
"runtime/bin/stop"
|
"runtime/bin/stop"
|
||||||
"runtime/bin/update"
|
"runtime/bin/update"
|
||||||
];
|
];
|
||||||
|
|
||||||
unpackPhase = ''
|
unpackPhase = ''
|
||||||
runHook preUnpack
|
runHook preUnpack
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
tar -C $out -xf $src
|
tar -C $out -xf $src
|
||||||
runHook postUnpack
|
runHook postUnpack
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
rm -rfv \
|
rm -rfv \
|
||||||
"$out/"*.bat \
|
"$out/"*.bat \
|
||||||
"$out/runtime/bin/"*.bat \
|
"$out/runtime/bin/"*.bat \
|
||||||
"$out/runtime/bin/"*.ps1 \
|
"$out/runtime/bin/"*.ps1 \
|
||||||
"$out/runtime/bin/"*.psm1
|
"$out/runtime/bin/"*.psm1
|
||||||
|
|
||||||
for exe in $wrappedExecutables; do
|
for exe in $wrappedExecutables; do
|
||||||
echo "Rewriting $exe…"
|
echo "Rewriting $exe…"
|
||||||
cat - $out/$exe > "$out/$exe".new << EOF
|
cat - $out/$exe > "$out/$exe".new << EOF
|
||||||
#!${bash}/bin/sh
|
#!${bash}/bin/sh
|
||||||
export PATH="\''$PATH:$extraPath"
|
export PATH="\''$PATH:$extraPath"
|
||||||
EOF
|
EOF
|
||||||
mv "$out/$exe".new "$out/$exe"
|
mv "$out/$exe".new "$out/$exe"
|
||||||
done
|
done
|
||||||
|
|
||||||
runHook postInstall
|
# Fix OPENHAB_HOME overwritting
|
||||||
|
sed '6d' "$out/runtime/bin/oh_dir_layout" | sed '6i if [ -z ''${OPENHAB_HOME} ]; then\n\texport OPENHAB_HOME=`cd "$DIRNAME/../.."; pwd`\nfi' > "$out/runtime/bin/oh_dir_layout.new"
|
||||||
|
mv "$out/runtime/bin/oh_dir_layout.new" "$out/runtime/bin/oh_dir_layout"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user