From 03b1edc941fc4a707d527cb3e147a9c59aa36794 Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Mon, 22 May 2023 21:58:12 +1000 Subject: [PATCH] make kitaab update a user unit, use user path --- home/gui/default.nix | 1 + home/profiles/cli/default.nix | 1 + home/profiles/sync/kitaab/default.nix | 32 ++++++++++++++++++++++++++ hosts/curve/default.nix | 1 - hosts/profiles/sync/kitaab/default.nix | 27 ---------------------- 5 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 home/profiles/sync/kitaab/default.nix delete mode 100644 hosts/profiles/sync/kitaab/default.nix diff --git a/home/gui/default.nix b/home/gui/default.nix index 8f150bda..9392441b 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -6,5 +6,6 @@ ../profiles/desktop ../profiles/email ../profiles/cal + ../profiles/sync/kitaab ]; } diff --git a/home/profiles/cli/default.nix b/home/profiles/cli/default.nix index 6d74512f..07dbb910 100644 --- a/home/profiles/cli/default.nix +++ b/home/profiles/cli/default.nix @@ -59,6 +59,7 @@ pandoc taskwarrior-tui python3Packages.howdoi + vimwiki-cli (pkgs.writeScriptBin "jq-repl" '' #!/usr/bin/env bash diff --git a/home/profiles/sync/kitaab/default.nix b/home/profiles/sync/kitaab/default.nix new file mode 100644 index 00000000..2e6c588b --- /dev/null +++ b/home/profiles/sync/kitaab/default.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +let + name = "kitaab-sync"; + # Note this will fail if index.wiki is open in vim while this runs + mkStartScript = name: pkgs.writeShellScript "${name}.sh" '' + set -euo pipefail + PATH=/run/current-system/sw/bin:/etc/profiles/per-user/anish/bin: + cd /home/anish/kitaab + vimwiki tags rebuild + git add -A + git diff-index --quiet HEAD || git commit -m 'syncing kitaab' # if nothing, don't exit 1 + git push + exit 0 + ''; +in +{ + systemd.user.services.kitaab-sync = { + Service = { + ExecStart = "${mkStartScript name}"; + }; + }; + systemd.user.timers.kitaab-sync = { + Install = { + WantedBy = [ "timers.target" ]; + PartOf = [ "kitaab-sync.service" ]; + }; + Timer = { + OnCalendar = [ "hourly" ]; + }; + }; +} diff --git a/hosts/curve/default.nix b/hosts/curve/default.nix index 8b2915f2..4450028d 100644 --- a/hosts/curve/default.nix +++ b/hosts/curve/default.nix @@ -6,7 +6,6 @@ ../profiles/core ../profiles/bluetooth ../profiles/music - ../profiles/sync/kitaab ../profiles/sync/cal ../profiles/wifi ../profiles/desktop diff --git a/hosts/profiles/sync/kitaab/default.nix b/hosts/profiles/sync/kitaab/default.nix deleted file mode 100644 index 5a24bd3b..00000000 --- a/hosts/profiles/sync/kitaab/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs, ... }: - -{ - systemd.services.kitaab-sync = { - serviceConfig.Type = "oneshot"; - path = [ - pkgs.git - pkgs.openssh - pkgs.coreutils - ]; - script = '' - cd /home/anish/kitaab - git add -A - git diff-index --quiet HEAD || git commit -m 'syncing kitaab' # if nothing, don't exit 1 - git push - exit 0 - ''; - serviceConfig = { - User = "anish"; - }; - }; - systemd.timers.kitaab-sync = { - wantedBy = [ "timers.target" ]; - partOf = [ "kitaab-sync.service" ]; - timerConfig.OnCalendar = [ "hourly" ]; - }; -}