2023-11-04 10:14:42 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2023-11-04 10:02:11 +00:00
|
|
|
port = "33829";
|
2023-11-04 10:14:42 +00:00
|
|
|
in {
|
2023-11-04 10:02:11 +00:00
|
|
|
imports = [
|
2023-11-17 05:38:25 +00:00
|
|
|
../../../../../../nixos/flake-modules/sops-nix.nix
|
2023-11-04 10:02:11 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
### Firewall
|
|
|
|
networking.firewall = {
|
2023-11-04 10:14:42 +00:00
|
|
|
allowedTCPPorts = [port];
|
|
|
|
allowedUDPPorts = [port];
|
2023-11-04 10:02:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#### sops-nix
|
|
|
|
sops.secrets."juicity-config" = {
|
|
|
|
owner = config.users.users."juicity".name;
|
|
|
|
group = config.users.groups."juicity".name;
|
2023-11-04 10:14:42 +00:00
|
|
|
restartUnits = ["juicity-server.service"];
|
2023-11-23 06:23:03 +00:00
|
|
|
path = "/etc/juicity/config.yaml";
|
2023-11-04 10:02:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
### User running proxy service
|
|
|
|
users.groups."juicity" = {};
|
|
|
|
users.users."juicity" = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = config.users.groups."juicity".name;
|
|
|
|
};
|
|
|
|
|
|
|
|
### Proxy service
|
|
|
|
systemd.services."juicity-server" = {
|
|
|
|
description = "Juicity Server";
|
2023-11-04 10:14:42 +00:00
|
|
|
after = ["network.target"];
|
2023-11-04 10:02:11 +00:00
|
|
|
|
2023-11-04 10:14:42 +00:00
|
|
|
wantedBy = ["multi-user.target"];
|
2023-11-04 10:02:11 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2023-11-23 06:23:03 +00:00
|
|
|
WorkingDirectory = "/etc/juicity";
|
2023-11-04 10:14:42 +00:00
|
|
|
User = [config.users.users."juicity".name];
|
|
|
|
Group = [config.users.groups."juicity".name];
|
2023-11-23 06:23:03 +00:00
|
|
|
ExecStart = "${pkgs.juicity}/bin/juicity-server run -c /etc/juicity/config.json";
|
2023-11-04 10:02:11 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
CapabilityBoundingSet = [
|
|
|
|
"CAP_NET_ADMIN"
|
|
|
|
"CAP_NET_BIND_SERVICE"
|
|
|
|
"CAP_NET_RAW"
|
|
|
|
];
|
|
|
|
AmbientCapabilities = [
|
|
|
|
"CAP_NET_ADMIN"
|
|
|
|
"CAP_NET_BIND_SERVICE"
|
|
|
|
"CAP_NET_RAW"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-11-04 10:14:42 +00:00
|
|
|
}
|