Compare commits

...
31 Commits
Author SHA1 Message Date
bot 3c9802ffc7 Merge pull request 'Lock file maintenance' (#335) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-11-15 03:04:11 +01:00
Renovate Bot 5e87128f4b Lock file maintenance
update.yml (push) Invalid workflow file
2026-11-15 02:04:09 +00:00
bot 6c8449103c Merge pull request 'Lock file maintenance' (#334) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-11-14 03:04:00 +01:00
Renovate Bot 83836af9b1 Lock file maintenance
update.yml (push) Invalid workflow file
2026-11-14 02:03:58 +00:00
bot 52d956f169 Merge pull request 'Lock file maintenance' (#333) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-11-08 03:03:51 +01:00
Renovate Bot 14dc52b584 Lock file maintenance
update.yml (push) Invalid workflow file
2026-11-08 02:03:49 +00:00
bot 55fc4e90d1 Merge pull request 'Lock file maintenance' (#332) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-11-07 03:04:52 +01:00
Renovate Bot fd4c3d9a3d Lock file maintenance
update.yml (push) Invalid workflow file
2026-11-07 02:04:50 +00:00
sora 6998f64d88 wg routing fix
update.yml (push) Invalid workflow file
2026-11-01 12:12:59 +01:00
sora 9a99024688 vpn mode to eww 2026-11-01 12:12:59 +01:00
bot 086d8651ff Merge pull request 'Lock file maintenance' (#331) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-11-01 03:04:38 +01:00
Renovate Bot 0b7dd8f725 Lock file maintenance
update.yml (push) Invalid workflow file
2026-11-01 02:04:34 +00:00
bot 4f572289a6 Merge pull request 'Lock file maintenance' (#330) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-10-31 03:04:28 +01:00
Renovate Bot f7eaf5da47 Lock file maintenance
update.yml (push) Invalid workflow file
2026-10-31 02:04:26 +00:00
sora 208e7cb2b2 Improve eww
update.yml (push) Invalid workflow file
2026-10-30 16:01:01 +01:00
bot 6e2601a39c Merge pull request 'Lock file maintenance' (#329) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-10-25 03:03:40 +01:00
Renovate Bot 07e14bf4e5 Lock file maintenance
update.yml (push) Invalid workflow file
2026-10-25 02:03:37 +00:00
bot 1657357da4 Merge pull request 'Lock file maintenance' (#328) from renovate/lock-file-maintenance into main
update.yml (push) Invalid workflow file
2026-10-24 04:04:50 +02:00
Renovate Bot dfa4797354 Lock file maintenance
update.yml (push) Invalid workflow file
2026-10-24 02:04:49 +00:00
bot 95aa3ad114 Merge pull request 'Update DeterminateSystems/magic-nix-cache-action action to v15' (#312) from renovate/determinatesystems-magic-nix-cache-action-15.x into main
update.yml (push) Invalid workflow file
2026-10-24 04:04:09 +02:00
Renovate Bot 6162403cdd Update DeterminateSystems/magic-nix-cache-action action to v15
update.yml (push) Invalid workflow file
2026-10-24 02:04:08 +00:00
sora cd42a892ee Merge pull request 'Update DeterminateSystems/flake-checker-action action to v14' (#314) from renovate/determinatesystems-flake-checker-action-14.x into main
update.yml (push) Invalid workflow file
Reviewed-on: #314
2026-10-23 09:17:40 +02:00
sora bb5b9930cd Merge pull request 'Update actions/checkout action to v7' (#313) from renovate/actions-checkout-7.x into main
update.yml (push) Invalid workflow file
Reviewed-on: #313
2026-10-23 09:17:16 +02:00
bot 7f726d7d00 Merge pull request 'Lock file maintenance' (#327) from renovate/lock-file-maintenance into main 2026-10-18 04:03:59 +02:00
Renovate Bot f4ab310e1b Lock file maintenance 2026-10-18 02:03:57 +00:00
bot c4407f9b36 Merge pull request 'Lock file maintenance' (#326) from renovate/lock-file-maintenance into main 2026-10-17 04:03:48 +02:00
Renovate Bot f1375b486b Lock file maintenance 2026-10-17 02:03:46 +00:00
bot 7137dab031 Merge pull request 'Lock file maintenance' (#325) from renovate/lock-file-maintenance into main 2026-10-11 04:04:04 +02:00
Renovate Bot 02b45cca9b Lock file maintenance 2026-10-11 02:04:02 +00:00
Renovate Bot 3b688d50ef Update DeterminateSystems/flake-checker-action action to v14 2026-09-11 02:02:39 +00:00
Renovate Bot fe2b38e78f Update actions/checkout action to v7 2026-09-11 02:02:36 +00:00
13 changed files with 280 additions and 48 deletions

No files matched your search

+3 -3
View File
@@ -12,14 +12,14 @@ jobs:
build-nixos: build-nixos:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v7
- name: "Install Nix ❄️" - name: "Install Nix ❄️"
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v31
# - uses: DeterminateSystems/nix-installer-action@v4 # - uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@v13 - uses: DeterminateSystems/magic-nix-cache-action@v15
- uses: DeterminateSystems/flake-checker-action@v12 - uses: DeterminateSystems/flake-checker-action@v14
- name: "Install Cachix ❄️" - name: "Install Cachix ❄️"
uses: cachix/cachix-action@v17 uses: cachix/cachix-action@v17
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v7
- name: Install nix - name: Install nix
uses: DeterminateSystems/nix-installer-action@v23 uses: DeterminateSystems/nix-installer-action@v23
with: with:
Generated
+24 -24
View File
@@ -23,11 +23,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1786845137, "lastModified": 1793418699,
"narHash": "sha256-oQFip+v0luP8NIxJzmiW4Wu8bILsbFWom5l0zonl8hQ=", "narHash": "sha256-+RpTlcdh9KqZ+ZiLkNSTvibQWm935EcIdBzRPCTFsrQ=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "4cff07de74b50e64bdd68cd4e722ab5b6b35ee48", "rev": "ff0e21a414d4547183396da1b44a66f2577b65e9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -76,11 +76,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1791373788, "lastModified": 1794597451,
"narHash": "sha256-c3oMt0QoE+4yiRk6u1m2L9ogjaUw0uTGn9yk808KkgE=", "narHash": "sha256-bUkc9dMpCFiJuuf5Efr7pnCDs5q18aA8zJah+MYZl9w=",
"owner": "nixos", "owner": "nixos",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "4bc63156b109ee7b4103e3ec30565c8c92bde435", "rev": "eb3c90bd715f7a9a28719bb014f53d309ccb2fc8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -96,11 +96,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1790996401, "lastModified": 1794251182,
"narHash": "sha256-f+kOxEmOUnQazVAmGg0i8hzwgd1kX/geY+k/Dpheye8=", "narHash": "sha256-R2sZBXiOJo3HAnvTiVkbbHDJy//JMlAwUKEiPbfqPXk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "db7d5e2332710f5abb088f6b5de927d7f9511b35", "rev": "6eb2d33d1d0c95a37ef6443c88e6c1686012ee8b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -131,11 +131,11 @@
}, },
"nixUnstable": { "nixUnstable": {
"locked": { "locked": {
"lastModified": 1791366222, "lastModified": 1794495034,
"narHash": "sha256-o0N4g6uSOIppU7CGToNvGlMf5vC+B6O6ukFHKY/TKOY=", "narHash": "sha256-E0hYoioqUtM2XmPPvYYpJgdADF5AW9oOoPSEiM9dTHQ=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "39ad350a0602fa0a58a544344e3e9187526ea45c", "rev": "2074cc672349f14240fb7ea90d509e0b643e9dd4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -153,11 +153,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1789164534, "lastModified": 1794368463,
"narHash": "sha256-DoYGPM6QpnYBLWj9gGw6ZwAzIX+HrAVov1BoT+8Jixo=", "narHash": "sha256-ncpk0eCCyhU7M7U/PGbtwb1PXqobksBBYbJJ13abV2g=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-wsl", "repo": "nixos-wsl",
"rev": "72c92b11bb8289e6651c7fef29cc0a885fd6a255", "rev": "05721a428830972f025a8575b1a19c418d422d1b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -211,11 +211,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1791426274, "lastModified": 1794552581,
"narHash": "sha256-MWhktfFtFE8Jl7bf9Pkp7TR5MSdYCjCswSo0Gkb4ywc=", "narHash": "sha256-qXFIqA6FCcx7XeDzw0ZNlkDT9UiCzrNDwK8RuU8RcHM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7c8764b7c7b09b34f632464276218ef9090eaa11", "rev": "f1e5c356f35d07e7b71a6b5e6c9338e0b029e0c0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -245,11 +245,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1791103873, "lastModified": 1794624949,
"narHash": "sha256-nFxM+pKoZ8LJAEnUXARyCaOAloWgaW9kZQOSjWzKcTE=", "narHash": "sha256-3q/hxp/flW1PnV3Dx+H3p8kHGEHJ7251BqVMNsAAB9E=",
"owner": "Mic92", "owner": "Mic92",
"repo": "sops-nix", "repo": "sops-nix",
"rev": "dcd241ba97088c22569d1573286e1b9daad340c0", "rev": "11e5885d241743ff0193465d533b20e754bc3ce0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -263,11 +263,11 @@
"flake-parts": "flake-parts" "flake-parts": "flake-parts"
}, },
"locked": { "locked": {
"lastModified": 1784312229, "lastModified": 1794081290,
"narHash": "sha256-2uHCSUw341o3my1R0U0YCfbnMEazylxb58evWsjGL50=", "narHash": "sha256-vJCjuYXp06XZ9rufttvv/W3mkzQzefYxEvmmsZfUmvw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-vscode-server", "repo": "nixos-vscode-server",
"rev": "2f984dfbe7e5271b5c413d3e734374cc1306c921", "rev": "e8aac40ed8d76486859741b1608badeca3475943",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -23,6 +23,7 @@
@include border-radius; @include border-radius;
font-size: 1.1em; font-size: 1.1em;
} }
.net-add-btn { margin-right: $popup-scale * 2pt; }
// Bluetooth device list // Bluetooth device list
.bt-device-row { margin-bottom: $popup-scale * 4pt; } .bt-device-row { margin-bottom: $popup-scale * 4pt; }
@@ -1,5 +1,5 @@
(deflisten net (deflisten net
:initial '{"wifi":{"connected":false,"enabled":false,"icon":"󰤮","ssid":"","ip":"","freq":0,"band":"","gen":"","signal":0},"ethernet":{"connected":false,"interface":"","ip":"","speed":""},"usb":{"connected":false,"interface":"","ip":""},"wireguard":[],"vpn":{"up":false,"name":""}}' :initial '{"wifi":{"connected":false,"enabled":false,"icon":"󰤮","ssid":"","ip":"","freq":0,"band":"","gen":"","signal":0},"ethernet":{"connected":false,"interface":"","ip":"","speed":""},"usb":{"connected":false,"interface":"","ip":""},"wireguard":[],"vpn":{"up":false,"full":false,"name":""}}'
"scripts/net/net") "scripts/net/net")
(deflisten bt (deflisten bt
@@ -23,7 +23,7 @@
(label (label
:visible {net.vpn.up} :visible {net.vpn.up}
:class "net-icon net-active" :class "net-icon net-active"
:tooltip "VPN: ${net.vpn.name}" :tooltip {net.vpn.full ? "VPN: all traffic through ${net.vpn.name}" : "WireGuard: ${net.vpn.name}"}
:text "󰖂") :text "󰖂")
(label (label
:class "net-icon ${net.wifi.connected ? 'net-active' : 'net-dim'}" :class "net-icon ${net.wifi.connected ? 'net-active' : 'net-dim'}"
@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Network state for the bar icons and the net panel: wifi, ethernet and USB # Network state for the bar icons and the net panel: wifi, ethernet and USB
# tethering. Refreshes on link/address changes and every 30 s (signal level). # tethering. Refreshes on link/address/rule changes and every 30 s (signal level).
wifi_iface() { awk 'NR > 2 { sub(":", "", $1); print $1; exit }' /proc/net/wireless; } wifi_iface() { awk 'NR > 2 { sub(":", "", $1); print $1; exit }' /proc/net/wireless; }
eth_iface() { ip -o link 2>/dev/null | awk '$2 ~ /^en[op]/ { sub(":", "", $2); print $2; exit }'; } eth_iface() { ip -o link 2>/dev/null | awk '$2 ~ /^en[op]/ { sub(":", "", $2); print $2; exit }'; }
@@ -84,7 +84,7 @@ state() {
wg_ifaces() { wg_ifaces() {
{ {
systemctl list-units --all --plain --no-legend 'wireguard-*.service' 2>/dev/null \ systemctl list-units --all --plain --no-legend 'wireguard-*.service' 2>/dev/null \
| awk '$1 !~ /-peer-/ { sub(/^wireguard-/, "", $1); sub(/\.service$/, "", $1); print $1 }' | awk '$1 !~ /-peer-|-vpn\.service$/ { sub(/^wireguard-/, "", $1); sub(/\.service$/, "", $1); print $1 }'
ip -d -o link 2>/dev/null | awk '/ wireguard / { sub(":", "", $2); print $2 }' ip -d -o link 2>/dev/null | awk '/ wireguard / { sub(":", "", $2); print $2 }'
} | sort -u } | sort -u
} }
@@ -97,10 +97,12 @@ human_bytes() {
} }
wg_json() { # prints the "wireguard" array and the "vpn" summary wg_json() { # prints the "wireguard" array and the "vpn" summary
local name up ip rx tx peers endpoint peer_unit peer_script sep="" out="[" vpn_up=false vpn_name="" local name up ip rx tx peers endpoint peer_unit peer_script vpn_able vpn sep="" out="[" vpn_up=false vpn_name="" vpn_full=false
while read -r name; do while read -r name; do
[[ -n $name ]] || continue [[ -n $name ]] || continue
up=false ip="" rx=0 tx=0 endpoint="" up=false ip="" rx=0 tx=0 endpoint="" vpn_able=false vpn=false
[[ $(systemctl show -p LoadState --value "wireguard-$name-vpn.service" 2>/dev/null) == loaded ]] && vpn_able=true
systemctl is-active --quiet "wireguard-$name-vpn.service" 2>/dev/null && vpn=true
if [[ -d /sys/class/net/$name ]]; then if [[ -d /sys/class/net/$name ]]; then
ip -o link show "$name" 2>/dev/null | grep -q '<[^>]*UP' && up=true ip -o link show "$name" 2>/dev/null | grep -q '<[^>]*UP' && up=true
ip=$(ipv4 "$name") ip=$(ipv4 "$name")
@@ -120,14 +122,15 @@ wg_json() { # prints the "wireguard" array and the "vpn" summary
fi fi
if [[ $up == true && $vpn_up == false ]]; then vpn_up=true vpn_name=$name; fi if [[ $up == true && $vpn_up == false ]]; then vpn_up=true vpn_name=$name; fi
[[ -z $vpn_name ]] && vpn_name=$name [[ -z $vpn_name ]] && vpn_name=$name
out+="$sep{\"name\":\"$(jstr "$name")\",\"up\":$up,\"ip\":\"$ip\",\"rx\":\"$(human_bytes "$rx")\",\"tx\":\"$(human_bytes "$tx")\",\"peers\":\"$(jstr "$peers")\",\"endpoint\":\"$(jstr "$endpoint")\"}" [[ $vpn == true ]] && vpn_full=true vpn_name=$name
out+="$sep{\"name\":\"$(jstr "$name")\",\"up\":$up,\"ip\":\"$ip\",\"rx\":\"$(human_bytes "$rx")\",\"tx\":\"$(human_bytes "$tx")\",\"peers\":\"$(jstr "$peers")\",\"endpoint\":\"$(jstr "$endpoint")\",\"vpn_able\":$vpn_able,\"vpn\":$vpn}"
sep=, sep=,
done < <(wg_ifaces) done < <(wg_ifaces)
printf '"wireguard":%s],"vpn":{"up":%s,"name":"%s"}' "$out" "$vpn_up" "$(jstr "$vpn_name")" printf '"wireguard":%s],"vpn":{"up":%s,"full":%s,"name":"%s"}' "$out" "$vpn_up" "$vpn_full" "$(jstr "$vpn_name")"
} }
refresh() { emit "$(state)"; } refresh() { emit "$(state)"; }
_link_events() { exec ip monitor link address; } _link_events() { exec ip monitor link address rule; }
refresh refresh
mux_init mux_init
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Toggle VPN mode (all traffic through the tunnel) of WireGuard interface $1,
# independently of the tunnel itself. Starting it brings the tunnel up.
# Needs the polkit rule from modules/nixos/system/network/wireguard.
name=$1
[[ -n $name ]] || exit 64
detach_self "$@"
unit=wireguard-$name-vpn.service
if systemctl is-active --quiet "$unit"; then
systemctl stop "$unit"
else
systemctl start "$unit"
fi
+111
View File
@@ -0,0 +1,111 @@
#!/usr/bin/env bash
# Pick a nearby WiFi network in wofi and connect to it through wpa_supplicant
# (userControlled: the control socket is open to wheel). Networks added here
# live in wpa_supplicant's memory only — the config file is a sops secret and
# is never rewritten — so they are gone after a reboot.
detach_self "$@"
eww close popup 2>/dev/null
eww update active-panel= 2>/dev/null
iface=""
for s in /run/wpa_supplicant/*; do
[[ -S $s && ${s##*/} != p2p-* ]] && { iface=${s##*/}; break; }
done
notify() { notify-send -a WiFi -i network-wireless "$@"; }
[[ -n $iface ]] || { notify "WiFi" "wpa_supplicant is not running"; exit 1; }
wpa() { wpa_cli -g "/run/wpa_supplicant/$iface" "$@"; }
field() { awk -F= -v k="$1" '$1 == k { print substr($0, length(k) + 2); exit }'; }
signal_icon() {
if (($1 >= -50)); then echo "󰤨"
elif (($1 >= -60)); then echo "󰤥"
elif (($1 >= -70)); then echo "󰤢"
elif (($1 >= -80)); then echo "󰤟"
else echo "󰤯"; fi
}
# wpa_cli prints SSIDs with printf-style escapes (\xNN, \\, \")
unescape() { printf '%b' "$1"; }
saved_id() { # SSID → network id
local id s
while IFS=$'\t' read -r id s _; do
[[ $(unescape "$s") == "$1" ]] && { echo "$id"; return; }
done < <(wpa list_networks | tail -n +2)
}
wpa scan >/dev/null
sleep 2
current=$(unescape "$(wpa status | field ssid)")
declare -A ssid_of flags_of
lines=()
# strongest BSS per SSID, strongest first; hidden networks are skipped
while IFS=$'\t' read -r sig flags raw; do
ssid=$(unescape "$raw")
[[ -n $ssid && $ssid != *$'\n'* ]] || continue
line="$(signal_icon "$sig") $ssid"
[[ $flags == *PSK* || $flags == *SAE* || $flags == *EAP* ]] && line+=" 󰌾"
[[ $ssid == "$current" ]] && line+=" 󰄬"
ssid_of[$line]=$ssid
flags_of[$line]=$flags
lines+=("$line")
done < <(wpa scan_results | awk -F'\t' '
NR > 1 && $5 != "" { if (!($5 in best) || $3 > best[$5]) { best[$5] = $3; flags[$5] = $4 } }
END { for (s in best) printf "%s\t%s\t%s\n", best[s], flags[s], s }' | sort -t$'\t' -k1,1nr)
((${#lines[@]})) || { notify "WiFi" "No networks found"; exit 0; }
choice=$(printf '%s\n' "${lines[@]}" | wofi --dmenu -p "WiFi")
[[ -n $choice && -n ${ssid_of[$choice]+x} ]] || exit 0
ssid=${ssid_of[$choice]}
flags=${flags_of[$choice]}
[[ $ssid == "$current" ]] && exit 0
id=$(saved_id "$ssid")
new=0
if [[ -z $id ]]; then
[[ $flags == *EAP* ]] && { notify "$ssid" "Enterprise (EAP) networks are not supported"; exit 1; }
id=$(wpa add_network | tail -n 1)
[[ $id =~ ^[0-9]+$ ]] || { notify "$ssid" "Could not add the network"; exit 1; }
new=1
wpa set_network "$id" ssid "$(printf '%s' "$ssid" | od -An -tx1 | tr -d ' \n')" >/dev/null
if [[ $flags == *PSK* || $flags == *SAE* ]]; then
psk=$(wofi --dmenu --password -p "Password for $ssid" </dev/null)
if ((${#psk} < 8 || ${#psk} > 63)); then
wpa remove_network "$id" >/dev/null
[[ -n $psk ]] && notify "$ssid" "The password must be 8 to 63 characters"
exit 1
fi
wpa set_network "$id" psk "\"$psk\"" >/dev/null
if [[ $flags == *SAE* ]]; then
wpa set_network "$id" key_mgmt WPA-PSK SAE >/dev/null
wpa set_network "$id" ieee80211w 1 >/dev/null
fi
else
wpa set_network "$id" key_mgmt NONE >/dev/null
fi
fi
# select_network disables every other network; re-enable them afterwards so
# the saved ones still auto-connect later.
wpa select_network "$id" >/dev/null
for ((i = 0; i < 30; i++)); do
sleep 0.5
st=$(wpa status)
if [[ $(field wpa_state <<<"$st") == COMPLETED && $(field id <<<"$st") == "$id" ]]; then
wpa enable_network all >/dev/null
notify "Connected" "$ssid"
exit 0
fi
done
((new)) && wpa remove_network "$id" >/dev/null
wpa enable_network all >/dev/null
wpa reassociate >/dev/null
notify "Could not connect to $ssid" "$( ((new)) && echo "Wrong password?" || echo "Timed out")"
exit 1
@@ -15,8 +15,9 @@ api="https://www.radiorecord.ru/api"
unit=eww-radio unit=eww-radio
state_dir=${XDG_STATE_HOME:-$HOME/.local/state}/eww state_dir=${XDG_STATE_HOME:-$HOME/.local/state}/eww
cache_dir=${XDG_CACHE_HOME:-$HOME/.cache}/eww cache_dir=${XDG_CACHE_HOME:-$HOME/.cache}/eww
img_dir=$cache_dir/radio-img
id_file=$state_dir/radio-station id_file=$state_dir/radio-station
mkdir -p "$state_dir" "$cache_dir" mkdir -p "$state_dir" "$cache_dir" "$img_dir"
station_ids='[507,522,523,536,537,42532,42602]' station_ids='[507,522,523,536,537,42532,42602]'
# Extra stations: {id (unique integer >= 1000000), title, stream_hls, icon_fill_white ("" for none)} # Extra stations: {id (unique integer >= 1000000), title, stream_hls, icon_fill_white ("" for none)}
@@ -47,6 +48,32 @@ stations() {
printf '%s\n' "$out" printf '%s\n' "$out"
} }
# GTK loads CSS url() images synchronously on the UI thread: a remote URL
# freezes the whole daemon until the download finishes (or times out). eww
# only ever gets file:// URIs of cached copies.
local_img() { # URL → file:// URI, "" if unavailable
local url=$1 f
case $url in
file://*) printf '%s' "$url"; return ;;
/*) printf 'file://%s' "$url"; return ;;
http://* | https://*) ;;
*) return ;;
esac
f=$img_dir/$(cksum <<<"$url" | cut -d' ' -f1)
if [[ ! -s $f ]]; then
curl -sfL --max-time 5 -o "$f.tmp" "$url" 2>/dev/null && mv "$f.tmp" "$f" || { rm -f "$f.tmp"; return; }
fi
printf 'file://%s' "$f"
}
localize_stations() {
local url map='{}'
while IFS= read -r url; do
map=$(jq -c --arg k "$url" --arg v "$(local_img "$url")" '.[$k] = $v' <<<"$map")
done < <(jq -r '.[].icon_fill_white // empty' <<<"$STATIONS" | sort -u)
STATIONS=$(jq -c --argjson m "$map" 'map(.icon_fill_white = ($m[.icon_fill_white // ""] // ""))' <<<"$STATIONS")
}
station() { # ID FIELD station() { # ID FIELD
jq -r --argjson id "${1:-0}" --arg f "$2" 'first(.[] | select(.id == $id) | .[$f]) // empty' <<<"$STATIONS" jq -r --argjson id "${1:-0}" --arg f "$2" 'first(.[] | select(.id == $id) | .[$f]) // empty' <<<"$STATIONS"
} }
@@ -141,7 +168,8 @@ song_playing() { # ID → SONG from the station history (radiorecord) or the tit
if [[ $(station "$id" radiorecord) == true ]]; then if [[ $(station "$id" radiorecord) == true ]]; then
fetched=$(curl -sf --compressed --max-time 8 "$api/station/history/?id=$id" 2>/dev/null \ fetched=$(curl -sf --compressed --max-time 8 "$api/station/history/?id=$id" 2>/dev/null \
| jq -c '.result.history[0] | {artist: (.artist // ""), song: (.song // ""), image600: (.image600 // "")}' 2>/dev/null) | jq -c '.result.history[0] | {artist: (.artist // ""), song: (.song // ""), image600: (.image600 // "")}' 2>/dev/null)
[[ -n $fetched && $fetched != null ]] && SONG=$fetched [[ -n $fetched && $fetched != null ]] \
&& SONG=$(jq -c --arg i "$(local_img "$(jq -r .image600 <<<"$fetched")")" '.image600 = $i' <<<"$fetched")
else else
SONG=$(jq -cn --arg t "$(station "$id" title)" '{artist: "", song: $t, image600: ""}') SONG=$(jq -cn --arg t "$(station "$id" title)" '{artist: "", song: $t, image600: ""}')
fi fi
@@ -159,7 +187,7 @@ media_event() {
if [[ -z $player ]]; then if [[ -z $player ]]; then
MEDIA=$default_media MEDIA_PLAYER="" MEDIA=$default_media MEDIA_PLAYER=""
elif [[ $player != mpv* ]]; then # the radio and jellyfin are mpv, not "external" elif [[ $player != mpv* ]]; then # the radio and jellyfin are mpv, not "external"
MEDIA=$(media_json "$player" "$status" "$artist" "$title" "$art") MEDIA=$(media_json "$player" "$status" "$artist" "$title" "$(local_img "$art")")
MEDIA_PLAYER=$player MEDIA_PLAYER=$player
fi fi
} }
@@ -206,7 +234,9 @@ refresh() {
} }
status_loop() { status_loop() {
find "$img_dir" -type f -mtime +7 -delete 2>/dev/null
STATIONS=$(stations) STATIONS=$(stations)
localize_stations
SONG=$default_song MEDIA=$default_media MEDIA_PLAYER="" PLAYING="" LAST_SONG=0 LAST_VOL="" SONG=$default_song MEDIA=$default_media MEDIA_PLAYER="" PLAYING="" LAST_SONG=0 LAST_VOL=""
refresh refresh
mux_init mux_init
@@ -10,6 +10,7 @@
(box :orientation "h" :space-evenly false :valign "center" :class "sys-section-header" (box :orientation "h" :space-evenly false :valign "center" :class "sys-section-header"
(box :class "section-accent ${accent}") (box :class "section-accent ${accent}")
(label :class "sys-label" :text title :hexpand true :halign "start") (label :class "sys-label" :text title :hexpand true :halign "start")
(children)
(button (button
:class "net-toggle-btn ${enabled ? 'net-toggle-on' : 'net-toggle-off'}" :class "net-toggle-btn ${enabled ? 'net-toggle-on' : 'net-toggle-off'}"
:onclick onclick :onclick onclick
@@ -23,7 +24,13 @@
:title "WiFi" :accent "wifi-accent" :title "WiFi" :accent "wifi-accent"
:enabled {net.wifi.enabled} :enabled {net.wifi.enabled}
:onclick {net.wifi.enabled ? "rfkill block wlan" : "rfkill unblock wlan"} :onclick {net.wifi.enabled ? "rfkill block wlan" : "rfkill unblock wlan"}
:icon-on "󰤨" :icon-off "󰖪") :icon-on "󰤨" :icon-off "󰖪"
(button
:class "net-toggle-btn net-toggle-on net-add-btn"
:visible {net.wifi.enabled}
:onclick "scripts/net/wifi-connect"
:tooltip "Connect to a network"
(label :text "󰐕")))
(box :orientation "v" :space-evenly false (box :orientation "v" :space-evenly false
:visible {net.wifi.connected} :visible {net.wifi.connected}
(netinfo-row :label "SSID" :value {net.wifi.ssid}) (netinfo-row :label "SSID" :value {net.wifi.ssid})
@@ -89,12 +96,19 @@
(box :orientation "v" :space-evenly false :class "wg-row" (box :orientation "v" :space-evenly false :class "wg-row"
(box :orientation "h" :space-evenly false :valign "center" (box :orientation "h" :space-evenly false :valign "center"
(label :class "wg-name ${wg.up ? 'wg-up' : 'wg-down'}" :halign "start" :hexpand true :text {wg.name}) (label :class "wg-name ${wg.up ? 'wg-up' : 'wg-down'}" :halign "start" :hexpand true :text {wg.name})
(button
:class "net-toggle-btn net-add-btn ${wg.vpn ? 'net-toggle-on' : 'net-toggle-off'}"
:visible {wg.vpn_able}
:onclick "scripts/net/wg-vpn-toggle ${wg.name}"
:tooltip {wg.vpn ? "VPN: all traffic through ${wg.name}" : "VPN off: only the private subnet"}
(label :text "󰖟"))
(button (button
:class "net-toggle-btn ${wg.up ? 'net-toggle-on' : 'net-toggle-off'}" :class "net-toggle-btn ${wg.up ? 'net-toggle-on' : 'net-toggle-off'}"
:onclick "scripts/net/wg-toggle ${wg.name}" :onclick "scripts/net/wg-toggle ${wg.name}"
:tooltip {wg.up ? "Disconnect" : "Connect"} :tooltip {wg.up ? "Disconnect" : "Connect"}
(label :text {wg.up ? "󰖂" : "󰦞"}))) (label :text {wg.up ? "󰖂" : "󰦞"})))
(box :orientation "v" :space-evenly false :visible {wg.up} (box :orientation "v" :space-evenly false :visible {wg.up}
(netinfo-row :label "Routing" :value {wg.vpn ? "All traffic" : "Private subnet"})
(netinfo-row :label "IP" :value {wg.ip}) (netinfo-row :label "IP" :value {wg.ip})
(netinfo-row :label "Peer" :value {wg.endpoint != "" ? "${wg.peers} · ${wg.endpoint}" : wg.peers}) (netinfo-row :label "Peer" :value {wg.endpoint != "" ? "${wg.peers} · ${wg.endpoint}" : wg.peers})
(netinfo-row :label "Traffic" :value "󰇚 ${wg.rx} 󰕒 ${wg.tx}")) (netinfo-row :label "Traffic" :value "󰇚 ${wg.rx} 󰕒 ${wg.tx}"))
@@ -21,6 +21,8 @@ let
"scripts/net/bt" = mkScript "bt" ./bar/scripts/net/bt [ jq glib ]; "scripts/net/bt" = mkScript "bt" ./bar/scripts/net/bt [ jq glib ];
"scripts/net/bt-toggle" = mkScript "bt-toggle" ./bar/scripts/net/bt-toggle [ bluez ]; "scripts/net/bt-toggle" = mkScript "bt-toggle" ./bar/scripts/net/bt-toggle [ bluez ];
"scripts/net/wg-toggle" = mkScript "wg-toggle" ./bar/scripts/net/wg-toggle [ ]; "scripts/net/wg-toggle" = mkScript "wg-toggle" ./bar/scripts/net/wg-toggle [ ];
"scripts/net/wg-vpn-toggle" = mkScript "wg-vpn-toggle" ./bar/scripts/net/wg-vpn-toggle [ ];
"scripts/net/wifi-connect" = mkScript "wifi-connect" ./bar/scripts/net/wifi-connect [ eww wpa_supplicant wofi libnotify ];
"scripts/sys/gpu" = mkScript "gpu" ./bar/scripts/sys/gpu [ custom.amdgpu_top jq ]; "scripts/sys/gpu" = mkScript "gpu" ./bar/scripts/sys/gpu [ custom.amdgpu_top jq ];
"scripts/sys/memory" = mkScript "memory" ./bar/scripts/sys/memory [ ]; "scripts/sys/memory" = mkScript "memory" ./bar/scripts/sys/memory [ ];
"scripts/sys/battery" = mkScript "battery" ./bar/scripts/sys/battery [ ]; "scripts/sys/battery" = mkScript "battery" ./bar/scripts/sys/battery [ ];
@@ -51,6 +53,12 @@ in {
# graphical session, opens the bar once the daemon answers, and is # graphical session, opens the bar once the daemon answers, and is
# restarted on crash. `eww-bar` (packages/eww-bar) does the heavy # restarted on crash. `eww-bar` (packages/eww-bar) does the heavy
# lifting; kanshi calls `eww-bar place` to move the bar between outputs. # lifting; kanshi calls `eww-bar place` to move the bar between outputs.
home.activation.ewwReload = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
if ${pkgs.systemd}/bin/systemctl --user is-active --quiet eww.service; then
run ${ewwBar} reload || true
fi
'';
systemd.user.services.eww = { systemd.user.services.eww = {
Unit = { Unit = {
Description = "eww daemon and bar"; Description = "eww daemon and bar";
@@ -5,6 +5,37 @@
(p.syscfg.net.wg.enable == true) && (p.syscfg.net.wg.enable == true) &&
(p.syscfg.net.wg.pubkey != config.syscfg.net.wg.pubkey); (p.syscfg.net.wg.pubkey != config.syscfg.net.wg.pubkey);
activePeers = builtins.filter isValidPeer config.syscfg.peers; activePeers = builtins.filter isValidPeer config.syscfg.peers;
isServer = config.syscfg.server ? wireguard && config.syscfg.server.wireguard;
vpnPeer = {
name = "vpn-helcel";
publicKey = "NFBJvYXZC+bd62jhrKnM7/pugidWhgR6+C5qIiUiq3Q=";
allowedIPs = [ "10.10.1.0/24" "fd10:10:10::0/64" ];
};
vpnTable = "51820";
vpnDown = pkgs.writeShellScript "wg0-vpn-down" ''
PATH=${lib.makeBinPath [ pkgs.iproute2 pkgs.wireguard-tools ]}
for f in -4 -6; do
ip $f rule del pref 31000 2>/dev/null
ip $f rule del pref 31001 2>/dev/null
ip $f route flush table ${vpnTable} 2>/dev/null
done
wg set wg0 fwmark off peer ${vpnPeer.publicKey} allowed-ips ${lib.concatStringsSep "," vpnPeer.allowedIPs} 2>/dev/null
true
'';
vpnUp = pkgs.writeShellScript "wg0-vpn-up" ''
set -e
PATH=${lib.makeBinPath [ pkgs.iproute2 pkgs.wireguard-tools pkgs.procps ]}
${vpnDown}
sysctl -q net.ipv4.conf.all.src_valid_mark=1
wg set wg0 fwmark ${vpnTable} peer ${vpnPeer.publicKey} allowed-ips 0.0.0.0/0,::/0
for f in -4 -6; do
ip $f route replace default dev wg0 table ${vpnTable}
ip $f rule add table main suppress_prefixlength 0 pref 31000
ip $f rule add not fwmark ${vpnTable} table ${vpnTable} pref 31001
done
'';
in in
{ {
config = lib.mkIf (config.syscfg.net.wg.enable) { config = lib.mkIf (config.syscfg.net.wg.enable) {
@@ -18,20 +49,17 @@ in
listenPort = 1515; listenPort = 1515;
mtu = 1340; mtu = 1340;
peers = peers =
if (config.syscfg.server ? wireguard && config.syscfg.server.wireguard) then if isServer then
map (p: { map (p: {
name = p.syscfg.hostname; name = p.syscfg.hostname;
publicKey = p.syscfg.net.wg.pubkey; publicKey = p.syscfg.net.wg.pubkey;
allowedIPs = [ p.syscfg.net.wg.ip4 p.syscfg.net.wg.ip6 ]; allowedIPs = [ p.syscfg.net.wg.ip4 p.syscfg.net.wg.ip6 ];
}) activePeers }) activePeers
else else
[{ [(vpnPeer // {
allowedIPs = [ "10.10.1.0/24" "fd10:10:10::0/64" ];
name = "vpn-helcel";
endpoint = "vpn.helcel.net:1515"; endpoint = "vpn.helcel.net:1515";
publicKey = "NFBJvYXZC+bd62jhrKnM7/pugidWhgR6+C5qIiUiq3Q=";
persistentKeepalive = 30; persistentKeepalive = 30;
}]; })];
}; };
}; };
}; };
@@ -59,7 +87,23 @@ in
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; # Wait 2 seconds before retrying the domain query RestartSec = "10s"; # Wait 2 seconds before retrying the domain query
}; };
startLimitIntervalSec = 0; startLimitIntervalSec = 0;
}; };
systemd.services."wireguard-wg0-vpn" = lib.mkIf (!isServer) {
description = "WireGuard wg0 - route all traffic";
bindsTo = [ "wireguard-wg0.service" ];
wants = [ "wireguard-wg0-peer-vpn-helcel.service" ];
partOf = [ "wireguard-wg0-peer-vpn-helcel.service" ];
after = [ "wireguard-wg0.service" "wireguard-wg0-peer-vpn-helcel.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = vpnUp;
ExecStop = vpnDown;
};
};
networking.firewall.checkReversePath = lib.mkIf (!isServer) "loose";
}; };
} }
+8
View File
@@ -1,6 +1,9 @@
{ config, lib, ... }: { config, lib, ... }:
let let
cfg = config.syscfg.server; cfg = config.syscfg.server;
wg = cfg.wireguard && config.syscfg.net.wg.enable;
wgIp4 = builtins.head (lib.splitString "/" config.syscfg.net.wg.ip4);
wgIp6 = builtins.head (lib.splitString "/" config.syscfg.net.wg.ip6);
in { in {
config = lib.mkIf (cfg.ipfw.enable) { config = lib.mkIf (cfg.ipfw.enable) {
boot.kernel.sysctl = { boot.kernel.sysctl = {
@@ -27,6 +30,11 @@ in {
iifname "${srcInt}" tcp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort} iifname "${srcInt}" tcp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort}
iifname "${srcInt}" udp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort} iifname "${srcInt}" udp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort}
'' + lib.optionalString wg ''
iifname "wg0" fib daddr type local ip daddr != ${wgIp4} tcp dport ${srcPort} counter dnat ip to ${dstAddr4}:${dstPort}
iifname "wg0" fib daddr type local ip daddr != ${wgIp4} udp dport ${srcPort} counter dnat ip to ${dstAddr4}:${dstPort}
iifname "wg0" fib daddr type local ip6 daddr != ${wgIp6} tcp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort}
iifname "wg0" fib daddr type local ip6 daddr != ${wgIp6} udp dport ${srcPort} counter dnat ip6 to [${dstAddr6}]:${dstPort}
'' ''
) cfg.ipfw.ports} ) cfg.ipfw.ports}
} }