1 # NixOS module for hans, ip over icmp daemon
2 { config, lib, pkgs, ... }:
4 cfg = config.services.hans;
16 clients = lib.mkOption {
19 Each attribute of this option defines a systemd service that
20 runs hans. Many or none may be defined.
21 The name of each service is
23 where «name» is the name of the
24 corresponding attribute name.
26 example = lib.literalExpression ''
34 type = lib.types.attrsOf (lib.types.submodule (
37 server = lib.mkOption {
40 description = "IP address of server running hans";
41 example = "192.0.2.1";
44 extraConfig = lib.mkOption {
47 description = "Additional command line parameters";
51 passwordFile = lib.mkOption {
54 description = "File that contains password";
62 enable = lib.mkOption {
63 type = lib.types.bool;
65 description = "enable hans server";
71 description = "The assigned ip range";
72 example = "198.51.100.0";
75 respondToSystemPings = lib.mkOption {
76 type = lib.types.bool;
78 description = "Force hans respond to ordinary pings";
81 extraConfig = lib.mkOption {
84 description = "Additional command line parameters";
88 passwordFile = lib.mkOption {
91 description = "File that contains password";
100 config = lib.mkIf (cfg.server.enable || cfg.clients != {}) {
101 boot.kernel.sysctl = lib.optionalAttrs cfg.server.respondToSystemPings {
102 "net.ipv4.icmp_echo_ignore_all" = 1;
105 boot.kernelModules = [ "tun" ];
109 createHansClientService = name: cfg:
111 description = "hans client - ${name}";
112 after = [ "network.target" ];
113 wantedBy = [ "multi-user.target" ];
114 script = "${pkgs.hans}/bin/hans -f -u ${hansUser} ${cfg.extraConfig} -c ${cfg.server} ${lib.optionalString (cfg.passwordFile != "") "-p $(cat \"${cfg.passwordFile}\")"}";
123 (name: value: lib.nameValuePair "hans-${name}" (createHansClientService name value))
126 hans = lib.mkIf (cfg.server.enable) {
127 description = "hans, ip over icmp server daemon";
128 after = [ "network.target" ];
129 wantedBy = [ "multi-user.target" ];
130 script = "${pkgs.hans}/bin/hans -f -u ${hansUser} ${cfg.server.extraConfig} -s ${cfg.server.ip} ${lib.optionalString cfg.server.respondToSystemPings "-r"} ${lib.optionalString (cfg.server.passwordFile != "") "-p $(cat \"${cfg.server.passwordFile}\")"}";
134 users.users.${hansUser} = {
135 description = "Hans daemon user";
140 meta.maintainers = [ ];