This commit is contained in:
1 parent
715bf6140f
commit
3893fb6078
5 files changed
+40
-31
No files matched your search
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
meta = import ./meta.nix;
|
meta = import ./meta.nix;
|
||||||
wolInterfaces = import ./wol-interfaces.nix;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -88,10 +87,7 @@ in
|
|||||||
};
|
};
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
taskwarrior.enable = true;
|
taskwarrior.enable = true;
|
||||||
wol = {
|
wol.interfaces.eno1.macAddress = "02:68:b3:29:da:98";
|
||||||
enable = true;
|
|
||||||
interfaces.eno1 = { inherit (wolInterfaces.eno1) macAddress; };
|
|
||||||
};
|
|
||||||
zfs.enable = true;
|
zfs.enable = true;
|
||||||
|
|
||||||
disko.devices = {
|
disko.devices = {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
eno1.macAddress = "02:68:b3:29:da:98";
|
|
||||||
}
|
|
||||||
@@ -71,6 +71,7 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
taskwarrior.enable = true;
|
taskwarrior.enable = true;
|
||||||
|
wol.wakes = [ "andromache" ];
|
||||||
zfs.enable = true;
|
zfs.enable = true;
|
||||||
|
|
||||||
secrets.nixSigningKey.enable = true;
|
secrets.nixSigningKey.enable = true;
|
||||||
@@ -82,16 +83,6 @@ in
|
|||||||
|
|
||||||
hardware.cpu.intel.updateMicrocode = true;
|
hardware.cpu.intel.updateMicrocode = true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "wol-andromache";
|
|
||||||
runtimeInputs = [ pkgs.wakeonlan ];
|
|
||||||
text = ''
|
|
||||||
wakeonlan ${(import ../andromache/wol-interfaces.nix).eno1.macAddress}
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostId = "5f0bde3c";
|
hostId = "5f0bde3c";
|
||||||
useDHCP = false;
|
useDHCP = false;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ in
|
|||||||
|
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
|
wol.wakes = [ "andromache" ];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
kernelParams = [
|
kernelParams = [
|
||||||
|
|||||||
+37
-13
@@ -1,33 +1,57 @@
|
|||||||
{ lib, config, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
outputs,
|
||||||
|
paths,
|
||||||
|
myUtils,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkOption types;
|
hosts = myUtils.dirNames paths.hosts;
|
||||||
|
interfaces = host: outputs.nixosConfigurations.${host}.config.wol.interfaces;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.wol = {
|
options.wol = {
|
||||||
enable = mkEnableOption "Wake-on-LAN configuration";
|
wakes = lib.mkOption {
|
||||||
|
type = lib.types.listOf (lib.types.enum hosts);
|
||||||
|
};
|
||||||
|
|
||||||
interfaces = mkOption {
|
interfaces = lib.mkOption {
|
||||||
type = types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
types.submodule {
|
lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
macAddress = mkOption {
|
macAddress = lib.mkOption { type = lib.types.str; };
|
||||||
type = types.str;
|
|
||||||
example = "02:68:b3:29:da:98";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
default = { };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.wol.enable {
|
config = {
|
||||||
|
assertions = map (host: {
|
||||||
|
assertion = interfaces host != { };
|
||||||
|
message = "cannot set up wake-on-lan for '${host}' as it declares no 'wol.interfaces'.";
|
||||||
|
}) config.wol.wakes;
|
||||||
|
|
||||||
networking.interfaces = lib.mapAttrs (_: iface: {
|
networking.interfaces = lib.mapAttrs (_: iface: {
|
||||||
wakeOnLan.enable = true;
|
wakeOnLan.enable = true;
|
||||||
inherit (iface) macAddress;
|
inherit (iface) macAddress;
|
||||||
}) config.wol.interfaces;
|
}) config.wol.interfaces;
|
||||||
|
|
||||||
# networking.firewall.allowedUDPPorts = [ 9 ];
|
environment.systemPackages = map (
|
||||||
|
host:
|
||||||
|
let
|
||||||
|
macAddresses = lib.mapAttrsToList (_: interface: interface.macAddress) (interfaces host);
|
||||||
|
in
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "wol-${host}";
|
||||||
|
runtimeInputs = [ pkgs.wakeonlan ];
|
||||||
|
text = ''
|
||||||
|
wakeonlan ${lib.escapeShellArgs macAddresses}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
) config.wol.wakes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user