Compare commits
3 Commits
a827438a4c
...
006652da36
| Author | SHA1 | Date | |
|---|---|---|---|
|
006652da36
|
|||
|
3557a2e6c8
|
|||
|
df8a22760c
|
21
lib.nix
21
lib.nix
@@ -78,5 +78,26 @@ inputs.nixpkgs.lib.extend (
|
||||
vpnNamespace = "wg";
|
||||
};
|
||||
};
|
||||
|
||||
serviceDependZpool =
|
||||
serviceName: zpool:
|
||||
{ config, ... }:
|
||||
{
|
||||
config = lib.mkIf (zpool != "") {
|
||||
systemd.services.${serviceName} = {
|
||||
wants = [ "zfs-import-${zpool}.service" ];
|
||||
after = [ "zfs-import-${zpool}.service" ];
|
||||
requires = [ "zfs-import-${zpool}.service" ];
|
||||
};
|
||||
|
||||
# assert that the pool is even enabled
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.elem zpool config.boot.zfs.extraPools;
|
||||
message = "${zpool} is not enabled in `boot.zfs.extraPools`";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
service_configs.vaultwarden.path
|
||||
config.services.vaultwarden.backupDir
|
||||
])
|
||||
(lib.serviceDependZpool "vaultwarden" service_configs.zpool_ssds)
|
||||
(lib.serviceDependZpool "backup-vaultwarden" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.vaultwarden = {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
config.services.caddy.dataDir
|
||||
service_configs.https.data_dir
|
||||
])
|
||||
(lib.serviceDependZpool "caddy" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.caddy = {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
{
|
||||
imports = [
|
||||
(lib.serviceMountDeps "gitea" [ config.services.gitea.stateDir ])
|
||||
(lib.serviceDependZpool "gitea" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.gitea = {
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
imports = [
|
||||
(lib.serviceMountDeps "immich-server" [ config.services.immich.mediaLocation ])
|
||||
(lib.serviceMountDeps "immich-machine-learning" [ config.services.immich.mediaLocation ])
|
||||
(lib.serviceDependZpool "immich-server" service_configs.zpool_ssds)
|
||||
(lib.serviceDependZpool "immich-machine-learning" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.immich = {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
config.services.jellyfin.dataDir
|
||||
config.services.jellyfin.cacheDir
|
||||
])
|
||||
(lib.serviceDependZpool "jellyfin" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.jellyfin = {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
(lib.serviceMountDeps "minecraft-server-${service_configs.minecraft.server_name}" [
|
||||
"${service_configs.minecraft.parent_dir}/${service_configs.minecraft.server_name}"
|
||||
])
|
||||
(lib.serviceDependZpool "minecraft-server-${service_configs.minecraft.server_name}" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
environment.systemPackages = [
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
{
|
||||
imports = [
|
||||
(lib.serviceMountDeps "postgresql" [ config.services.postgresql.dataDir ])
|
||||
(lib.serviceDependZpool "postgresql" service_configs.zpool_ssds)
|
||||
];
|
||||
|
||||
services.postgresql = {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"${config.services.qbittorrent.profileDir}/qBittorrent"
|
||||
])
|
||||
(lib.vpnNamespaceOpenPort config.services.qbittorrent.webuiPort "qbittorrent")
|
||||
(lib.serviceDependZpool "qbittorrent" service_configs.zpool_hdds)
|
||||
];
|
||||
|
||||
services.qbittorrent = {
|
||||
|
||||
@@ -16,6 +16,8 @@ in
|
||||
service_configs.slskd.downloads
|
||||
service_configs.slskd.incomplete
|
||||
])
|
||||
(lib.serviceDependZpool "slskd" service_configs.zpool_ssds)
|
||||
(lib.serviceDependZpool "slskd" service_configs.zpool_hdds)
|
||||
];
|
||||
|
||||
users.groups."music" = { };
|
||||
|
||||
@@ -32,6 +32,7 @@ let
|
||||
https = {
|
||||
domain = "test.local";
|
||||
};
|
||||
zpool_ssds = "";
|
||||
};
|
||||
username = "testuser";
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user