project-software/affine/affine.nix
2025-09-29 01:10:22 +07:00

40 lines
No EOL
1 KiB
Nix

{ pkgs, lib, config, ... }:
let
affine-static = "/var/lib/affine";
affine-config = config.services.affine;
in {
config = lib.mkIf affine-config.enable {
system.activationScripts.affine-dir = ''
mkdir -p ${affine-static}/{config,db,storage}
'';
virtualisation.docker = {
enable = true;
autoPrune.enable = true;
};
networking.firewall.interfaces."docker+".allowedUDPPorts = [ 53 ];
virtualisation.oci-containers.backend = "docker";
systemd.services."docker-network-affine_default" = {
path = [ pkgs.docker ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStop = "docker network rm -f affine_default";
};
script = ''
docker network inspect affine_default || docker network create affine_default
'';
partOf = [ "docker-compose-affine-root.target" ];
wantedBy = [ "docker-compose-affine-root.target" ];
};
systemd.targets."docker-compose-affine-root" = {
unitConfig.Description = "Root target generated by compose2nix.";
wantedBy = [ "multi-user.target" ];
};
};
}