diff --git a/Justfile b/Justfile index b6ff1ab..0c7b613 100644 --- a/Justfile +++ b/Justfile @@ -23,7 +23,7 @@ format: treefmt . switch: - nh os switch + nh os switch --refresh switch_update: nh os switch --refresh --update diff --git a/common/modules/home/default.nix b/common/modules/home/default.nix index 0b7fad3..6901bae 100644 --- a/common/modules/home/default.nix +++ b/common/modules/home/default.nix @@ -3,6 +3,7 @@ ./dconf ./desktop-files.nix ./starship.nix + ./services.nix ./zsh.nix ]; diff --git a/common/modules/home/services.nix b/common/modules/home/services.nix new file mode 100644 index 0000000..e156ad4 --- /dev/null +++ b/common/modules/home/services.nix @@ -0,0 +1,39 @@ +{pkgs, ...}: { + systemd.user.services.sync-dev-shells = { + Unit = { + Description = "Background sync for Nix dev shells repository"; + 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.' \ + " + ''; + + PassEnvironment = ["DBUS_SESSION_BUS_ADDRESS" "DISPLAY"]; + }; + }; + + systemd.user.timers.sync-dev-shells = { + Unit = { + Description = "Check for dev shell updates every hour"; + }; + + Timer = { + OnBootSec = "2m"; + OnUnitActiveSec = "1h"; + Persistent = true; + }; + + Install = { + WantedBy = ["timers.target"]; + }; + }; +} diff --git a/flake.lock b/flake.lock index cf2c6cb..147cce1 100644 --- a/flake.lock +++ b/flake.lock @@ -95,11 +95,11 @@ ] }, "locked": { - "lastModified": 1774539458, - "narHash": "sha256-H9GIOqdMfQZ6lFetsQhO9TCq53hYzpTHDWOt3PRh9V0=", + "lastModified": 1774626137, + "narHash": "sha256-1WelwA45Xm4glTG8R9IX9jYeFKDG2HbR79jAauLezUE=", "owner": "nix-community", "repo": "home-manager", - "rev": "e2e5f512b33ed19a7a3271d0b73ed5eefcc0be5f", + "rev": "9df3a639007cfe0d074433f7fc225ea94f877d08", "type": "github" }, "original": { @@ -179,11 +179,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1774509978, - "narHash": "sha256-hdl5+yPF2KXSpuFy6dTHe62c5hKiEAhd1fq8UagtTdQ=", + "lastModified": 1774612448, + "narHash": "sha256-+uVDNwxihd82I6aZTgNvIXqFyLcfUBkg/Y0A8UBgycg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b317a7eaabaea07be8c71aded8b266fddce0a181", + "rev": "b55b0e0c856ac73c7f507336780f97aa7a9746e2", "type": "github" }, "original": {