1 # NixOS module for hans, ip over icmp daemon
3 { config, lib, pkgs, ... }:
8 cfg = config.services.hans;
22 description = lib.mdDoc ''
23 Each attribute of this option defines a systemd service that
24 runs hans. Many or none may be defined.
25 The name of each service is
27 where «name» is the name of the
28 corresponding attribute name.
30 example = literalExpression ''
38 type = types.attrsOf (types.submodule (
44 description = lib.mdDoc "IP address of server running hans";
45 example = "192.0.2.1";
48 extraConfig = mkOption {
51 description = lib.mdDoc "Additional command line parameters";
55 passwordFile = mkOption {
58 description = lib.mdDoc "File that containts password";
69 description = lib.mdDoc "enable hans server";
75 description = lib.mdDoc "The assigned ip range";
76 example = "198.51.100.0";
79 respondToSystemPings = mkOption {
82 description = lib.mdDoc "Force hans respond to ordinary pings";
85 extraConfig = mkOption {
88 description = lib.mdDoc "Additional command line parameters";
92 passwordFile = mkOption {
95 description = lib.mdDoc "File that containts password";
104 config = mkIf (cfg.server.enable || cfg.clients != {}) {
105 boot.kernel.sysctl = optionalAttrs cfg.server.respondToSystemPings {
106 "net.ipv4.icmp_echo_ignore_all" = 1;
109 boot.kernelModules = [ "tun" ];
113 createHansClientService = name: cfg:
115 description = "hans client - ${name}";
116 after = [ "network.target" ];
117 wantedBy = [ "multi-user.target" ];
118 script = "${pkgs.hans}/bin/hans -f -u ${hansUser} ${cfg.extraConfig} -c ${cfg.server} ${optionalString (cfg.passwordFile != "") "-p $(cat \"${cfg.passwordFile}\")"}";
127 (name: value: nameValuePair "hans-${name}" (createHansClientService name value))
130 hans = mkIf (cfg.server.enable) {
131 description = "hans, ip over icmp server daemon";
132 after = [ "network.target" ];
133 wantedBy = [ "multi-user.target" ];
134 script = "${pkgs.hans}/bin/hans -f -u ${hansUser} ${cfg.server.extraConfig} -s ${cfg.server.ip} ${optionalString cfg.server.respondToSystemPings "-r"} ${optionalString (cfg.server.passwordFile != "") "-p $(cat \"${cfg.server.passwordFile}\")"}";
138 users.users.${hansUser} = {
139 description = "Hans daemon user";
144 meta.maintainers = with maintainers; [ ];