mob next [ci-skip] [ci skip] [skip ci]

lastFile:flake.nix
This commit is contained in:
2025-12-01 14:44:10 +07:00
parent 938ab2bdd2
commit ee05c0dad4
5 changed files with 51 additions and 1 deletions

View File

@@ -44,6 +44,7 @@
./machines
./routers
./inventories
./overlays
./modules/clan/flake-module.nix
./modules/nixos/flake-module.nix
];

11
lib/default.nix Normal file
View File

@@ -0,0 +1,11 @@
final: prev:
let
callLibs = file: import file { lib = prev; };
in
{
lib = prev.lib.extend (
finalLib: prevLib: {
getInterface = callLibs ./zerotier-interface.nix { };
}
);
}

View File

@@ -0,0 +1,29 @@
nwid:
{ pkgs, ... }:
let
ztInterfaceScript = pkgs.writeShellScript "zt-interface" ''
#!/usr/bin/env bash
network="$1"
index=${"2:-0"}
network="0x$network"
# zerotier hash function
network=$(( (($network ^ ($network >> (3*8))) + $index ) % (1<<(5*8)) ))
# encode the result in base32
while [ $network -gt 0 ]; do
index=$(( $network % (1<<5) + 24 ))
[ $index -lt 50 ] && index=$(( $index + 73 ))
result="$(printf "\\%03o" $index)$result"
network=$(( $network >> 5 ))
done
echo "zt$(printf %b "$result")"
'';
result = pkgs.runCommand "zt-interface-output" { } ''
${ztInterfaceScript} > $out
'';
in
builtins.readFile result

View File

@@ -180,8 +180,11 @@
];
networking.firewall.allowedTCPPorts = [
53
80
];
networking.firewall.interfaces =
let
in
{ };
services.asterisk = {
enable = lib.mkDefault true;

6
overlays/default.nix Normal file
View File

@@ -0,0 +1,6 @@
{ ... }:
{
flake.overlays = {
libsOverlay = import ../lib/default.nix;
};
}