2015-04-25 14:31:27 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.racoon;
|
|
|
|
in {
|
|
|
|
options.services.racoon = {
|
2015-06-21 16:19:46 +01:00
|
|
|
enable = mkEnableOption "racoon";
|
2015-04-25 14:31:27 +01:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
description = "Contents of racoon configuration file.";
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
configPath = mkOption {
|
|
|
|
description = "Location of racoon config if config is not provided.";
|
|
|
|
default = "/etc/racoon/racoon.conf";
|
|
|
|
type = types.path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.racoon = {
|
|
|
|
description = "Racoon Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.ipsecTools}/bin/racoon -f ${
|
|
|
|
if (cfg.config != "") then pkgs.writeText "racoon.conf" cfg.config
|
|
|
|
else cfg.configPath
|
|
|
|
}";
|
|
|
|
ExecReload = "${pkgs.ipsecTools}/bin/racoonctl reload-config";
|
2018-12-19 21:40:37 +00:00
|
|
|
PIDFile = "/run/racoon.pid";
|
2015-04-25 14:31:27 +01:00
|
|
|
Type = "forking";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
2015-08-19 22:38:44 +01:00
|
|
|
preStart = ''
|
2018-12-19 21:40:37 +00:00
|
|
|
rm /run/racoon.pid || true
|
2015-08-19 22:38:44 +01:00
|
|
|
mkdir -p /var/racoon
|
|
|
|
'';
|
2015-04-25 14:31:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|