feat(chen): WoL

This commit is contained in:
arcnmx 2024-05-11 12:33:10 -07:00
parent 6cfaf82535
commit 81ae90dd12
12 changed files with 77 additions and 4 deletions

View file

@ -32,5 +32,8 @@ in {
packages.x86_64-linux.openwebrxplus
# TODO: packages.aarch64-linux.openwebrxplus
];
systemd2mqtt.inputs = [
packages.x86_64-linux.systemd2mqtt
];
};
}

View file

@ -21,6 +21,20 @@
}
}
},
"chen": {
"network": {
"hostName": "chen",
"networks": {
"int": null,
"local": {
"address4": null,
"address6": "fd0a::9e6b:00ff:fe21:1ce2",
"macAddress": "9c:6b:00:21:1c:e2"
},
"tail": null
}
}
},
"ct": {
"network": {
"hostName": "ct",

View file

@ -28,7 +28,7 @@ in {
};
type = mkOption {
description = "Operating system type of the host";
type = enum ["NixOS" "MacOS" "Darwin" "Linux"];
type = enum ["NixOS" "MacOS" "Darwin" "Linux" "Windows"];
default = "NixOS";
};
folder = mkOption {
@ -73,6 +73,7 @@ in {
macos = "darwin";
darwin = "darwin";
linux = "linux";
windows = "windows";
}
.${string.toLower config.type};
modules = mkIf (config.folder != "linux") [

View file

@ -1,11 +1,15 @@
{
config,
access,
lib,
inputs,
...
}: let
inherit (lib.modules) mkIf mkDefault;
cfg = config.services.systemd2mqtt;
in {
imports = [ inputs.systemd2mqtt.nixosModules.default ];
services.systemd2mqtt = {
enable = mkDefault true;
user = mkDefault "root";
@ -13,7 +17,7 @@ in {
url = mkDefault (
if config.services.mosquitto.enable
then "tcp://localhost:1883"
else "tcp://mqtt.local.${config.networking.domain}:1883"
else access.proxyUrlFor { serviceName = "mosquitto"; scheme = "tcp"; }
);
username = mkDefault "systemd";
};

31
nixos/wake-chen.nix Normal file
View file

@ -0,0 +1,31 @@
{
config,
pkgs,
gensokyo-zone,
lib,
...
}: let
inherit (gensokyo-zone.lib) mapOptionDefaults;
inherit (lib.meta) getExe;
chen = gensokyo-zone.systems.chen.config;
service = "wake-chen";
in {
systemd.services.${service} = {
path = [ pkgs.wol ];
script = ''
exec wol ${chen.network.networks.local.macAddress}
'';
environment = mapOptionDefaults {
WOL_MAC_ADDRESS = chen.network.networks.local.macAddress;
};
serviceConfig = mapOptionDefaults {
Type = "oneshot";
RemainAfterExit = false;
} // {
ExecStart = [
"${getExe pkgs.wol} $WOL_MAC_ADDRESS"
];
};
};
services.systemd2mqtt.units = [ "${service}.service" ];
}

View file

@ -19,6 +19,7 @@
overlays = [
inputs.self.overlays.default
inputs.self.overlays.deploy-rs
inputs.self.overlays.systemd2mqtt
inputs.self.overlays.arc
];
config = {

View file

@ -21,5 +21,6 @@ in rec {
samba = import ./samba.nix;
openwebrx = import ./openwebrxplus.nix;
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
arc = inputs.arcexprs.overlays.default;
}

View file

@ -47,7 +47,8 @@
krb5-ldap
nfs-utils-ldap
barcodebuddy
openwebrxplus;
openwebrxplus
systemd2mqtt;
nf-setup-node = let
reisen = ../systems/reisen;

9
systems/chen/default.nix Normal file
View file

@ -0,0 +1,9 @@
{...}: {
type = "Windows";
network.networks = {
local = {
macAddress = "9c:6b:00:21:1c:e2";
address4 = null;
};
};
}

View file

@ -23,6 +23,7 @@ in {
nixos.tailscale
nixos.ipa
nixos.cloudflared
nixos.systemd2mqtt
nixos.ddclient
nixos.acme
nixos.nginx
@ -44,6 +45,7 @@ in {
nixos.access.proxmox
nixos.access.plex
nixos.access.invidious
nixos.wake-chen
nixos.samba
./reisen-ssh.nix
];

View file

@ -159,3 +159,10 @@ module "tewi_legacy_system_records" {
zone_zone = cloudflare_zone.gensokyo-zone_zone.zone
net_data = local.systems.tewi.network
}
module "chen_system_records" {
source = "./system/records"
zone_id = cloudflare_zone.gensokyo-zone_zone.id
zone_zone = cloudflare_zone.gensokyo-zone_zone.zone
net_data = local.systems.chen.network
}

View file

@ -51,7 +51,6 @@
filebin
mosh
doc-warnings
inputs.systemd2mqtt.nixosModules.default
];
};
};