2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.sniproxy;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "sniproxy.conf" ''
|
|
|
|
user ${cfg.user}
|
|
|
|
pidfile /run/sniproxy.pid
|
|
|
|
${cfg.config}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
2022-01-13 20:06:32 +00:00
|
|
|
imports = [ (mkRemovedOptionModule [ "services" "sniproxy" "logDir" ] "Now done by LogsDirectory=. Set to a custom path if you log to a different folder in your config.") ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
options = {
|
|
|
|
services.sniproxy = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "sniproxy server");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "sniproxy";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "User account under which sniproxy runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "sniproxy";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Group under which sniproxy runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "sniproxy.conf configuration excluding the daemon username and pid file.";
|
2021-10-06 13:57:05 +00:00
|
|
|
example = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
error_log {
|
|
|
|
filename /var/log/sniproxy/error.log
|
|
|
|
}
|
|
|
|
access_log {
|
|
|
|
filename /var/log/sniproxy/access.log
|
|
|
|
}
|
|
|
|
listen 443 {
|
|
|
|
proto tls
|
|
|
|
}
|
|
|
|
table {
|
|
|
|
example.com 192.0.2.10
|
|
|
|
example.net 192.0.2.20
|
2021-10-06 13:57:05 +00:00
|
|
|
}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.sniproxy = {
|
|
|
|
description = "sniproxy server";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
|
|
|
ExecStart = "${pkgs.sniproxy}/bin/sniproxy -c ${configFile}";
|
2022-01-13 20:06:32 +00:00
|
|
|
LogsDirectory = "sniproxy";
|
|
|
|
LogsDirectoryMode = "0640";
|
2020-04-24 23:36:52 +00:00
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users = mkIf (cfg.user == "sniproxy") {
|
|
|
|
sniproxy = {
|
|
|
|
group = cfg.group;
|
|
|
|
uid = config.ids.uids.sniproxy;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups = mkIf (cfg.group == "sniproxy") {
|
|
|
|
sniproxy = {
|
|
|
|
gid = config.ids.gids.sniproxy;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|