134 lines
3.7 KiB
Nix
134 lines
3.7 KiB
Nix
# Auto-generated using compose2nix v0.2.2-pre.
|
|
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
{
|
|
# Runtime
|
|
virtualisation.podman = {
|
|
enable = true;
|
|
autoPrune.enable = true;
|
|
dockerCompat = true;
|
|
defaultNetwork.settings = {
|
|
# Required for container networking to be able to use names.
|
|
dns_enabled = true;
|
|
};
|
|
};
|
|
virtualisation.oci-containers.backend = "podman";
|
|
|
|
# Containers
|
|
virtualisation.oci-containers.containers."obsidian-livesync" = {
|
|
image = "couchdb";
|
|
environmentFiles = [ config.age.secrets.couchdb.path ];
|
|
volumes = [
|
|
"${./local.ini}:/opt/couchdb/etc/local.ini:rw"
|
|
"test_dbdata:/opt/couchdb/data:rw"
|
|
];
|
|
ports = [ "5984:5984/tcp" ];
|
|
log-driver = "journald";
|
|
extraOptions = [
|
|
"--network-alias=couchserver"
|
|
"--network=test_default"
|
|
];
|
|
};
|
|
systemd.services."podman-obsidian-livesync" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 500 "always";
|
|
};
|
|
after = [
|
|
"podman-network-test_default.service"
|
|
"podman-volume-test_dbdata.service"
|
|
];
|
|
requires = [
|
|
"podman-network-test_default.service"
|
|
"podman-volume-test_dbdata.service"
|
|
];
|
|
partOf = [ "podman-compose-test-root.target" ];
|
|
wantedBy = [ "podman-compose-test-root.target" ];
|
|
};
|
|
virtualisation.oci-containers.containers."rustypaste" = {
|
|
image = "orhunp/rustypaste:latest";
|
|
environment = {
|
|
"RUST_LOG" = "debug";
|
|
};
|
|
volumes = [
|
|
"${./rusty.toml}:/app/config.toml:ro"
|
|
"test_rustypaste-data:/app/upload:rw"
|
|
];
|
|
ports = [ "8000:8000/tcp" ];
|
|
log-driver = "journald";
|
|
extraOptions = [
|
|
"--network-alias=rustypaste"
|
|
"--network=test_default"
|
|
];
|
|
};
|
|
systemd.services."podman-rustypaste" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 500 "always";
|
|
};
|
|
after = [
|
|
"podman-network-test_default.service"
|
|
"podman-volume-test_rustypaste-data.service"
|
|
];
|
|
requires = [
|
|
"podman-network-test_default.service"
|
|
"podman-volume-test_rustypaste-data.service"
|
|
];
|
|
partOf = [ "podman-compose-test-root.target" ];
|
|
wantedBy = [ "podman-compose-test-root.target" ];
|
|
};
|
|
|
|
# Networks
|
|
systemd.services."podman-network-test_default" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStop = "podman network rm -f test_default";
|
|
};
|
|
script = ''
|
|
podman network inspect test_default || podman network create test_default
|
|
'';
|
|
partOf = [ "podman-compose-test-root.target" ];
|
|
wantedBy = [ "podman-compose-test-root.target" ];
|
|
};
|
|
|
|
# Volumes
|
|
systemd.services."podman-volume-test_dbdata" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
script = ''
|
|
podman volume inspect test_dbdata || podman volume create test_dbdata
|
|
'';
|
|
partOf = [ "podman-compose-test-root.target" ];
|
|
wantedBy = [ "podman-compose-test-root.target" ];
|
|
};
|
|
systemd.services."podman-volume-test_rustypaste-data" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
script = ''
|
|
podman volume inspect test_rustypaste-data || podman volume create test_rustypaste-data
|
|
'';
|
|
partOf = [ "podman-compose-test-root.target" ];
|
|
wantedBy = [ "podman-compose-test-root.target" ];
|
|
};
|
|
|
|
# Root service
|
|
# When started, this will automatically create all resources and start
|
|
# the containers. When stopped, this will teardown all resources.
|
|
systemd.targets."podman-compose-test-root" = {
|
|
unitConfig = {
|
|
Description = "Root target generated by compose2nix.";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
}
|