Hello,
I’d like to add a script to an existing project, in the bin
folder, that calls some executable that lies in the same bin
folder. I’ve tried to use writeShellScriptBin
with something like:
let
mywrapper = binaryfile: writeShellScript "XX" ''
bla;
${binaryfile}&
blo
'';
in
mkDerivation rec {
# ...
installPhase = ''
install -Dt $out/bin mainbinary ${myWrapper (out + "/bin/mainbinary")}";
}
Unfortunately, this does not compile since out
variable does not exist. How could I make this script work? How could I refer to the current derivation? Is there a better way to proceed?
PS: for reference here is the script I’m trying to use:
{ stdenv, fetchFromGitHub, pkgconfig, libusbmuxd, libplist, speex, libav, alsaLib, gtk3, libappindicator-gtk3, libjpeg_turbo, writeShellScriptBin }:
let
myWrapper = binaryfile: writeShellScriptBin "droidcam-with-modules" ''
if ! modinfo v4l2loopback_dc; then
sudo modprobe v4l2loopback-dc
fi
if ! modinfo videodev; then
sudo modprobe videodev
fi
if ! modinfo snd_aloop; then
sudo modprobe snd_aloop
fi
${binaryfile} &
pacmd load-module module-alsa-source device=hw:Loopback,1,0
wait
'';
in
stdenv.mkDerivation rec {
pname = "droidcam";
version = "1.5";
src = fetchFromGitHub {
owner = "aramg";
repo = "droidcam";
rev = "v1.5";
sha256 = "tIb7wqzAjSHoT9169NiUO+z6w5DrJVYvkQ3OxDqI1DA=";
};
sourceRoot = "source/linux";
buildInputs = [ pkgconfig ];
nativeBuildInputs = [ libappindicator-gtk3 speex libav gtk3 libjpeg_turbo libusbmuxd libplist alsaLib ];
makeFlags = [ "JPEG_DIR=${libjpeg_turbo.out}" "JPEG_LIB=${libjpeg_turbo.out}/lib" ];
postPatch = ''
sed -i -e 's:(JPEG_LIB)/libturbojpeg.a:(JPEG_LIB)/libturbojpeg.so:' Makefile
substituteInPlace src/droidcam.c --replace "/opt/droidcam-icon.png" "$out/share/icons/hicolor/droidcam.png"
'';
installPhase = ''
# Copy the executables in the bin folder, creating automatically the subfolders
install -Dt $out/bin droidcam droidcam-cli (myWrapper "${out}/bin/droidcam")
# Same for pictures
install -D icon2.png $out/share/icons/hicolor/droidcam.png
'';
meta = with stdenv.lib; {
description = "DroidCam Linux client";
homepage = https://github.com/aramg/droidcam;
};
}