From cdfe4d6bcb64a28d44e497e3a4dcd7b51aa76247 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Thu, 13 Jun 2024 01:59:25 +0200 Subject: [PATCH] ryzensun: enable wake-on-lan --- hosts/ryzensun/networking.nix | 2 ++ hosts/ryzensun/ryzensun.nix | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hosts/ryzensun/networking.nix b/hosts/ryzensun/networking.nix index dbe15d05..0818ee31 100644 --- a/hosts/ryzensun/networking.nix +++ b/hosts/ryzensun/networking.nix @@ -23,6 +23,8 @@ "10.0.1.208" = ["cn07.lev-1"]; }; + interfaces.enp4s0.wakeOnLan.enable = true; + wireguard.enable = true; wg-quick.interfaces = { wg0 = { diff --git a/hosts/ryzensun/ryzensun.nix b/hosts/ryzensun/ryzensun.nix index ba15501a..5f03d39f 100644 --- a/hosts/ryzensun/ryzensun.nix +++ b/hosts/ryzensun/ryzensun.nix @@ -5,7 +5,7 @@ flake, ... }: -with lib; let +let psCfg = config.pub-solar; xdg = config.home-manager.users."${psCfg.user.name}".xdg; in { @@ -28,6 +28,30 @@ in { boot.binfmt.emulatedSystems = ["aarch64-linux"]; + # Required for WakeOnLan + boot.kernelParams = [ "ip=dhcp" ]; + boot.initrd = { + availableKernelModules = [ "r8169" ]; + network = { + enable = true; + ssh = { + enable = true; + # To prevent ssh clients from freaking out because a different host key is used, + # a different port for ssh is useful (assuming the same host has also a regular sshd running) + port = 2222; + + # Please create this manually the first time. + # sudo ssh-keygen -t ed25519 -N "" -f /etc/secrets/initrd/ssh_host_ed25519_key + hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ]; + authorizedKeys = psCfg.user.publicKeys; + }; + postCommands = '' + # Automatically ask for the password on SSH login + echo 'cryptsetup-askpass || echo "Unlock was successful; exiting SSH session" && exit 1' >> /root/.profile + ''; + }; + }; + services.fstrim.enable = true; services.tailscale.enable = true;