From fa295f3b1a53dd24b7567c10640e81a6ed90bcfb Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 8 Dec 2024 01:03:06 +0100 Subject: [PATCH] Allow configuring networkd --- profiles/machines/manuel/server.nix | 27 +++++++++++++++++++ .../Arch/Software/systemd-networkd/main.fish | 13 +++++++++ scripts/Arch/lib/deploy.fish | 1 + .../Software/systemd-networkd/main.fish | 16 +++++++++++ 4 files changed, 57 insertions(+) create mode 100644 scripts/Arch/Software/systemd-networkd/main.fish create mode 100644 scripts/Common/Software/systemd-networkd/main.fish diff --git a/profiles/machines/manuel/server.nix b/profiles/machines/manuel/server.nix index bc609829..dc0c9104 100644 --- a/profiles/machines/manuel/server.nix +++ b/profiles/machines/manuel/server.nix @@ -70,6 +70,33 @@ in { linux.programs = { grub.enable = true; + systemd-networkd = { + enable = true; + + networks = + let device = "enp0s31f6"; + in { + ${device} = { + Match = { + Name = device; + }; + + Network = { + Address = "2a01:4f8:10b:2644::2/64"; + Gateway = [ + "94.130.48.193" + "fe80::1" + ]; + }; + + Address = { + Address = "94.130.48.251"; + Peer = "94.130.48.193/32"; + }; + }; + }; + }; + docker = { services = { anki-sync.enable = true; diff --git a/scripts/Arch/Software/systemd-networkd/main.fish b/scripts/Arch/Software/systemd-networkd/main.fish new file mode 100644 index 00000000..ea2435f9 --- /dev/null +++ b/scripts/Arch/Software/systemd-networkd/main.fish @@ -0,0 +1,13 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../../lib/software.fish" + inherit "$dir/../../../Common/Software/systemd-networkd/main.fish" + + function configureSW -V dir + systemctl enable systemd-networkd + configureSWBase $argv + end + + runInstaller $argv +end diff --git a/scripts/Arch/lib/deploy.fish b/scripts/Arch/lib/deploy.fish index 59cd3d1f..73dddc23 100644 --- a/scripts/Arch/lib/deploy.fish +++ b/scripts/Arch/lib/deploy.fish @@ -71,6 +71,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action end and source "$dir/../../Common/Software/bash/main.fish" $argv + and source "$dir/../Software/systemd-networkd/main.fish" $argv and source "$dir/../Software/btrfs/main.fish" $argv and source "$dir/../../Common/Software/nuke-usb/main.fish" $argv and source "$dir/../Software/sudo/main.fish" $argv diff --git a/scripts/Common/Software/systemd-networkd/main.fish b/scripts/Common/Software/systemd-networkd/main.fish new file mode 100644 index 00000000..901fd6a5 --- /dev/null +++ b/scripts/Common/Software/systemd-networkd/main.fish @@ -0,0 +1,16 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../../lib/software.fish" + + function configureSW -V dir + source "$dir/../../../lib/settings.fish" + set config (getProgramConfig $argv --json) + + for name in (echo "$config" | jq '.networkFiles | keys[]' --raw-output0 | string split0 || true) + echo "$config" | NAME=$name jq '.networkFiles[env.NAME]' | sudo tee "/etc/systemd/network/10-$name.network" >/dev/null + end + end + + runInstaller $argv +end