Actually add /etc/nix as well

This commit is contained in:
2026-03-27 19:32:51 +01:00
parent 0a07190179
commit 599be0b0e5

View File

@@ -1,39 +1,41 @@
{pkgs, ...}: { {pkgs, ...}: let
systemd.user.services.sync-dev-shells = { devShellsDir = "$HOME/.config/nix-shells";
nixConfigDir = "/etc/nixos";
syncScript = pkgs.writeShellScript "sync-all-repos" ''
repos=("${devShellsDir}" "${nixConfigDir}")
for repo in "''${repos[@]}"; do
echo "Syncing $repo..."
if ! ${pkgs.git}/bin/git -C "$repo" pull --rebase --autostash; then
${pkgs.libnotify}/bin/notify-send -u critical "Sync Failed" "Conflict or network error in $repo"
else
${pkgs.git}/bin/git -C "$repo" add -N . 2>/dev/null || true
fi
done
'';
in {
systemd.user.services.sync-nix-repos = {
Unit = { Unit = {
Description = "Background sync for Nix dev shells repository"; Description = "Background sync for Nix Config and Dev Shells";
After = ["network-online.target"]; After = ["network-online.target"];
Wants = ["network-online.target"]; Wants = ["network-online.target"];
}; };
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
WorkingDirectory = "%h/.config/nix-shells"; ExecStart = "${syncScript}";
ExecStart = ''
${pkgs.bash}/bin/bash -c " \
${pkgs.git}/bin/git pull --rebase --autostash || \
${pkgs.libnotify}/bin/notify-send -u critical 'Sync Failed' 'Nix dev shells encountered a git conflict or network error.' \
"
'';
PassEnvironment = ["DBUS_SESSION_BUS_ADDRESS" "DISPLAY"]; PassEnvironment = ["DBUS_SESSION_BUS_ADDRESS" "DISPLAY"];
}; };
}; };
systemd.user.timers.sync-dev-shells = { systemd.user.timers.sync-nix-repos = {
Unit = { Unit.Description = "Hourly sync for all Nix repositories";
Description = "Check for dev shell updates every hour";
};
Timer = { Timer = {
OnBootSec = "2m"; OnBootSec = "2m";
OnUnitActiveSec = "1h"; OnUnitActiveSec = "1h";
Persistent = true; Persistent = true;
}; };
Install.WantedBy = ["timers.target"];
Install = {
WantedBy = ["timers.target"];
};
}; };
} }