nixpkgs/nixos/modules/services/networking/sniproxy.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
2.0 KiB
Nix
Raw Normal View History

2016-05-11 04:18:38 +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
{
imports = [ (mkRemovedOptionModule [ "services" "sniproxy" "logDir" ] "Now done by LogsDirectory=. Set to a custom path if you log to a different folder in your config.") ];
2016-05-11 04:18:38 +00:00
options = {
services.sniproxy = {
enable = mkEnableOption (lib.mdDoc "sniproxy server");
user = mkOption {
type = types.str;
default = "sniproxy";
description = lib.mdDoc "User account under which sniproxy runs.";
};
group = mkOption {
type = types.str;
default = "sniproxy";
description = lib.mdDoc "Group under which sniproxy runs.";
};
config = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc "sniproxy.conf configuration excluding the daemon username and pid file.";
example = ''
2016-05-11 04:18:38 +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
}
2016-05-11 04:18:38 +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}";
LogsDirectory = "sniproxy";
LogsDirectoryMode = "0640";
2016-05-11 04:18:38 +00:00
Restart = "always";
};
};
users.users = mkIf (cfg.user == "sniproxy") {
2016-05-11 04:18:38 +00:00
sniproxy = {
group = cfg.group;
uid = config.ids.uids.sniproxy;
};
};
users.groups = mkIf (cfg.group == "sniproxy") {
2016-05-11 04:18:38 +00:00
sniproxy = {
gid = config.ids.gids.sniproxy;
};
};
};
}