1
0
mirror of https://github.com/kmein/niveum synced 2026-03-21 12:21:08 +01:00

3 Commits

5 changed files with 124 additions and 74 deletions

View File

@@ -109,12 +109,12 @@ in
{{ define "telegram.default" }}
{{range .Alerts -}}
{{ if eq .Status "firing" }}
<b>{{ index .Annotations "summary"}}</b>
{{ index .Annotations "description" }}
<b>{{ index .Annotations "summary"}}</b>
{{ index .Annotations "description" }}
See on <a href="${config.services.grafana.domain}/d/alpUteInz/niveum">Grafana</a>.
See on <a href="http://${config.services.grafana.domain}/d/alpUteInz/niveum">Grafana</a>.
{{ else -}}
😌 <del>{{ index .Annotations "summary"}}</del>
😌 <del>{{ index .Annotations "summary"}}</del>
{{- end }}
{{end -}}
{{end}}

View File

@@ -1,13 +1,82 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
let
autowifi = pkgs.writers.writePython3Bin "autowifi" { flakeIgnore = [ "E501" ]; } <stockholm/lass/5pkgs/autowifi/autowifi.py>;
profile = name: custom: lib.recursiveUpdate {
connection.id = name;
connection.type = "wifi";
connection.interface-name = "wlp3s0";
connection.permissions = "";
wifi.mac-address-blacklist = "";
wifi.ssid = name;
wifi.mode = "infrastructure";
ipv4.dns-search = "";
ipv4.method = "auto";
ipv6.addr-gen-mode = "stable-privacy";
ipv6.dns-search = "";
ipv6.method = "auto";
proxy = {};
} custom;
eduroamProfile = {
connection.uuid = "eae9fee6-a7d2-4120-a609-440b457d6fcf";
wifi-security = {
group = "ccmp;tkip;";
key-mgmt = "wpa-eap";
pairwise = "ccmp;";
proto = "rsn;";
};
"802-1x" = {
altsubject-matches = "DNS:srv1-radius.cms.hu-berlin.de;DNS:srv2-radius.cms.hu-berlin.de;";
anonymous-identity = "anonymous@wlan.hu-berlin.de";
ca-cert = pkgs.fetchurl {
url = "https://www.cms.hu-berlin.de/de/dl/netze/wlan/config/eduroam/t-telesec_globalroot_class_2.pem";
sha256 = "0if8aqd06sid7a0vw009zpa087wxcgdd2x6z2zs4pis5kvyqj2dk";
};
eap = "ttls;";
identity = lib.strings.fileContents <secrets/eduroam/identity>;
password = lib.strings.fileContents <secrets/eduroam/password>;
phase2-auth = "pap";
};
};
in
{
imports = [ <niveum/modules/networkmanager-declarative.nix> ];
networking.networkmanager = {
enable = true;
wifi.macAddress = "random";
ethernet.macAddress = "random";
unmanaged = [ "docker*" ];
profiles = lib.mapAttrs profile {
Aether = {
connection.uuid = "7138bb0f-1aeb-4905-890e-a6628427aa21";
wifi-security = {
psk = lib.strings.fileContents <secrets/wifi/Aether.psk>;
auth-alg = "open";
key-mgmt = "wpa-psk";
};
};
FactoryCommunityGuest = {
connection.uuid = "fb1f2e52-651e-48b5-a72c-1accddf31afb";
connection.timestamp = "1631885129";
wifi.seen-bssids = "54:EC:2F:19:30:DC;54:EC:2F:19:5C:9C;54:EC:2F:58:E4:3C;";
wifi-security = {
psk = "Factory4ever";
auth-alg = "open";
key-mgmt = "wpa-psk";
};
};
o2-WLAN66 = {
connection.uuid = "c563aec3-f344-4ffb-8d1c-60a6cdac8fe0";
wifi-security = {
psk = "PK3468KV488T934U";
auth-alg = "open";
key-mgmt = "wpa-psk";
};
};
"WIFI@DB".connection.uuid = "4eff4e94-8850-4e9f-a338-1787d0d90479";
eduroam = eduroamProfile;
eduroam_5GHz = eduroamProfile;
};
};
users.users.me.extraGroups = [ "networkmanager" ];

View File

@@ -5,15 +5,6 @@ let
radioStore = "/var/lib/radio";
htgenPort = 8080;
stations = {
meddl = {
streamPort = 8000;
mpdPort = 6600;
description = ''
Drachenlord-Radio. Kopie von <a href="https://antenne-asb.ga/">Hit Radio Antenne ASB</a>, dem Anti-Mobbing-Sender.
<em>Hier wird nicht nur, aber auch Meddl gespielt.
Für dich On Air einer unserer Top Moderatoren Rainer Winkler. Als einer der größten Meddler aller Zeiten, hat er sich schon in seiner Kinheit einen Namen gemacht. Auch wenn er dem Meddl zugeneigt ist und HipHop-Kaschber eigentlich hasst, spielt er mittlerweile gelegentlich auch Techno oder HipHop.</em>
'';
};
lyrikline = {
streamPort = 8001;
mpdPort = 6601;
@@ -113,25 +104,6 @@ in
)"
url="$(cat ${radioStore}/$hash)"
echo "<html><body style='margin:0'><iframe style='width:100%;height:100%;border:0' src="$url"></iframe></body></html>"
exit
;;
"POST /meddl/skip")
send200
${mpcs.meddl}/bin/mpc-meddl next
exit
;;
"GET /meddl/status")
send200
hash="$(
${mpcs.meddl}/bin/mpc-meddl status -f '%file%' \
| head -n 1 \
| md5sum \
| cut -d' ' -f 1
)"
url="$(cat ${radioStore}/$hash)"
echo "<html><body style='margin:0'><iframe style='width:100%;height:100%;border:0' src="$url"></iframe></body></html>"
exit
;;
@@ -220,40 +192,6 @@ in
};
systemd.services.meddl = {
after = [ "container@meddl.service" ];
wantedBy = [ "container@meddl.service" ];
startAt = "*:00/10";
serviceConfig.User = config.users.extraUsers.radio.name;
preStart = "${mpcs.meddl}/bin/mpc-meddl crop || :";
script = ''
set -efu
host=http://antenne-asb.ga
prepend_host() {
sed "s#^#$host/#"
}
${pkgs.curl}/bin/curl -sSL "$host" \
| ${pkgs.pup}/bin/pup 'li a attr{href}' \
| prepend_host \
| while read -r song; do
song_url="$(${pkgs.curl}/bin/curl -sSL "$song" \
| ${pkgs.pup}/bin/pup 'audio source attr{src}' \
| prepend_host
)"
hash="$(echo "$song_url" | md5sum | cut -d' ' -f 1)"
echo "$song_url ($hash) -> $song"
echo "$song" > "${radioStore}/$hash"
${mpcs.meddl}/bin/mpc-meddl add "$song_url"
done
${mpcs.meddl}/bin/mpc-meddl play
'';
};
services.nginx.virtualHosts."radio.xn--kiern-0qa.de" = {
enableACME = true;
forceSSL = true;
@@ -269,7 +207,6 @@ in
index index.html;
'';
# skip
"= /meddl/skip".proxyPass = "http://127.0.0.1:${toString htgenPort}";
}
] ++ (lib.mapAttrsToList (name: station: {
"= /${name}/status".proxyPass = "http://127.0.0.1:${toString htgenPort}";

View File

@@ -49,12 +49,6 @@ in [
logo = "http://lassul.us/art/portraits/selbstportrait.jpg";
desc = "Diminutive from lassus (weary, faint, tired). A programming human. Doing superior professional art.";
}
{
stream = "https://radio.xn--kiern-0qa.de/meddl/listen.ogg";
station = "Meddl";
logo = "https://antenne-asb.ga/logo.png";
desc = "Forked from antenne-asb.ga: Radiosender zum Youtuber Drachenlord. Hier läuft den ganzen Tag Drachenlord Musik von Haidern oder Podcasts zum Lord.";
}
{
stream = "https://radio.xn--kiern-0qa.de/lyrik/listen.ogg";
station = "Lyrik";

View File

@@ -0,0 +1,50 @@
# https://github.com/jmackie/nixos-networkmanager-profiles/
{ lib, config, ... }:
with lib;
let
nm = config.networking.networkmanager;
mkProfile = profileAttrs:
if !(isAttrs profileAttrs) then
throw "error 1"
else {
enable = true;
mode = "0400"; # readonly (user)
text = (foldlAttrs (accum:
{ name, value }: ''
${accum}
[${name}] ${mkProfileEntry value}'')
"# Generated by nixos-networkmanager-profiles" profileAttrs) + "\n";
};
mkProfileEntry = entryAttrs:
if !(isAttrs entryAttrs) then
throw "error 2"
else
foldlAttrs (accum:
{ name, value }: ''
${accum}
${name}=${toString value}'') "" entryAttrs;
foldlAttrs = op: nul: attrs:
foldl (accum: { fst, snd }: op accum (nameValuePair fst snd)) nul
(lists.zipLists (attrNames attrs) (attrValues attrs));
attrLength = attrs: length (attrValues attrs);
in {
options.networking.networkmanager.profiles = mkOption {
type = types.attrs;
default = { };
};
config = mkIf (attrLength nm.profiles > 0) {
environment.etc = (foldlAttrs (accum:
{ name, value }:
accum // {
"NetworkManager/system-connections/${name}.nmconnection" =
mkProfile value;
}) { } nm.profiles);
};
}