Greetings all,
something I’ve continuously butted up against (with my current knowledge) I’m unsure on how to deal with specific oci-containers that require other systemd services or mount units to operate.
my most common headache is ensuring that the container is started after the nfs mounts are up but also the appropriate order on shutdown.
At least from my testing the dependsOn variable only works for container names so entering something like mnt-containers.mount wouldn’t work.
any advice would be appreciated, I’ve attached some snippets from my server config below.
{ config, pkgs, ... }:
let
mkServerMount = path: {
device = "192.168.5.1:/mnt/myDATA-RZ2${path}";
fsType = "nfs";
};
in {
fileSystems."/mnt/storage" = mkServerMount("/servers/nixos-server/mnt/storage");
fileSystems."/mnt/containers" = mkServerMount("/servers/home-server/containers");
}
{ config, pkgs, ... }:
{
virtualisation.oci-containers.containers = {
nextcloud_database = {
image = "postgres:15.1";
autoStart = true;
volumes = [
"/mnt/containers/home-nextcloud/postgres_data:/var/lib/postgresql/data"
];
environmentFiles = [
/etc/nixos/oci-containers/default.env
/etc/nixos/oci-containers/nextcloud/database.env
];
};
nextcloud = {
dependsOn = [ "nextcloud_database" ];
image = "nextcloud:25.0.3";
autoStart = true;
volumes = [
"/mnt/containers/home-nextcloud/nextcloud_data:/var/www/html"
];
environmentFiles = [
/etc/nixos/oci-containers/default.env
/etc/nixos/oci-containers/nextcloud/database.env
];
environment = {
POSTGRES_HOST = "nextcloud_database";
};
};
};
}