1
0
Fork 0
selfhostblocks/ttrss/dbupgrade.nix
2023-02-19 20:37:52 -08:00

52 lines
850 B
Nix

{ stdenv
, pkgs
}:
{ name
, user
, binDir
, dependsOn ? {}
}:
{
inherit name;
pkg =
{ db
, config
}:
stdenv.mkDerivation {
name = "dbupgrade";
src = pkgs.writeTextDir "wrapper" ''
#!/bin/bash -e
sudo -u ${user} bash <<HERE
case "$1" in
activate)
${pkgs.php}/bin/php ${binDir}/update.php --update-schema=force-yes
;;
lock)
if [ -f /tmp/wrapper.lock ]
then
exit 1
else
echo "1" > /tmp/wrapper.lock
fi
;;
unlock)
rm -f /tmp/wrapper.lock
;;
esac
HERE
'';
installPhase = ''
mkdir -p $out/bin
cp $src/wrapper $out/bin
chmod +x $out/bin/*
'';
};
inherit dependsOn;
type = "wrapper";
}