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: { mkWorker = name: {
after = [ after = [
"network-online.target" config.systemd.targets.network-online.name
"nixpkgs-update-supervisor.service" config.systemd.services.nixpkgs-update-supervisor.name
]; ];
wants = [ "network-online.target" ]; wants = [ config.systemd.targets.network-online.name ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
description = "nixpkgs-update ${name} service"; description = "nixpkgs-update ${name} service";
enable = true; enable = true;
restartIfChanged = true; restartIfChanged = true;
@ -63,8 +63,8 @@ let
}; };
mkFetcher = name: cmd: { mkFetcher = name: cmd: {
after = [ "network-online.target" ]; after = [ config.systemd.targets.network-online.name ];
wants = [ "network-online.target" ]; wants = [ config.systemd.targets.network-online.name ];
path = nixpkgsUpdateSystemDependencies ++ [ path = nixpkgsUpdateSystemDependencies ++ [
# nixpkgs-update-github-releases # nixpkgs-update-github-releases
(pkgs.python3.withPackages ( (pkgs.python3.withPackages (
@ -121,8 +121,8 @@ in
systemd.services.nixpkgs-update-delete-done = { systemd.services.nixpkgs-update-delete-done = {
startAt = "0/12:10"; # every 12 hours startAt = "0/12:10"; # every 12 hours
after = [ "network-online.target" ]; after = [ config.systemd.targets.network-online.name ];
wants = [ "network-online.target" ]; wants = [ config.systemd.targets.network-online.name ];
description = "nixpkgs-update delete done branches"; description = "nixpkgs-update delete done branches";
restartIfChanged = true; restartIfChanged = true;
path = nixpkgsUpdateSystemDependencies; path = nixpkgsUpdateSystemDependencies;
@ -160,7 +160,7 @@ in
# Too many workers cause out-of-memory. # Too many workers cause out-of-memory.
systemd.services.nixpkgs-update-supervisor = { systemd.services.nixpkgs-update-supervisor = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
description = "nixpkgs-update supervisor service"; description = "nixpkgs-update supervisor service";
enable = true; enable = true;
restartIfChanged = true; restartIfChanged = true;

View file

@ -1,5 +1,10 @@
# This is the configuration required to run NixOS on GandiCloud. # This is the configuration required to run NixOS on GandiCloud.
{ lib, modulesPath, ... }: {
config,
lib,
modulesPath,
...
}:
{ {
imports = [ (modulesPath + "/virtualisation/openstack-config.nix") ]; imports = [ (modulesPath + "/virtualisation/openstack-config.nix") ];
config = { config = {
@ -21,7 +26,7 @@
boot.kernelParams = [ "console=ttyS0" ]; boot.kernelParams = [ "console=ttyS0" ];
systemd.services."serial-getty@ttyS0" = { systemd.services."serial-getty@ttyS0" = {
enable = true; enable = true;
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
serviceConfig.Restart = "always"; serviceConfig.Restart = "always";
}; };
@ -31,7 +36,7 @@
# This is to get a prompt via the "openstack console url show" command # This is to get a prompt via the "openstack console url show" command
systemd.services."getty@tty1" = { systemd.services."getty@tty1" = {
enable = lib.mkForce true; enable = lib.mkForce true;
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
serviceConfig.Restart = "always"; serviceConfig.Restart = "always";
}; };

View file

@ -62,9 +62,9 @@
Type = "oneshot"; Type = "oneshot";
TimeoutStartSec = "60"; TimeoutStartSec = "60";
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
after = [ "hydra-server.service" ]; after = [ config.systemd.services.hydra-server.name ];
requires = [ "hydra-server.service" ]; requires = [ config.systemd.services.hydra-server.name ];
environment = { environment = {
inherit (config.systemd.services.hydra-init.environment) HYDRA_DBI; 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 = { age.secrets.grafana-client-secret = {
file = "${inputs.self}/secrets/grafana-client-secret.age"; file = "${inputs.self}/secrets/grafana-client-secret.age";

View file

@ -20,9 +20,9 @@ in
systemd.services.matrix-hook = { systemd.services.matrix-hook = {
description = "Matrix Hook"; description = "Matrix Hook";
after = [ "network-online.target" ]; after = [ config.systemd.targets.network-online.name ];
wants = [ "network-online.target" ]; wants = [ config.systemd.targets.network-online.name ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ config.systemd.targets.multi-user.name ];
environment = { environment = {
HTTP_ADDRESS = "localhost"; HTTP_ADDRESS = "localhost";
HTTP_PORT = "9088"; HTTP_PORT = "9088";

View file

@ -1,8 +1,13 @@
{ inputs, pkgs, ... }:
{ {
systemd.services.prometheus.after = pkgs.lib.mkForce [ "network-online.target" ]; config,
systemd.services.prometheus.wants = [ "network-online.target" ]; inputs,
systemd.services.alertmanager.after = [ "prometheus.service" ]; 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 = { services.prometheus = {
enable = true; enable = true;

View file

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