How to configure IPv6 tunnel from tunnelbroker.net

They do have example configurations for many OSes, but obviously Nix is different.

Here’s an example for Ubuntu:

auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address 2001:470:a:3b3::2
        netmask 64
        endpoint 216.218.226.238
        local 162.43.203.91
        ttl 255
        gateway 2001:470:a:3b3::1

You can use networkd. I use something like this:

  systemd.network.netdevs."he-ipv6" = {
    netdevConfig = {
      Name = "he-ipv6";
      Kind = "sit";
      MTUBytes = "1412";
    };
    tunnelConfig = {
      Local = config.host.publicIp4;
      Remote = "216.66.80.98";
      TTL = 255;
    };
  };

  systemd.network.networks."he-ipv6" = {
    matchConfig = { Name = "he-ipv6"; };
    networkConfig = {
      Address = "2001:470:25:188::2/64";
    };
    routes = [{
      Destination = "2000::/3";
      Source = "${config.site.prefix6}::/48";
      Metric = 50;
    }];
  };