network options working for basic functionality

This commit is contained in:
Git Sagar 2024-06-03 20:36:30 -03:00
parent e4cdc2cae5
commit 392375b046
9 changed files with 348 additions and 221 deletions

13
lib/network.nix Normal file
View file

@ -0,0 +1,13 @@
{ pkgs, lib, ... }: rec {
calc = (import ((builtins.fetchTarball "https://gist.github.com/duairc/5c9bb3c922e5d501a1edb9e7b3b845ba/archive/3885f7cd9ed0a746a9d675da6f265d41e9fd6704.tar.gz") + "/net.nix" ) { inherit lib; }).lib.net;
regex.ipv4 =
let
compRegex = "(25[0-5]|(2[0-4]|10|1?[1-9])?[0-9])";
in
"(${compRegex}\\.){3}${compRegex}";
regex.cidr4 = "${regex.ipv4}/(3[0-2]|[1-2]?[0-9])";
regex.ipOrCidr4 = "(${regex.ipv4}|${regex.cidr4})";
ipv4ToInt = ipv4: calc.ip.diff ipv4 "0.0.0.0";
intToipv4 = inte: calc.ip.add "0.0.0.0" inte;
}