Fix maintenance script
This commit is contained in:
parent
79f5d05b4f
commit
7f741aeef8
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue