summary refs log tree commit diff
path: root/nixos/modules/services/networking/racoon.nix
blob: 00986bbbd84971d58d59e5232e01e80a94e0ada8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.racoon;
in {
  options.services.racoon = {
    enable = mkEnableOption "Whether to enable racoon.";

    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";
        PIDFile = "/var/run/racoon.pid";
        Type = "forking";
        Restart = "always";
      };
      preStart = "rm /var/run/racoon.pid || true";
    };
  };
}