-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-sync.nix
More file actions
40 lines (39 loc) · 1.18 KB
/
git-sync.nix
File metadata and controls
40 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{config, pkgs, ...}: {
systemd.user.services.git-pull-home-manager = {
Unit = {
Description = "Git pull for home-manager repository";
After = [ "network-online.target" ];
};
Service = {
Type = "oneshot";
ExecStart =
let
script = pkgs.writeShellScript "git-pull-notify" ''
set -eu
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
cd "${config.home.homeDirectory}/.config/home-manager"
OLD_HEAD=$(${pkgs.git}/bin/git rev-parse HEAD)
${pkgs.git}/bin/git pull
NEW_HEAD=$(${pkgs.git}/bin/git rev-parse HEAD)
if [ "$OLD_HEAD" != "$NEW_HEAD" ]; then
${pkgs.libnotify}/bin/notify-send "Home Manager" "Configuration updated. Run home-manager switch."
fi
'';
in
"${script}";
};
};
systemd.user.timers.git-pull-home-manager = {
Unit = {
Description = "Timer for git-pull-home-manager service";
};
Timer = {
OnBootSec = "5m";
OnUnitActiveSec = "12h"; # 43200 seconds
};
Install = {
WantedBy = [ "timers.target" ];
};
};
}