add serviceMountDeps

This commit is contained in:
Simon Gardling 2025-03-22 20:46:55 -04:00
parent 9a45c808fd
commit f3fe629666
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
7 changed files with 46 additions and 0 deletions

View File

@ -112,6 +112,12 @@
data_dir = services_dir + "/owntracks"; data_dir = services_dir + "/owntracks";
}; };
}; };
serviceMountDeps = serviceName: dirs: {
systemd.services.${serviceName} = {
unitConfig.RequiresMountsFor = dirs;
};
};
in in
{ {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
@ -123,6 +129,7 @@
eth_interface eth_interface
service_configs service_configs
inputs inputs
serviceMountDeps
; ;
}; };
modules = modules =

View File

@ -2,9 +2,14 @@
config, config,
service_configs, service_configs,
username, username,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "gitea" [ config.services.gitea.stateDir ])
];
services.gitea = { services.gitea = {
enable = true; enable = true;
appName = "Simon Gardling's Gitea instance"; appName = "Simon Gardling's Gitea instance";

View File

@ -3,9 +3,14 @@
pkgs, pkgs,
config, config,
username, username,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "immich" [ config.services.immich.mediaLocation ])
];
services.immich = { services.immich = {
enable = true; enable = true;
mediaLocation = service_configs.immich.dir; mediaLocation = service_configs.immich.dir;

View File

@ -3,9 +3,17 @@
config, config,
service_configs, service_configs,
username, username,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "jellyfin" [
config.services.jellyfin.dataDir
config.services.jellyfin.cacheDir
])
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
jellyfin jellyfin
jellyfin-web jellyfin-web
@ -37,6 +45,7 @@
"video" "video"
"render" "render"
service_configs.torrent_group service_configs.torrent_group
"media"
]; ];
users.users.${username}.extraGroups = [ users.users.${username}.extraGroups = [

View File

@ -4,9 +4,16 @@
lib, lib,
username, username,
config, config,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "minecraft-server-${service_configs.minecraft.server_name}" [
"${service_configs.minecraft.parent_dir}/${service_configs.minecraft.server_name}"
])
];
environment.systemPackages = [ environment.systemPackages = [
(pkgs.writeScriptBin "mc-console" '' (pkgs.writeScriptBin "mc-console" ''
#!/bin/sh #!/bin/sh

View File

@ -3,9 +3,14 @@
config, config,
username, username,
service_configs, service_configs,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "postgresql" [ config.services.postgresql.dataDir ])
];
services.postgresql = { services.postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_16; package = pkgs.postgresql_16;

View File

@ -4,9 +4,17 @@
service_configs, service_configs,
username, username,
lib, lib,
serviceMountDeps,
... ...
}: }:
{ {
imports = [
(serviceMountDeps "qbittorrent" [
service_configs.torrent.SavePath
service_configs.torrent.TempPath
])
];
# network namespace that is proxied through mullvad # network namespace that is proxied through mullvad
vpnNamespaces.wg = { vpnNamespaces.wg = {
portMappings = [ portMappings = [