Skip to content

Commit

Permalink
use systemd unit name attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Nov 14, 2024
1 parent df68047 commit 6ee4a1c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
18 changes: 9 additions & 9 deletions hosts/build02/nixpkgs-update.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ let

mkWorker = name: {
after = [
"network-online.target"
"nixpkgs-update-supervisor.service"
config.systemd.targets.network-online.name
config.systemd.services.nixpkgs-update-supervisor.name
];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
wants = [ config.systemd.targets.network-online.name ];
wantedBy = [ config.systemd.targets.multi-user.name ];
description = "nixpkgs-update ${name} service";
enable = true;
restartIfChanged = true;
Expand Down Expand Up @@ -63,8 +63,8 @@ let
};

mkFetcher = name: cmd: {
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
after = [ config.systemd.targets.network-online.name ];
wants = [ config.systemd.targets.network-online.name ];
path = nixpkgsUpdateSystemDependencies ++ [
# nixpkgs-update-github-releases
(pkgs.python3.withPackages (
Expand Down Expand Up @@ -121,8 +121,8 @@ in

systemd.services.nixpkgs-update-delete-done = {
startAt = "0/12:10"; # every 12 hours
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
after = [ config.systemd.targets.network-online.name ];
wants = [ config.systemd.targets.network-online.name ];
description = "nixpkgs-update delete done branches";
restartIfChanged = true;
path = nixpkgsUpdateSystemDependencies;
Expand Down Expand Up @@ -160,7 +160,7 @@ in
# Too many workers cause out-of-memory.

systemd.services.nixpkgs-update-supervisor = {
wantedBy = [ "multi-user.target" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
description = "nixpkgs-update supervisor service";
enable = true;
restartIfChanged = true;
Expand Down
11 changes: 8 additions & 3 deletions hosts/web02/gandi.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# This is the configuration required to run NixOS on GandiCloud.
{ lib, modulesPath, ... }:
{
config,
lib,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/virtualisation/openstack-config.nix") ];
config = {
Expand All @@ -21,7 +26,7 @@
boot.kernelParams = [ "console=ttyS0" ];
systemd.services."serial-getty@ttyS0" = {
enable = true;
wantedBy = [ "multi-user.target" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
serviceConfig.Restart = "always";
};

Expand All @@ -31,7 +36,7 @@
# This is to get a prompt via the "openstack console url show" command
systemd.services."getty@tty1" = {
enable = lib.mkForce true;
wantedBy = [ "multi-user.target" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
serviceConfig.Restart = "always";
};

Expand Down
6 changes: 3 additions & 3 deletions modules/nixos/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
Type = "oneshot";
TimeoutStartSec = "60";
};
wantedBy = [ "multi-user.target" ];
after = [ "hydra-server.service" ];
requires = [ "hydra-server.service" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
after = [ config.systemd.services.hydra-server.name ];
requires = [ config.systemd.services.hydra-server.name ];
environment = {
inherit (config.systemd.services.hydra-init.environment) HYDRA_DBI;
};
Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/monitoring/grafana.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
...
}:
{
systemd.services.grafana.after = [ "prometheus.service" ];
systemd.services.grafana.after = [ config.systemd.services.prometheus.name ];

age.secrets.grafana-client-secret = {
file = "${inputs.self}/secrets/grafana-client-secret.age";
Expand Down
6 changes: 3 additions & 3 deletions modules/nixos/monitoring/matrix-hook.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ in

systemd.services.matrix-hook = {
description = "Matrix Hook";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
after = [ config.systemd.targets.network-online.name ];
wants = [ config.systemd.targets.network-online.name ];
wantedBy = [ config.systemd.targets.multi-user.name ];
environment = {
HTTP_ADDRESS = "localhost";
HTTP_PORT = "9088";
Expand Down
13 changes: 9 additions & 4 deletions modules/nixos/monitoring/prometheus.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{ inputs, pkgs, ... }:
{
systemd.services.prometheus.after = pkgs.lib.mkForce [ "network-online.target" ];
systemd.services.prometheus.wants = [ "network-online.target" ];
systemd.services.alertmanager.after = [ "prometheus.service" ];
config,
inputs,
pkgs,
...
}:
{
systemd.services.prometheus.after = pkgs.lib.mkForce [ config.systemd.targets.network-online.name ];
systemd.services.prometheus.wants = [ config.systemd.targets.network-online.name ];
systemd.services.alertmanager.after = [ config.systemd.services.prometheus.name ];

services.prometheus = {
enable = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/nur-update.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
Restart = "always";
RuntimeDirectory = "nur-update";
};
wantedBy = [ "multi-user.target" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
};
}

0 comments on commit 6ee4a1c

Please sign in to comment.