From de6329de4cc86549d1e18fa46b1c5aeea8245b81 Mon Sep 17 00:00:00 2001 From: Grigory Shipunov Date: Mon, 1 May 2023 05:58:55 +0200 Subject: [PATCH] add borken-data-hoarder microvm --- hosts/server10/microvm-staging.nix | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hosts/server10/microvm-staging.nix b/hosts/server10/microvm-staging.nix index 418fed71..236ee8e4 100644 --- a/hosts/server10/microvm-staging.nix +++ b/hosts/server10/microvm-staging.nix @@ -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}" = {