mirror of
https://github.com/JaxTheWolf/nixos.git
synced 2026-03-31 17:50:23 +02:00
Actually add /etc/nix as well
This commit is contained in:
@@ -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"];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user