Flakify freifunk container

This commit is contained in:
Ehmry - 2021-02-26 20:22:15 +01:00
parent bf74133ea7
commit 535478c160
10 changed files with 144 additions and 27 deletions

View File

@ -15,7 +15,13 @@
hostRegistry = import ./host-registry.nix;
in {
inherit (nixpkgs) legacyPackages;
overlay = import ./overlay;
legacyPackages = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
packages = forAllSystems (system:
let
@ -40,6 +46,8 @@
# TODO: check if the ethernet address is reachable and if not,
# execute wol on a machine in HQ.
in {
inherit (pkgs) bmxd;
dhcp-nixos-rebuild = mkDeploy "dhcp" hostRegistry.hosts.dhcp.ip4;
glotzbert-nixos-rebuild = mkDeploy "glotzbert" "glotzbert.hq.c3d2.de";
@ -62,6 +70,7 @@
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
nixpkgs.overlays = [ self.overlay ];
})
];
});
@ -76,6 +85,12 @@
system = "x86_64-linux";
};
freifunk = nixosSystem' {
modules =
[ (import ./hosts/containers/freifunk { inherit secrets; }) ];
system = "x86_64-linux";
};
glotzbert = nixosSystem' {
modules = [
./hosts/glotzbert

View File

@ -1,4 +1,5 @@
{ config, pkgs, lib, ... }:
{ secrets }:
{ config, pkgs, lib, modulesPath, ... }:
let
coreAddress = "172.20.72.40";
@ -6,20 +7,17 @@ let
meshInterface = "bmx";
meshLoopback = "bmx_prime";
ddmeshRegisterUrl = "https://register.freifunk-dresden.de/bot.php";
secrets = import <secrets/hosts/freifunk>;
ddmeshRegisterKey = secrets.ddmeshRegisterKey;
secrets' = import "${secrets}/hosts/freifunk";
ddmeshRegisterKey = secrets'.ddmeshRegisterKey;
ddmeshNode = 51073;
ddmeshAddrPart = "200.74";
rt_table = 7;
bmxd = import (toString <lib/pkgs/bmxd.nix>) { inherit pkgs; };
sysinfo-json =
import <this-host/sysinfo-json.nix> { inherit pkgs bmxd ddmeshNode; };
sysinfo-json = import ./sysinfo-json.nix { inherit pkgs ddmeshNode; };
in {
imports = [
<nixpkgs/nixos/modules/profiles/minimal.nix>
<lib>
<lib/lxc-container.nix>
<lib/shared.nix>
"${modulesPath}/profiles/minimal.nix"
../../../lib/lxc-container.nix
../../../lib/shared.nix
];
boot.tmpOnTmpfs = true;
@ -118,7 +116,7 @@ in {
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = ''
${bmxd}/sbin/bmxd \
${pkgs.bmxd}/sbin/bmxd \
--rt_table_offset=${toString rt_table} \
--no_fork 1 \
--throw-rules 0 \
@ -193,7 +191,9 @@ in {
stubnet 10.200.0.0/15;
interface "core" {
authentication cryptographic;
password "${import <secrets/shared/ospf/message-digest-key.nix>}";
password "${
import "${secrets}/shared/ospf/message-digest-key.nix"
}";
};
};
}
@ -207,7 +207,9 @@ in {
};
interface "core" {
#authentication cryptographic;
#password "${import <secrets/shared/ospf/message-digest-key.nix>}";
#password "${
import "${secrets}/shared/ospf/message-digest-key.nix"
}";
};
};
}
@ -228,7 +230,7 @@ in {
virtualHosts = {
"c3d2.ffdd" = {
default = true;
root = <this-host/assets>;
root = ./assets;
locations = let
sysinfo-json = {
alias = "/run/nginx/sysinfo.json";
@ -241,9 +243,7 @@ in {
index = "index.html";
extraConfig = ''
etag off;
add_header etag "\"${
builtins.substring 11 32 (<this-host> + "/assets")
}\"";
add_header etag "\"${builtins.substring 11 32 (./assets)}\"";
'';
};
"=/sysinfo-json.cgi" = sysinfo-json;

View File

@ -1,6 +1,7 @@
{ pkgs ? import <nixpkgs> { }, ffdd-server ?
builtins.fetchGit "https://github.com/Freifunk-Dresden/ffdd-server.git", bmxd
, ddmeshNode, ... }:
{ pkgs ? import <nixpkgs> { }, ffdd-server ? pkgs.fetchgit {
url = "https://github.com/Freifunk-Dresden/ffdd-server.git";
sha256 = "15iijpywfp0zd785na5ry0g8z41x3zg238piih5rp8khc5xis09c";
}, ddmeshNode, ... }:
with pkgs;
let

View File

@ -24,6 +24,5 @@ let
in {
scrape = deployContainer "scrape" "172.20.73.32";
ledstripes = deployContainer "ledstripes" "172.22.99.168";
freifunk = deployContainer "freifunk" "172.20.72.40";
kibana = deployContainer "kibana" "172.20.73.44";
}

View File

@ -1,8 +1,10 @@
{ pkgs ? import <nixpkgs> { }, src ? builtins.fetchGit
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware.git", }:
{ stdenv, fetchgit, fetchpatch, }:
with pkgs;
let
src = fetchgit {
url = "https://gitlab.freifunk-dresden.de/firmware-developer/firmware.git";
sha256 = "sha256-3sV59uqFp+TZKrDf7kmksLvz+5ZKriwFyXZMBH2Sdws=";
};
path = "feeds/19.07/feeds-own/bmxd";
makefile = builtins.readFile "${src}/${path}/Makefile";
makeDef = name:
@ -12,10 +14,11 @@ let
name = makeDef "PKG_NAME";
version = makeDef "PKG_VERSION";
release = makeDef "PKG_RELEASE";
patch = fetchurl {
patch = fetchpatch {
name = "timercpy.patch";
url =
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware/merge_requests/36.patch";
sha256 = "10gm1fqg2s8c261i0j1py3sfyyzr0h5b6wwdsgg3icn7lfjd6k75";
sha256 = "sha256-40BbcCZ10cQzvkfsAi8ApCgmC4hGMh2J8xU6gjD3cng=";
};
in stdenv.mkDerivation {
name = "${name}-${version}-${release}";

View File

@ -0,0 +1,9 @@
final: prev:
{
bmxd = prev.callPackage ./bmdx.nix { };
pile = prev.callPackage ./pile.nix { };
}

25
nixpkgs-overlay/pile.nix Normal file
View File

@ -0,0 +1,25 @@
{ fetchgit, rustPlatform }:
let
pile = fetchgit {
url = "https://github.com/astro/pile.git";
sha256 = "sha256-z4xNUGmP35ZBZUpgozQHANZniADfmwEoclnEwNlvAC4=";
};
in {
ledball = rustPlatform.buildRustPackage {
name = "ledball";
version = "0.0.0";
src = "${pile}/ledball";
cargoSha256 = "0zyfbf3gph8gqab07fmm5a7x5slapsqn8ck6isp53fsa7ljnagjy";
cargoBuildFlags = [ "--examples" ];
postInstall = ''
mkdir -p $out/bin
for f in target/*/release/examples/*; do
if [ -f $f ] && [ -x $f ]; then
cp $f $out/bin/
fi
done
'';
};
}

31
overlay/bmdx.nix Normal file
View File

@ -0,0 +1,31 @@
{ stdenv, fetchgit, fetchpatch, }:
let
src = fetchgit {
url = "https://gitlab.freifunk-dresden.de/firmware-developer/firmware.git";
sha256 = "sha256-3sV59uqFp+TZKrDf7kmksLvz+5ZKriwFyXZMBH2Sdws=";
};
path = "feeds/19.07/feeds-own/bmxd";
makefile = builtins.readFile "${src}/${path}/Makefile";
makeDef = name:
builtins.elemAt (builtins.match ''
.*?${name}:=([^
]+).*?'' makefile) 0;
name = makeDef "PKG_NAME";
version = makeDef "PKG_VERSION";
release = makeDef "PKG_RELEASE";
patch = fetchpatch {
name = "timercpy.patch";
url =
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware/merge_requests/36.patch";
sha256 = "sha256-40BbcCZ10cQzvkfsAi8ApCgmC4hGMh2J8xU6gjD3cng=";
};
in stdenv.mkDerivation {
name = "${name}-${version}-${release}";
inherit src;
patches = [ patch ];
buildPhase = "cd ${path}/sources";
installPhase = ''
make install SBINDIR=$out/sbin
'';
}

9
overlay/default.nix Normal file
View File

@ -0,0 +1,9 @@
final: prev:
{
bmxd = prev.callPackage ./bmdx.nix { };
pile = prev.callPackage ./pile.nix { };
}

25
overlay/pile.nix Normal file
View File

@ -0,0 +1,25 @@
{ fetchgit, rustPlatform }:
let
pile = fetchgit {
url = "https://github.com/astro/pile.git";
sha256 = "sha256-z4xNUGmP35ZBZUpgozQHANZniADfmwEoclnEwNlvAC4=";
};
in {
ledball = rustPlatform.buildRustPackage {
name = "ledball";
version = "0.0.0";
src = "${pile}/ledball";
cargoSha256 = "0zyfbf3gph8gqab07fmm5a7x5slapsqn8ck6isp53fsa7ljnagjy";
cargoBuildFlags = [ "--examples" ];
postInstall = ''
mkdir -p $out/bin
for f in target/*/release/examples/*; do
if [ -f $f ] && [ -x $f ]; then
cp $f $out/bin/
fi
done
'';
};
}