Fix maintenance script
This commit is contained in:
parent
79f5d05b4f
commit
7f741aeef8
2 changed files with 18 additions and 8 deletions
|
@ -1,11 +1,26 @@
|
||||||
{ pkgs, config, ... }:
|
{ 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 = {
|
systemd.user = {
|
||||||
services.maintenance = {
|
services.maintenance = {
|
||||||
Unit.Description = "Routine maintenance";
|
Unit.Description = "Routine maintenance";
|
||||||
Service = {
|
Service = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.kitty}/bin/kitty --hold ${config.home.profileDirectory}/bin/maintenance --only-on-update";
|
ExecStart = toString script;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
timers.maintenance = {
|
timers.maintenance = {
|
||||||
|
|
|
@ -2,9 +2,9 @@ opts: { pkgs, lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.m-0) hostName;
|
inherit (config.m-0) hostName;
|
||||||
modes = pkgs.lib.attrNames (import ../machines.nix).${hostName};
|
modes = pkgs.lib.attrNames (import ../machines.nix).${hostName};
|
||||||
configPath = "${config.home.homeDirectory}/git/config";
|
|
||||||
modeFile = "${config.home.homeDirectory}/${opts.modeFile}";
|
modeFile = "${config.home.homeDirectory}/${opts.modeFile}";
|
||||||
modeDir = "${config.home.homeDirectory}/${opts.modeDir}";
|
modeDir = "${config.home.homeDirectory}/${opts.modeDir}";
|
||||||
|
configPath = "${config.home.homeDirectory}/git/config";
|
||||||
configGit = "${pkgs.git}/bin/git -C ${configPath}";
|
configGit = "${pkgs.git}/bin/git -C ${configPath}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -12,12 +12,7 @@ in
|
||||||
home.packages = builtins.attrValues rec {
|
home.packages = builtins.attrValues rec {
|
||||||
maintenance = pkgs.writeShellScriptBin "maintenance" ''
|
maintenance = pkgs.writeShellScriptBin "maintenance" ''
|
||||||
set -e
|
set -e
|
||||||
${configGit} fetch
|
${configGit} pull --ff-only
|
||||||
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} submodule update
|
${configGit} submodule update
|
||||||
${updateModes}/bin/update-modes
|
${updateModes}/bin/update-modes
|
||||||
/run/wrappers/bin/sudo -A /run/current-system/sw/bin/update-system
|
/run/wrappers/bin/sudo -A /run/current-system/sw/bin/update-system
|
||||||
|
|
Loading…
Reference in a new issue