1
0
Fork 0

Fetch based system update

This commit is contained in:
Malte 2023-03-17 15:52:57 +01:00
parent e1e679a4ab
commit e21663c8e3
3 changed files with 12 additions and 4 deletions

View file

@ -58,6 +58,7 @@ let
++ [
(makeAutostart "kassandra2")
(makeAutostart "unlock-ssh")
./roles/refresh-config.nix
./roles/firefox.nix
./roles/kassandra.nix
./roles/mode-switching.nix
@ -138,7 +139,6 @@ in {
./roles/untrusted-env.nix
];
zeus = daily-driver "zeus" [
./roles/hourly-maintenance.nix
(import ./roles/state.nix "orga")
./roles/trusted-env.nix
./roles/monitor-config

View file

@ -8,10 +8,10 @@
in {
systemd.user = {
services.update-config = {
Unit.Description = "Routine maintenance";
Unit.Description = "Fetch config repo";
Service = {
Type = "oneshot";
ExecStart = "${configGit} pull --ff-only";
ExecStart = "${configGit} fetch origin main";
};
};
timers.update-config = {

View file

@ -7,6 +7,7 @@ import Control.Exception (catch, onException)
import Control.Exception qualified as Exception
import Data.ByteString.Char8 qualified as ByteString
import Data.ByteString.Lazy qualified as LBS
import Data.ByteString.Lazy.Char8 qualified as LBSC
import Data.String.Interpolate (i)
import Data.Text qualified as Text
import Data.Time qualified as Time
@ -214,7 +215,14 @@ main = do
, simpleModule (5 * oneSecond) $ do
current_kernel <- readlink "/run/current-system/kernel" |> captureTrim
booted_kernel <- readlink "/run/booted-system/kernel" |> captureTrim
when' (current_kernel /= booted_kernel) $ withColor "ffff00" "Booted kernel stale"
when' (current_kernel /= booted_kernel) $ withColor yellow "Booted kernel stale"
, simpleModule (5 * oneSecond) $ do
mode <- read_mode
behind <-
if mode /= Klausur
then tryCmd (git "--no-optional-locks" "-C" git_dir "log" "--oneline" "origin/main" "^main")
else pure ""
when' (not $ LBS.null behind) $ withColor yellow [i|Config #{show (length (LBSC.lines behind))} commits behind.|]
, \var -> do
commit_var <- newTVarIO ""
system_var <- newTVarIO ""