flake/users/guanranwang/nixos/presets/core/juicity-server.nix

61 lines
1.4 KiB
Nix
Raw Normal View History

{
pkgs,
config,
...
}: let
2023-11-04 10:02:11 +00:00
etcDirectory = "juicity";
port = "33829";
in {
2023-11-04 10:02:11 +00:00
imports = [
../../../../../flakes/nixos/sops-nix.nix
];
### Firewall
networking.firewall = {
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;
restartUnits = ["juicity-server.service"];
2023-11-04 10:02:11 +00:00
path = "/etc/${etcDirectory}/config.yaml";
};
### 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";
after = ["network.target"];
2023-11-04 10:02:11 +00:00
wantedBy = ["multi-user.target"];
2023-11-04 10:02:11 +00:00
serviceConfig = {
Type = "simple";
WorkingDirectory = "/etc/${etcDirectory}";
User = [config.users.users."juicity".name];
Group = [config.users.groups."juicity".name];
2023-11-04 10:02:11 +00:00
ExecStart = "${pkgs.juicity}/bin/juicity-server run -c /etc/${etcDirectory}/config.json";
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"
];
};
};
}