1
0
Fork 0
selfhostblocks/_disnix/ttrss/dbupgrade.nix

53 lines
850 B
Nix
Raw Normal View History

{ stdenv
, pkgs
}:
2023-01-17 06:39:20 +01:00
{ name
, user
2023-01-17 06:39:20 +01:00
, binDir
, dependsOn ? {}
}:
2023-01-17 06:39:20 +01:00
{
inherit name;
pkg =
{ db
, config
}:
stdenv.mkDerivation {
name = "dbupgrade";
src = pkgs.writeTextDir "wrapper" ''
#!/bin/bash -e
2023-01-17 06:39:20 +01:00
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
'';
2023-01-17 06:39:20 +01:00
installPhase = ''
mkdir -p $out/bin
cp $src/wrapper $out/bin
chmod +x $out/bin/*
'';
};
2023-01-17 06:39:20 +01:00
inherit dependsOn;
type = "wrapper";
}