add borken-data-hoarder microvm

This commit is contained in:
oxapentane - 2023-05-01 05:58:55 +02:00
parent 0401d57e33
commit de6329de4c
Signed by: oxapentane
GPG Key ID: 91FA5E5BF9AA901C
1 changed files with 37 additions and 0 deletions

View File

@ -2,7 +2,42 @@
let
microvms = {
staging-data-hoarder.flakeref = "git+https://github.com/tlm-solutions/nix-config";
borken-data-hoarder.flakeref = "git+file:///tmp/dump-dvb-borken";
};
realizeFlake = with pkgs; "${writeScriptBin "realize-flake" ''
#! ${runtimeShell} -e
NAME=$1
if [ $NAME = "borken-data-hoarder" ]; then
SRC_NIX_CONFIG=https://github.com/dump-dvb/nix-config.git
BRANCH=borken
DIR_NIX_CONFIG=dump-dvb-borken
elif [ $NAME = "staging-data-hoarder" ]; then
echo "staging-data-hoarder: no need for flake magic"
echo "Deploying staging-data-hoarder from github"
exit 0
else
echo "Do not know what to do"
exit 0
fi
cd /tmp
if [ -d $DIR_DUMP_DVB ]; then
cd $DIR_NIX_CONFG
git fetch origin
git reset --hard origin/$BRANCH
else
git clone -b $BRANCH --single-branch $SRC_NIX_CONFIG $DIR_NIX_CONFIG
cd $DIR_NIX_CONFIG
fi
git config user.email "grisha@tlm.solutions"
git config user.name "Flake McUpdater"
nix flake update --commit-lock-file
''}/bin/realize-flake";
in
{
microvm.autostart = builtins.attrNames microvms;
@ -21,6 +56,7 @@ in
scriptArgs = "%i";
script = ''
NAME=$1
${realizeFlake} $NAME
/run/current-system/sw/bin/microvm -Ru $NAME
'';
};
@ -44,6 +80,7 @@ in
'';
};
}) {} (builtins.attrNames microvms);
${realizeFlake} ${name}
systemd.timers = builtins.foldl' (timers: name: timers // {
"microvm-update-${name}" = {