Open afzl-wtu opened 11 months ago
On nixos things are changed. Here is template file wg0.conf that work directly with nixos by importing it into configuration.nix:
{ config, pkgs, ... }: # This file was generated using wireguard-ui (https://github.com/ngoduykhanh/wireguard-ui) # Please don't modify it manually, otherwise your change might get replaced. # Address updated at: {{ .serverConfig.Interface.UpdatedAt }} # Private Key updated at: {{ .serverConfig.KeyPair.UpdatedAt }} { # TODO: ips and allowedIPs are working only if they have exact one element. Otherwise Wireguard will crash as template need to improve. networking.wireguard.interfaces = { wg0 = { ips = [ "{{$first :=true}}{{range .serverConfig.Interface.Addresses }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}" ]; postSetup = '' {{ .serverConfig.Interface.PostUp }} ''; postShutdown = '' {{ .serverConfig.Interface.PostDown }} ''; listenPort = {{ .serverConfig.Interface.ListenPort }}; privateKey = "{{ .serverConfig.KeyPair.PrivateKey }}"; peers = [ {{range .clientDataList}}{{if eq .Client.Enabled true}} # ID: {{ .Client.ID }} # Name: {{ .Client.Name }} # Email: {{ .Client.Email }} # Created at: {{ .Client.CreatedAt }} # Update at: {{ .Client.UpdatedAt }} { publicKey = "{{ .Client.PublicKey }}"; {{if .Client.PresharedKey }}presharedKey = "{{ .Client.PresharedKey }}"; {{end}}allowedIPs = [ "{{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}"] ; } {{end}}{{end}} ]; }; }; }
Do not forget to use WG_CONF_TEMPLATE in docker environmental variable. NOTE: You still have to write NAT lines in main configuration.nix
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
On nixos things are changed. Here is template file wg0.conf that work directly with nixos by importing it into configuration.nix:
Do not forget to use WG_CONF_TEMPLATE in docker environmental variable. NOTE: You still have to write NAT lines in main configuration.nix