diff --git a/hosts/Dimaga/default.nix b/hosts/Dimaga/default.nix index f07d919..40e6896 100644 --- a/hosts/Dimaga/default.nix +++ b/hosts/Dimaga/default.nix @@ -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; diff --git a/modules/services/airsonic.nix b/modules/services/airsonic.nix index 26917d1..040675a 100644 --- a/modules/services/airsonic.nix +++ b/modules/services/airsonic.nix @@ -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; }; }; } diff --git a/modules/services/deluge.nix b/modules/services/deluge.nix index 41950b3..38999c3 100644 --- a/modules/services/deluge.nix +++ b/modules/services/deluge.nix @@ -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; }; }; } diff --git a/modules/services/duplicacy-web.nix b/modules/services/duplicacy-web.nix index 483e6e9..9caa48a 100644 --- a/modules/services/duplicacy-web.nix +++ b/modules/services/duplicacy-web.nix @@ -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; }; }; } diff --git a/modules/services/forgejo.nix b/modules/services/forgejo.nix index 9175a3d..43212b3 100644 --- a/modules/services/forgejo.nix +++ b/modules/services/forgejo.nix @@ -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; }; }; } diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index 3d33369..65cbae9 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -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; }; }; }