diff --git a/hosts/containers/freifunk/configuration.nix b/hosts/containers/freifunk/configuration.nix new file mode 100644 index 00000000..0ba81c2c --- /dev/null +++ b/hosts/containers/freifunk/configuration.nix @@ -0,0 +1,60 @@ +{ config, pkgs, lib, ... }: + +let + meshInterface = "bmx"; +in { + imports = [ + + + + + ]; + + c3d2 = { + isInHq = false; + enableHail = false; + }; + + networking.hostName = "freifunk"; + networking.useNetworkd = true; + networking.nameservers = [ "172.20.73.8" "9.9.9.9" ]; + + # Required for krops + services.openssh.enable = true; + environment.systemPackages = with pkgs; [ git tcpdump ]; + + systemd.network.networks = { + "10-bmx" = { + enable = true; + matchConfig = { Name = meshInterface; }; + networkConfig = { + Address = "10.200.0.15/16"; + }; + }; + "20-core" = { + enable = true; + matchConfig = { Name = "core"; }; + networkConfig = { + Address = "172.20.72.40/26"; + Gateway = "172.20.72.7"; + }; + }; + }; + systemd.services.bmxd = + let + bmxd = import (toString ) { inherit pkgs; }; + in { + after = [ "systemd-networkd.service" ]; + wantedBy = [ "network.target" ]; + serviceConfig = { + ExecStart = "${bmxd}/sbin/bmxd --no_fork 1 --throw-rules 0 --prio-rules 0 dev=${meshInterface} /linklayer 0"; + Restart = "always"; + }; + }; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = "20.03"; # Did you read the comment? +} diff --git a/hosts/containers/freifunk/freifunk.qcow2 b/hosts/containers/freifunk/freifunk.qcow2 new file mode 100644 index 00000000..f760381f Binary files /dev/null and b/hosts/containers/freifunk/freifunk.qcow2 differ diff --git a/krops.nix b/krops.nix index f8e4d1c9..f9ad4e28 100644 --- a/krops.nix +++ b/krops.nix @@ -29,4 +29,5 @@ let in { scrape = deployContainer "scrape" "172.20.73.32"; ledstripes = deployContainer "ledstripes" "172.22.99.168"; + freifunk = deployContainer "freifunk" "172.20.72.40"; } diff --git a/lib/pkgs/bmxd.nix b/lib/pkgs/bmxd.nix new file mode 100644 index 00000000..5b7b7391 --- /dev/null +++ b/lib/pkgs/bmxd.nix @@ -0,0 +1,20 @@ +{ pkgs ? import {}, + src ? builtins.fetchGit "https://gitlab.freifunk-dresden.de/firmware-developer/firmware.git", +}: + +with pkgs; +let + path = "${src}/feeds/19.07/feeds-own/bmxd"; + makefile = builtins.readFile "${path}/Makefile"; + makeDef = name: + builtins.elemAt (builtins.match ".*?${name}:=([^\n]+).*?" makefile) 0; + name = makeDef "PKG_NAME"; + version = makeDef "PKG_VERSION"; + release = makeDef "PKG_RELEASE"; +in stdenv.mkDerivation { + name = "${name}-${version}-${release}"; + src = "${path}/sources"; + installPhase = '' + make install SBINDIR=$out/sbin + ''; +}