Add wake online

This commit is contained in:
2025-12-12 04:42:20 +01:00
parent 87993b83fe
commit 918d42ff71
8 changed files with 74 additions and 11 deletions

View File

@@ -1,14 +1,27 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
modulesPath,
...
}:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [
"xhci_pci"
"ehci_pci"
"ahci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];

View File

@@ -24,6 +24,7 @@
pkgs.bash pkgs.bash
pkgs.fzf pkgs.fzf
pkgs.bc pkgs.bc
pkgs.wakeonlan
]; ];
services = { services = {
locate = { locate = {

View File

@@ -18,7 +18,7 @@
"video" "video"
]; ];
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAKMJ3TkEmRQcX7RQijNa2km6a2xXJk6M6FERh7C9nTJ" config.sops.secrets."ssh_keys/beastie_priv".path
]; ];
shell = pkgs.zsh; shell = pkgs.zsh;
}; };

View File

@@ -3,6 +3,9 @@
pkgs, pkgs,
... ...
}: }:
let
lanIface = "enp5s0";
in
{ {
imports = [ imports = [
#../ai.nix #../ai.nix
@@ -10,10 +13,12 @@
../k8s.nix ../k8s.nix
../libvirt.nix ../libvirt.nix
../openfortivpn.nix ../openfortivpn.nix
../options.nix
../packages.nix ../packages.nix
../sops-desktop.nix ../sops-desktop.nix
../ssh.nix ../sshd.nix
../sudo-nopasswd.nix ../sudo-nopasswd.nix
../wakeonlan.nix
### Import GUI modules ### Import GUI modules
../desktop/code.nix ../desktop/code.nix
@@ -31,6 +36,8 @@
../desktop/nvidia.nix ../desktop/nvidia.nix
]; ];
my.lanInterface = "enp5s0";
sops = { sops = {
secrets = { secrets = {
"wireguard_home/publickey" = { }; "wireguard_home/publickey" = { };
@@ -44,7 +51,7 @@
networking = { networking = {
#useNetworkd = true; #useNetworkd = true;
#useHostResolvConf = false; #useHostResolvConf = false;
interfaces.enp5s0 = { interfaces.${config.my.lanInterface} = {
ipv4.addresses = [ ipv4.addresses = [
{ {
address = "192.168.0.2"; address = "192.168.0.2";
@@ -54,7 +61,7 @@
}; };
defaultGateway = { defaultGateway = {
address = "192.168.0.254"; address = "192.168.0.254";
interface = "enp5s0"; interface = "${config.my.lanInterface}";
}; };
nameservers = [ nameservers = [
#"9.9.9.9" #"9.9.9.9"

View File

@@ -10,7 +10,7 @@
../openfortivpn.nix ../openfortivpn.nix
../packages.nix ../packages.nix
../sops-desktop.nix ../sops-desktop.nix
../ssh.nix ../sshd.nix
../sudo-nopasswd.nix ../sudo-nopasswd.nix
### Import GUI modules ### Import GUI modules
@@ -36,7 +36,7 @@
carto-interavtive 172.18.20.134 carto-interavtive 172.18.20.134
''; '';
}; };
users.users.${username} = { users.users.${username} = {
extraGroups = [ "networkmanager" ]; extraGroups = [ "networkmanager" ];
}; };
programs.nm-applet.enable = true; programs.nm-applet.enable = true;

View File

@@ -0,0 +1,10 @@
{
lib,
...
}:
{
options.my.lanInterface = lib.mkOption {
type = lib.types.str;
default = "enp5s0";
};
}

View File

@@ -0,0 +1,32 @@
{
config,
pkgs,
hostname,
...
}:
{
systemd.services."wol@$${config.my.lanInterface}" = {
description = "Wake-on-LAN for ${config.my.lanInterface}";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.ethtool}/bin/ethtool -s ${config.my.lanInterface} wol g";
RandomizedDelaySec = "30s";
};
};
environment.systemPackages = [ pkgs.ethtool ];
boot.initrd.network = {
enable = true;
ssh = {
enable = true;
port = 2222;
authorizedKeys = [ "ssh-ed25519 AAAA..." ]; # ta clé publique
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
};
};
boot.kernelParams = [
"ip=192.168.0.2::192.168.0.254:255.255.255.0:${hostname}:${config.my.lanInterface}:off"
];
}