1
0
Fork 0

Fix maintenance script

This commit is contained in:
Malte Brandy 2021-07-09 13:39:48 +02:00
parent 79f5d05b4f
commit 7f741aeef8
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
2 changed files with 18 additions and 8 deletions

View file

@ -1,11 +1,26 @@
{ pkgs, config, ... }:
let
configPath = "${config.home.homeDirectory}/git/config";
configGit = "${pkgs.git}/bin/git -C ${configPath}";
script = pkgs.writeShellScript "hourly-maintenance" ''
set -e
${configGit} fetch
if [[ "$(${configGit} rev-parse master)" == "$(${configGit} rev-parse origin/master)" ]]; then
echo "Git repo up-to-date, not doing anything."
exit 0;
else
${pkgs.kitty}/bin/kitty --hold ${config.home.profileDirectory}/bin/maintenance
fi
'';
in
{
systemd.user = {
services.maintenance = {
Unit.Description = "Routine maintenance";
Service = {
Type = "oneshot";
ExecStart = "${pkgs.kitty}/bin/kitty --hold ${config.home.profileDirectory}/bin/maintenance --only-on-update";
ExecStart = toString script;
};
};
timers.maintenance = {

View file

@ -2,9 +2,9 @@ opts: { pkgs, lib, config, ... }:
let
inherit (config.m-0) hostName;
modes = pkgs.lib.attrNames (import ../machines.nix).${hostName};
configPath = "${config.home.homeDirectory}/git/config";
modeFile = "${config.home.homeDirectory}/${opts.modeFile}";
modeDir = "${config.home.homeDirectory}/${opts.modeDir}";
configPath = "${config.home.homeDirectory}/git/config";
configGit = "${pkgs.git}/bin/git -C ${configPath}";
in
{
@ -12,12 +12,7 @@ in
home.packages = builtins.attrValues rec {
maintenance = pkgs.writeShellScriptBin "maintenance" ''
set -e
${configGit} fetch
if [[ "$1" == "--only-on-update" && "$(${configGit} rev-parse master)" == "$(${configGit} rev-parse origin/master)" ]]; then
echo "Git repo up-to-date, not doing anything."
exit 0;
fi
${configGit} merge --ff-only origin/master master
${configGit} pull --ff-only
${configGit} submodule update
${updateModes}/bin/update-modes
/run/wrappers/bin/sudo -A /run/current-system/sw/bin/update-system