use systemd unit name attribute

This commit is contained in:
zowoq 2024-11-09 21:49:54 +10:00
parent df68047ea9
commit 6ee4a1c4d5
7 changed files with 34 additions and 24 deletions

View file

@ -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;
@ -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 (
@ -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;
@ -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;

View file

@ -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 = {
@ -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";
};
@ -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";
};

View file

@ -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;
};

View file

@ -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";

View file

@ -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";

View file

@ -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;

View file

@ -37,6 +37,6 @@
Restart = "always";
RuntimeDirectory = "nur-update";
};
wantedBy = [ "multi-user.target" ];
wantedBy = [ config.systemd.targets.multi-user.name ];
};
}