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, ...}: {
systemd.user.services.sync-dev-shells = {
{pkgs, ...}: let
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 = {
Description = "Background sync for Nix dev shells repository";
Description = "Background sync for Nix Config and Dev Shells";
After = ["network-online.target"];
Wants = ["network-online.target"];
};
Service = {
Type = "oneshot";
WorkingDirectory = "%h/.config/nix-shells";
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.' \
"
'';
ExecStart = "${syncScript}";
PassEnvironment = ["DBUS_SESSION_BUS_ADDRESS" "DISPLAY"];
};
};
systemd.user.timers.sync-dev-shells = {
Unit = {
Description = "Check for dev shell updates every hour";
};
systemd.user.timers.sync-nix-repos = {
Unit.Description = "Hourly sync for all Nix repositories";
Timer = {
OnBootSec = "2m";
OnUnitActiveSec = "1h";
Persistent = true;
};
Install = {
WantedBy = ["timers.target"];
};
Install.WantedBy = ["timers.target"];
};
}