From c03246f53160aa858a24ca7dd723ffe853618ddf Mon Sep 17 00:00:00 2001
From: zowoq <59103226+zowoq@users.noreply.github.com>
Date: Mon, 22 Jan 2024 13:07:47 +1000
Subject: [PATCH] add `wants` to services using `network-online.target`

https://github.com/NixOS/nixpkgs/commit/c2853e2588b6f45279884740ef8bc4fe77a633f3
---
 hosts/build02/nixpkgs-update.nix         | 3 +++
 modules/nixos/monitoring/matrix-hook.nix | 1 +
 modules/nixos/monitoring/prometheus.nix  | 1 +
 3 files changed, 5 insertions(+)

diff --git a/hosts/build02/nixpkgs-update.nix b/hosts/build02/nixpkgs-update.nix
index 4869931..8ef5cb9 100644
--- a/hosts/build02/nixpkgs-update.nix
+++ b/hosts/build02/nixpkgs-update.nix
@@ -21,6 +21,7 @@ let
 
   mkWorker = name: {
     after = [ "network-online.target" "nixpkgs-update-supervisor.service" ];
+    wants = [ "network-online.target" ];
     wantedBy = [ "multi-user.target" ];
     description = "nixpkgs-update ${name} service";
     enable = true;
@@ -105,6 +106,7 @@ let
 
   mkFetcher = name: cmd: {
     after = [ "network-online.target" ];
+    wants = [ "network-online.target" ];
     wantedBy = [ "multi-user.target" ];
     path = nixpkgsUpdateSystemDependencies;
     # API_TOKEN is used by nixpkgs-update-github-releases
@@ -159,6 +161,7 @@ in
   systemd.services.nixpkgs-update-delete-done = {
     startAt = "daily";
     after = [ "network-online.target" ];
+    wants = [ "network-online.target" ];
     wantedBy = [ "multi-user.target" ];
     description = "nixpkgs-update delete done branches";
     restartIfChanged = true;
diff --git a/modules/nixos/monitoring/matrix-hook.nix b/modules/nixos/monitoring/matrix-hook.nix
index 362c366..bf4be53 100644
--- a/modules/nixos/monitoring/matrix-hook.nix
+++ b/modules/nixos/monitoring/matrix-hook.nix
@@ -14,6 +14,7 @@ in
   systemd.services.matrix-hook = {
     description = "Matrix Hook";
     after = [ "network-online.target" ];
+    wants = [ "network-online.target" ];
     wantedBy = [ "multi-user.target" ];
     environment = {
       HTTP_ADDRESS = "localhost";
diff --git a/modules/nixos/monitoring/prometheus.nix b/modules/nixos/monitoring/prometheus.nix
index 5f6441a..0cd524d 100644
--- a/modules/nixos/monitoring/prometheus.nix
+++ b/modules/nixos/monitoring/prometheus.nix
@@ -1,6 +1,7 @@
 { pkgs, ... }:
 {
   systemd.services.prometheus.after = pkgs.lib.mkForce [ "network-online.target" ];
+  systemd.services.prometheus.wants = [ "network-online.target" ];
   systemd.services.alertmanager.after = [ "prometheus.service" ];
 
   services.prometheus = {