From fa88755137f1b455e92d5540a46ae6bb45f1e8e9 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Fri, 20 Sep 2024 21:42:08 +0100 Subject: [PATCH] Fix mail and Git repo syncing on darwin (#79) --- darwin-configuration.nix | 19 +++++++++++++++---- home-manager/modules/mail.nix | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/darwin-configuration.nix b/darwin-configuration.nix index 12f4624..2dc45b6 100644 --- a/darwin-configuration.nix +++ b/darwin-configuration.nix @@ -53,13 +53,14 @@ in { serviceConfig = { KeepAlive = false; UserName = "patrick"; - StartInterval = 60; + # Refresh token is 60min long, so do this more often than that! + StartInterval = 30; RunAtLoad = true; }; }; backup-calendar = { - command = ''${pkgs.bash}/bin/bash -c "mkdir -p /Users/patrick/Backups && if [ ! -d /Users/patrick/Backups/radicale ] ; then ${pkgs.git}/bin/git clone root@patrickstevens.co.uk:/preserve/radicale/data/.git /Users/patrick/Backups/radicale >/tmp/radicale.out.log 2>/tmp/radicale.err.log; fi && ${pkgs.git}/bin/git --git-dir /Users/patrick/Backups/radicale/.git pull 2>>/tmp/radicale.err.log"''; + command = ''${pkgs.bash}/bin/bash -c "mkdir -p '/Users/patrick/Library/Application Support/RadicaleBackups' && if [ ! -d '/Users/patrick/Library/Application Support/RadicaleBackups/.git' ] ; then ${pkgs.git}/bin/git clone root@patrickstevens.co.uk:/preserve/radicale/data/.git '/Users/patrick/Library/Application Support/RadicaleBackups' >/tmp/radicale.out.log 2>/tmp/radicale.err.log; fi && ${pkgs.git}/bin/git --git-dir '/Users/patrick/Library/Application Support/RadicaleBackups/.git' --work-tree '/Users/patrick/Library/Application Support/RadicaleBackups/' pull 2>>/tmp/radicale.err.log"''; serviceConfig = { KeepAlive = false; UserName = "patrick"; @@ -69,7 +70,7 @@ in { }; sync-nixpkgs = { - command = ''${pkgs.bash}/bin/bash -c "if [ -d /Users/patrick/Documents/GitHub/nixpkgs ] ; then ${pkgs.git}/bin/git --git-dir /Users/patrick/Documents/GitHub/nixpkgs/.git fetch origin ; fi"''; + command = ''${pkgs.bash}/bin/bash -c "if [ -d /Users/patrick/Documents/GitHub/nixpkgs ] ; then ${pkgs.git}/bin/git --git-dir /Users/patrick/Documents/GitHub/nixpkgs/.git --work-tree '/Users/patrick/Documents/GitHub/nixpkgs/' fetch origin ; fi"''; serviceConfig = { KeepAlive = false; UserName = "patrick"; @@ -79,7 +80,17 @@ in { }; sync-dotnet-api-docs = { - command = ''${pkgs.bash}/bin/bash -c "if [ -d /Users/patrick/Documents/GitHub/dotnet-api-docs ] ; then ${pkgs.git}/bin/git --git-dir /Users/patrick/Documents/GitHub/dotnet-api-docs/.git fetch origin ; fi"''; + command = ''${pkgs.bash}/bin/bash -c "if [ -d /Users/patrick/Documents/GitHub/dotnet-api-docs ] ; then ${pkgs.git}/bin/git --git-dir /Users/patrick/Documents/GitHub/dotnet-api-docs/.git --work-tree '/Users/patrick/Documents/GitHub/dotnet-api-docs' fetch origin ; fi"''; + serviceConfig = { + KeepAlive = false; + UserName = "patrick"; + StartInterval = 36000; + RunAtLoad = true; + }; + }; + + sync-dotnet-docs = { + command = ''${pkgs.bash}/bin/bash -c "if [ -d /Users/patrick/Documents/GitHub/dotnet-docs ] ; then ${pkgs.git}/bin/git --git-dir /Users/patrick/Documents/GitHub/dotnet-docs/.git --work-tree '/Users/patrick/Documents/GitHub/dotnet-docs' fetch origin ; fi"''; serviceConfig = { KeepAlive = false; UserName = "patrick"; diff --git a/home-manager/modules/mail.nix b/home-manager/modules/mail.nix index 1f9c8b0..5e07a14 100644 --- a/home-manager/modules/mail.nix +++ b/home-manager/modules/mail.nix @@ -75,7 +75,7 @@ in { # Run `./mail/mutt-oauth2.py /path/to/secret --authorize --verbose` once manually, # and that will populate /path/to/secret. # I've left it unencrypted here; the original uses GPG to store it encrypted at rest. - passwordCommand = ''${pkgs.python3}/bin/python ${./mail/mutt-oauth2.py} ${secretsPath}/gmail.txt''; + passwordCommand = ''${pkgs.python3}/bin/python ${./mail/mutt-oauth2.py} ${secretsPath}/gmail.txt 2>/tmp/gmail-passcmd.2.txt''; realName = "Patrick Stevens"; };