mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
feat(chen): WoL
This commit is contained in:
parent
6cfaf82535
commit
81ae90dd12
12 changed files with 77 additions and 4 deletions
|
|
@ -32,5 +32,8 @@ in {
|
||||||
packages.x86_64-linux.openwebrxplus
|
packages.x86_64-linux.openwebrxplus
|
||||||
# TODO: packages.aarch64-linux.openwebrxplus
|
# TODO: packages.aarch64-linux.openwebrxplus
|
||||||
];
|
];
|
||||||
|
systemd2mqtt.inputs = [
|
||||||
|
packages.x86_64-linux.systemd2mqtt
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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": {
|
"ct": {
|
||||||
"network": {
|
"network": {
|
||||||
"hostName": "ct",
|
"hostName": "ct",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ in {
|
||||||
};
|
};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Operating system type of the host";
|
description = "Operating system type of the host";
|
||||||
type = enum ["NixOS" "MacOS" "Darwin" "Linux"];
|
type = enum ["NixOS" "MacOS" "Darwin" "Linux" "Windows"];
|
||||||
default = "NixOS";
|
default = "NixOS";
|
||||||
};
|
};
|
||||||
folder = mkOption {
|
folder = mkOption {
|
||||||
|
|
@ -73,6 +73,7 @@ in {
|
||||||
macos = "darwin";
|
macos = "darwin";
|
||||||
darwin = "darwin";
|
darwin = "darwin";
|
||||||
linux = "linux";
|
linux = "linux";
|
||||||
|
windows = "windows";
|
||||||
}
|
}
|
||||||
.${string.toLower config.type};
|
.${string.toLower config.type};
|
||||||
modules = mkIf (config.folder != "linux") [
|
modules = mkIf (config.folder != "linux") [
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
access,
|
||||||
lib,
|
lib,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
cfg = config.services.systemd2mqtt;
|
cfg = config.services.systemd2mqtt;
|
||||||
in {
|
in {
|
||||||
|
imports = [ inputs.systemd2mqtt.nixosModules.default ];
|
||||||
|
|
||||||
services.systemd2mqtt = {
|
services.systemd2mqtt = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
user = mkDefault "root";
|
user = mkDefault "root";
|
||||||
|
|
@ -13,7 +17,7 @@ in {
|
||||||
url = mkDefault (
|
url = mkDefault (
|
||||||
if config.services.mosquitto.enable
|
if config.services.mosquitto.enable
|
||||||
then "tcp://localhost:1883"
|
then "tcp://localhost:1883"
|
||||||
else "tcp://mqtt.local.${config.networking.domain}:1883"
|
else access.proxyUrlFor { serviceName = "mosquitto"; scheme = "tcp"; }
|
||||||
);
|
);
|
||||||
username = mkDefault "systemd";
|
username = mkDefault "systemd";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
31
nixos/wake-chen.nix
Normal file
31
nixos/wake-chen.nix
Normal 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" ];
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
overlays = [
|
overlays = [
|
||||||
inputs.self.overlays.default
|
inputs.self.overlays.default
|
||||||
inputs.self.overlays.deploy-rs
|
inputs.self.overlays.deploy-rs
|
||||||
|
inputs.self.overlays.systemd2mqtt
|
||||||
inputs.self.overlays.arc
|
inputs.self.overlays.arc
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,6 @@ in rec {
|
||||||
samba = import ./samba.nix;
|
samba = import ./samba.nix;
|
||||||
openwebrx = import ./openwebrxplus.nix;
|
openwebrx = import ./openwebrxplus.nix;
|
||||||
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
||||||
|
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
|
||||||
arc = inputs.arcexprs.overlays.default;
|
arc = inputs.arcexprs.overlays.default;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@
|
||||||
krb5-ldap
|
krb5-ldap
|
||||||
nfs-utils-ldap
|
nfs-utils-ldap
|
||||||
barcodebuddy
|
barcodebuddy
|
||||||
openwebrxplus;
|
openwebrxplus
|
||||||
|
systemd2mqtt;
|
||||||
|
|
||||||
nf-setup-node = let
|
nf-setup-node = let
|
||||||
reisen = ../systems/reisen;
|
reisen = ../systems/reisen;
|
||||||
|
|
|
||||||
9
systems/chen/default.nix
Normal file
9
systems/chen/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{...}: {
|
||||||
|
type = "Windows";
|
||||||
|
network.networks = {
|
||||||
|
local = {
|
||||||
|
macAddress = "9c:6b:00:21:1c:e2";
|
||||||
|
address4 = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -23,6 +23,7 @@ in {
|
||||||
nixos.tailscale
|
nixos.tailscale
|
||||||
nixos.ipa
|
nixos.ipa
|
||||||
nixos.cloudflared
|
nixos.cloudflared
|
||||||
|
nixos.systemd2mqtt
|
||||||
nixos.ddclient
|
nixos.ddclient
|
||||||
nixos.acme
|
nixos.acme
|
||||||
nixos.nginx
|
nixos.nginx
|
||||||
|
|
@ -44,6 +45,7 @@ in {
|
||||||
nixos.access.proxmox
|
nixos.access.proxmox
|
||||||
nixos.access.plex
|
nixos.access.plex
|
||||||
nixos.access.invidious
|
nixos.access.invidious
|
||||||
|
nixos.wake-chen
|
||||||
nixos.samba
|
nixos.samba
|
||||||
./reisen-ssh.nix
|
./reisen-ssh.nix
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -159,3 +159,10 @@ module "tewi_legacy_system_records" {
|
||||||
zone_zone = cloudflare_zone.gensokyo-zone_zone.zone
|
zone_zone = cloudflare_zone.gensokyo-zone_zone.zone
|
||||||
net_data = local.systems.tewi.network
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
1
tree.nix
1
tree.nix
|
|
@ -51,7 +51,6 @@
|
||||||
filebin
|
filebin
|
||||||
mosh
|
mosh
|
||||||
doc-warnings
|
doc-warnings
|
||||||
inputs.systemd2mqtt.nixosModules.default
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue