1
0
Fork 0

Services: replace 'autostart' with a more useful 'requires' option

This commit is contained in:
Aires 2024-08-29 10:28:28 -04:00
parent 86e3cb01cc
commit 0ce77db45a
6 changed files with 44 additions and 21 deletions

View file

@ -136,21 +136,21 @@ in
boinc.enable = true;
deluge = {
enable = true;
autostart = false;
home = "${services-root}/deluge";
domain = config.secrets.networking.primaryDomain;
requires = [ "storage.mount" ];
url = config.secrets.services.deluge.url;
};
duplicacy-web = {
enable = true;
autostart = false;
requires = [ "storage.mount" ];
environment = "/storage/backups/settings/Haven";
};
forgejo = {
enable = true;
autostart = false;
home = "${services-root}/forgejo";
domain = config.secrets.networking.primaryDomain;
requires = [ "storage.mount" ];
url = config.secrets.services.forgejo.url;
actions = {
enable = true;
@ -159,9 +159,9 @@ in
};
jellyfin = {
enable = true;
autostart = false;
home = "${services-root}/jellyfin";
domain = config.secrets.networking.primaryDomain;
requires = [ "storage.mount" ];
url = config.secrets.services.jellyfin.url;
};
msmtp.enable = true;

View file

@ -10,7 +10,6 @@ in
{
options = {
aux.system.services.airsonic = {
autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Airsonic at boot.");
enable = lib.mkEnableOption (lib.mdDoc "Enables Airsonic Advanced media streaming service.");
home = lib.mkOption {
default = "";
@ -29,6 +28,12 @@ in
description = "The complete URL where Airsonic is hosted.";
example = "https://forgejo.example.com";
};
requires = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = "If this service depends on other systemd units (e.g. a *.mount unit), enter their name(s) here.";
example = [ "storage.mount" ];
};
};
};
@ -71,7 +76,7 @@ in
};
systemd.services.nginx.wants = [ config.systemd.services.airsonic.name ];
# Disable autostart if configured
systemd.services.airsonic = lib.mkIf (!cfg.autostart) { wantedBy = lib.mkForce [ ]; };
# Don't start this service until after these services
systemd.services.airsonic = lib.mkIf (cfg.requires != [ ]) { requires = cfg.requires; };
};
}

View file

@ -7,7 +7,6 @@ in
{
options = {
aux.system.services.deluge = {
autostart = lib.mkEnableOption "Automatically starts Deluge at boot.";
enable = lib.mkEnableOption "Enables Deluge.";
home = lib.mkOption {
default = "";
@ -26,6 +25,12 @@ in
description = "The complete URL where Deluge is hosted.";
example = "https://deluge.example.com";
};
requires = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = "If this service depends on other systemd units (e.g. a *.mount unit), enter their name(s) here.";
example = [ "storage.mount" ];
};
};
};
@ -52,5 +57,8 @@ in
};
};
};
# Don't start this service until after these services
systemd.services.deluge = lib.mkIf (cfg.requires != [ ]) { requires = cfg.requires; };
};
}

View file

@ -13,17 +13,17 @@ in
options = {
aux.system.services.duplicacy-web = {
enable = lib.mkEnableOption "Enables duplicacy-web";
autostart = lib.mkOption {
default = true;
type = lib.types.bool;
description = "Whether to auto-start duplicacy-web on boot";
};
environment = lib.mkOption {
default = "";
type = lib.types.str;
description = "Environment where duplicacy-web stores its config files";
};
requires = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = "If this service depends on other systemd units (e.g. a *.mount unit), enter their name(s) here.";
example = [ "storage.mount" ];
};
};
};
@ -52,6 +52,6 @@ in
environment = {
HOME = cfg.environment;
};
} // lib.optionalAttrs (!cfg.autostart) { wantedBy = lib.mkForce [ ]; };
} // lib.optionalAttrs (cfg.requires != [ ]) { requires = cfg.requires; };
};
}

View file

@ -24,7 +24,6 @@ in
{
options = {
aux.system.services.forgejo = {
autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Forgejo at boot.");
enable = lib.mkEnableOption (lib.mdDoc "Enables Forgejo Git hosting service.");
domain = lib.mkOption {
default = "";
@ -38,6 +37,12 @@ in
description = "Where to store Forgejo's files";
example = "/home/forgejo";
};
requires = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = "If this service depends on other systemd units (e.g. a *.mount unit), enter their name(s) here.";
example = [ "storage.mount" ];
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -125,7 +130,7 @@ in
allowedTCPPorts = [ 53 ];
allowedUDPPorts = [ 53 ];
};
# Disable autostart if configured
systemd.services.forgejo = lib.mkIf (!cfg.autostart) { wantedBy = lib.mkForce [ ]; };
# Don't start this service until after these services
systemd.services.forgejo = lib.mkIf (cfg.requires != [ ]) { requires = cfg.requires; };
};
}

View file

@ -14,7 +14,6 @@ in
{
options = {
aux.system.services.jellyfin = {
autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Jellyfin at boot.");
enable = lib.mkEnableOption (lib.mdDoc "Enables the Jellyfin media streaming service.");
home = lib.mkOption {
default = "";
@ -27,6 +26,12 @@ in
description = "The root domain that Jellyfin will be hosted on.";
example = "example.com";
};
requires = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = "If this service depends on other systemd units (e.g. a *.mount unit), enter their name(s) here.";
example = [ "storage.mount" ];
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -98,7 +103,7 @@ in
];
systemd.services.nginx.wants = [ config.systemd.services.jellyfin.name ];
# Disable autostart if configured
systemd.services.jellyfin = lib.mkIf (!cfg.autostart) { wantedBy = lib.mkForce [ ]; };
# Don't start this service until after these services
systemd.services.jellyfin = lib.mkIf (cfg.requires != [ ]) { requires = cfg.requires; };
};
}