feat(networking): enable systemd-networkd

This commit is contained in:
Felix Schröter 2025-05-10 15:56:47 +02:00
parent d8d4b29769
commit 61b899ecb6
Signed by: felschr
GPG key ID: 671E39E6744C807D
6 changed files with 147 additions and 1 deletions
home/modules/seven
modules
secrets/wireguard
system

View file

@ -0,0 +1,22 @@
{ config, lib, ... }:
let
cfg = config.custom.seven;
in
{
imports = [ ./seven-ntfy.nix ];
options = {
custom.seven = {
enable = lib.mkEnableOption (lib.mdDoc "Seven");
ssh.enable = lib.mkEnableOption (lib.mdDoc "Seven SSH");
};
};
config = lib.mkIf cfg.enable {
programs.ssh.extraConfig = lib.mkIf cfg.ssh.enable ''
Host *.factory.secunet.com
User fschroeter
'';
};
}

View file

@ -0,0 +1,40 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.custom.seven.ntfy;
in
{
options = {
custom.seven.ntfy = {
enable = lib.mkEnableOption (lib.mdDoc "ntfy service for seven");
};
};
config = lib.mkIf cfg.enable {
systemd.user = {
services.ntfy = {
Unit = {
Description = "ntfy alert scubscription";
After = "network-online.target";
PartOf = [ "graphical-session.target" ];
};
Service =
let
topic = "https://grafana.factory.secunet.com/ntfy/alerts";
notify-send = lib.getExe pkgs.libnotify;
in
{
Environment = "PATH=${pkgs.bash}/bin:\${PATH}";
ExecStart = "${pkgs.ntfy-sh}/bin/ntfy sub ${topic} '${notify-send} \"$t\" \"$m\"'";
Restart = "always";
};
Install.WantedBy = [ "default.target" ];
};
};
};
}

67
modules/wg0.nix Normal file
View file

@ -0,0 +1,67 @@
{ config, lib, ... }:
let
cfg = config.custom.wg0;
in
{
options = {
custom.wg0 = {
enable = lib.mkEnableOption (lib.mdDoc "Wireguard config");
addresses = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "IP addresses for this machine within VPN.";
};
privateKeyFile = lib.mkOption {
type = lib.types.str;
example = "/path/to/secret.key";
description = "Private key file.";
};
};
};
config = lib.mkIf cfg.enable {
age.secrets.wireguard-home-pc-key = {
file = ../secrets/wireguard/home-pc.key.age;
owner = "systemd-network";
};
age.secrets.wireguard-cmdframe-key = {
file = ../secrets/wireguard/cmdframe.key.age;
owner = "systemd-network";
};
systemd.network = {
enable = true;
# TODO cannot push this to public git like this
netdevs."40-wg0" = {
netdevConfig = {
Kind = "wireguard";
Name = "wg0";
MTUBytes = "1280";
};
wireguardConfig = {
PrivateKeyFile = cfg.privateKeyFile;
};
wireguardPeers = [
{
PublicKey = "ZVayNyJeOn848aus5bqYU2ujNxvnYtV3ACoerLtDpg8=";
AllowedIPs = [
"198.18.0.0/15"
"fd00:5ec::/48"
];
# TODO remove endpoint from config
Endpoint = "gateway.seven.secunet.com:51821";
}
];
};
networks."40-wg0" = {
matchConfig.Name = "wg0";
address = cfg.addresses;
networkConfig = {
IPMasquerade = "ipv4";
};
};
};
};
}

View file

@ -0,0 +1,7 @@
age-encryption.org/v1
-> ssh-ed25519 OAZQhA yHDlGU8tW/fiMocPl0nldeEEn7NvPDMNCqL9hO7B5VY
71ZALgVNzj0FJG4wW5qK+0rhF2hMMkkvqOl6wvpI1xo
-> ssh-ed25519 lJaKnA 32vsGauSIeEy8gMq3rOuJV5OOVR/qbNCaJ96gvaYc38
3f8ZLzGFg4g2XNfUPS+ePMc9AZHMLUjh6y0q2gaRwio
--- PZeKDBBgibYk1Xl5Sd1S38kx322Gi6KnI0lj2NyhFUU
?ºy)<29>Sk*ŒÀ˜ýgzË_íEË>| JÔ×­*9á ähÁŒ“aIë9pÌ ?Õ(ïJÑØäF x:;1yKPü]VQ2‡J;Y¤º

Binary file not shown.

View file

@ -5,7 +5,17 @@
"127.0.0.1"
"::1"
];
networking.networkmanager.dns = "systemd-resolved";
networking.nftables.enable = true;
networking.networkmanager = {
enable = true;
dns = "systemd-resolved";
};
systemd.network = {
enable = true;
wait-online.ignoredInterfaces = [ "tailscale0" ];
};
services.dnsmasq.enable = false;
services.resolved = {