This commit is contained in:
1 parent
715bf6140f
commit
3893fb6078
5 files changed
+41
-32
No files matched your search
@@ -8,7 +8,6 @@
|
||||
|
||||
let
|
||||
meta = import ./meta.nix;
|
||||
wolInterfaces = import ./wol-interfaces.nix;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
@@ -88,10 +87,7 @@ in
|
||||
};
|
||||
tailscale.enable = true;
|
||||
taskwarrior.enable = true;
|
||||
wol = {
|
||||
enable = true;
|
||||
interfaces.eno1 = { inherit (wolInterfaces.eno1) macAddress; };
|
||||
};
|
||||
wol.interfaces.eno1.macAddress = "02:68:b3:29:da:98";
|
||||
zfs.enable = true;
|
||||
|
||||
disko.devices = {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
eno1.macAddress = "02:68:b3:29:da:98";
|
||||
}
|
||||
@@ -71,6 +71,7 @@ in
|
||||
};
|
||||
};
|
||||
taskwarrior.enable = true;
|
||||
wol.wakes = [ "andromache" ];
|
||||
zfs.enable = true;
|
||||
|
||||
secrets.nixSigningKey.enable = true;
|
||||
@@ -82,16 +83,6 @@ in
|
||||
|
||||
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 = {
|
||||
hostId = "5f0bde3c";
|
||||
useDHCP = false;
|
||||
|
||||
@@ -16,6 +16,7 @@ in
|
||||
|
||||
ssh.enable = true;
|
||||
tailscale.enable = true;
|
||||
wol.wakes = [ "andromache" ];
|
||||
|
||||
boot = {
|
||||
kernelParams = [
|
||||
|
||||
+38
-14
@@ -1,33 +1,57 @@
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
outputs,
|
||||
paths,
|
||||
myUtils,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
hosts = myUtils.dirNames paths.hosts;
|
||||
interfaces = host: outputs.nixosConfigurations.${host}.config.wol.interfaces;
|
||||
in
|
||||
{
|
||||
options.wol = {
|
||||
enable = mkEnableOption "Wake-on-LAN configuration";
|
||||
|
||||
interfaces = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
macAddress = mkOption {
|
||||
type = types.str;
|
||||
example = "02:68:b3:29:da:98";
|
||||
wakes = lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.enum hosts);
|
||||
};
|
||||
|
||||
interfaces = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
macAddress = lib.mkOption { type = lib.types.str; };
|
||||
};
|
||||
}
|
||||
);
|
||||
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: {
|
||||
wakeOnLan.enable = true;
|
||||
inherit (iface) macAddress;
|
||||
}) 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