8 cfg = config.services.clatd;
10 settingsFormat = pkgs.formats.keyValue { };
12 configFile = settingsFormat.generate "clatd.conf" cfg.settings;
17 enable = lib.mkEnableOption "clatd";
19 package = lib.mkPackageOption pkgs "clatd" { };
21 enableNetworkManagerIntegration = lib.mkEnableOption "NetworkManager integration" // {
22 default = config.networking.networkmanager.enable;
23 defaultText = "config.networking.networkmanager.enable";
26 settings = lib.mkOption {
27 type = lib.types.submodule (
30 freeformType = settingsFormat.type;
34 example = lib.literalExpression ''
36 plat-prefix = "64:ff9b::/96";
40 Configuration of clatd. See [clatd Documentation](https://github.com/toreanderson/clatd/blob/master/README.pod#configuration).
46 config = lib.mkIf cfg.enable {
47 systemd.services.clatd = {
48 description = "464XLAT CLAT daemon";
49 documentation = [ "man:clatd(8)" ];
50 wantedBy = [ "multi-user.target" ];
51 after = [ "network-online.target" ];
52 wants = [ "network-online.target" ];
53 startLimitIntervalSec = 0;
56 ExecStart = "${cfg.package}/bin/clatd -c ${configFile}";
59 CapabilityBoundingSet = [
62 LockPersonality = true;
63 MemoryDenyWriteExecute = true;
64 NoNewPrivileges = true;
67 ProtectControlGroups = true;
69 ProtectHostname = true;
70 ProtectKernelLogs = true;
71 ProtectKernelModules = true;
72 ProtectProc = "invisible";
74 RestrictAddressFamilies = [
79 RestrictNamespaces = true;
80 RestrictRealtime = true;
81 RestrictSUIDSGID = true;
82 SystemCallArchitectures = "native";
92 networking.networkmanager.dispatcherScripts = lib.optionals cfg.enableNetworkManagerIntegration [
95 # https://github.com/toreanderson/clatd/blob/master/scripts/clatd.networkmanager
96 source = pkgs.writeShellScript "restart-clatd" ''
97 [ "$DEVICE_IFACE" = "${cfg.settings.clat-dev or "clat"}" ] && exit 0
98 [ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
99 ${pkgs.systemd}/bin/systemctl restart clatd.service