fix(mesh): create heather identity interface with systemd
This commit is contained in:
parent
55bb222eb5
commit
9abae8d2f5
1 changed files with 18 additions and 3 deletions
|
|
@ -27,10 +27,25 @@
|
||||||
# The private key is generated on the live host and stays outside the flake.
|
# The private key is generated on the live host and stays outside the flake.
|
||||||
environment.systemPackages = [ pkgs.wireguard-tools ];
|
environment.systemPackages = [ pkgs.wireguard-tools ];
|
||||||
|
|
||||||
systemd.network.netdevs."10-mesh0" = {
|
# NixOS uses scripted networking here (not systemd-networkd), so create the
|
||||||
netdevConfig = { Name = "mesh0"; Kind = "dummy"; };
|
# dummy identity interface through a small idempotent systemd unit.
|
||||||
|
systemd.services.mesh-identity = {
|
||||||
|
description = "Create mesh identity interface";
|
||||||
|
wantedBy = [ "network.target" ];
|
||||||
|
after = [ "wireguard-wg-mesh.service" "network-addresses-wg-mesh.service" ];
|
||||||
|
wants = [ "wireguard-wg-mesh.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
ExecStart = pkgs.writeShellScript "mesh-identity-up" ''
|
||||||
|
set -eu
|
||||||
|
${pkgs.iproute2}/bin/ip link show mesh0 >/dev/null 2>&1 || ${pkgs.iproute2}/bin/ip link add mesh0 type dummy
|
||||||
|
${pkgs.iproute2}/bin/ip addr replace 10.0.0.1/32 dev mesh0
|
||||||
|
${pkgs.iproute2}/bin/ip link set mesh0 up
|
||||||
|
'';
|
||||||
|
ExecStop = "${pkgs.iproute2}/bin/ip link del mesh0";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
networking.interfaces.mesh0.ipv4.addresses = [ { address = "10.0.0.1"; prefixLength = 32; } ];
|
|
||||||
|
|
||||||
networking.wireguard.interfaces.wg-mesh = {
|
networking.wireguard.interfaces.wg-mesh = {
|
||||||
ips = [ "10.99.0.1/30" ];
|
ips = [ "10.99.0.1/30" ];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue