Flakify freifunk container
This commit is contained in:
parent
bf74133ea7
commit
535478c160
17
flake.nix
17
flake.nix
|
@ -15,7 +15,13 @@
|
||||||
hostRegistry = import ./host-registry.nix;
|
hostRegistry = import ./host-registry.nix;
|
||||||
in {
|
in {
|
||||||
|
|
||||||
inherit (nixpkgs) legacyPackages;
|
overlay = import ./overlay;
|
||||||
|
|
||||||
|
legacyPackages = forAllSystems (system:
|
||||||
|
import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlay ];
|
||||||
|
});
|
||||||
|
|
||||||
packages = forAllSystems (system:
|
packages = forAllSystems (system:
|
||||||
let
|
let
|
||||||
|
@ -40,6 +46,8 @@
|
||||||
# TODO: check if the ethernet address is reachable and if not,
|
# TODO: check if the ethernet address is reachable and if not,
|
||||||
# execute wol on a machine in HQ.
|
# execute wol on a machine in HQ.
|
||||||
in {
|
in {
|
||||||
|
inherit (pkgs) bmxd;
|
||||||
|
|
||||||
dhcp-nixos-rebuild = mkDeploy "dhcp" hostRegistry.hosts.dhcp.ip4;
|
dhcp-nixos-rebuild = mkDeploy "dhcp" hostRegistry.hosts.dhcp.ip4;
|
||||||
|
|
||||||
glotzbert-nixos-rebuild = mkDeploy "glotzbert" "glotzbert.hq.c3d2.de";
|
glotzbert-nixos-rebuild = mkDeploy "glotzbert" "glotzbert.hq.c3d2.de";
|
||||||
|
@ -62,6 +70,7 @@
|
||||||
package = pkgs.nixFlakes;
|
package = pkgs.nixFlakes;
|
||||||
extraOptions = "experimental-features = nix-command flakes";
|
extraOptions = "experimental-features = nix-command flakes";
|
||||||
};
|
};
|
||||||
|
nixpkgs.overlays = [ self.overlay ];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@ -76,6 +85,12 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
freifunk = nixosSystem' {
|
||||||
|
modules =
|
||||||
|
[ (import ./hosts/containers/freifunk { inherit secrets; }) ];
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
|
||||||
glotzbert = nixosSystem' {
|
glotzbert = nixosSystem' {
|
||||||
modules = [
|
modules = [
|
||||||
./hosts/glotzbert
|
./hosts/glotzbert
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ secrets }:
|
||||||
|
{ config, pkgs, lib, modulesPath, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
coreAddress = "172.20.72.40";
|
coreAddress = "172.20.72.40";
|
||||||
|
@ -6,20 +7,17 @@ let
|
||||||
meshInterface = "bmx";
|
meshInterface = "bmx";
|
||||||
meshLoopback = "bmx_prime";
|
meshLoopback = "bmx_prime";
|
||||||
ddmeshRegisterUrl = "https://register.freifunk-dresden.de/bot.php";
|
ddmeshRegisterUrl = "https://register.freifunk-dresden.de/bot.php";
|
||||||
secrets = import <secrets/hosts/freifunk>;
|
secrets' = import "${secrets}/hosts/freifunk";
|
||||||
ddmeshRegisterKey = secrets.ddmeshRegisterKey;
|
ddmeshRegisterKey = secrets'.ddmeshRegisterKey;
|
||||||
ddmeshNode = 51073;
|
ddmeshNode = 51073;
|
||||||
ddmeshAddrPart = "200.74";
|
ddmeshAddrPart = "200.74";
|
||||||
rt_table = 7;
|
rt_table = 7;
|
||||||
bmxd = import (toString <lib/pkgs/bmxd.nix>) { inherit pkgs; };
|
sysinfo-json = import ./sysinfo-json.nix { inherit pkgs ddmeshNode; };
|
||||||
sysinfo-json =
|
|
||||||
import <this-host/sysinfo-json.nix> { inherit pkgs bmxd ddmeshNode; };
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/profiles/minimal.nix>
|
"${modulesPath}/profiles/minimal.nix"
|
||||||
<lib>
|
../../../lib/lxc-container.nix
|
||||||
<lib/lxc-container.nix>
|
../../../lib/shared.nix
|
||||||
<lib/shared.nix>
|
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.tmpOnTmpfs = true;
|
boot.tmpOnTmpfs = true;
|
||||||
|
@ -118,7 +116,7 @@ in {
|
||||||
wantedBy = [ "network.target" ];
|
wantedBy = [ "network.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${bmxd}/sbin/bmxd \
|
${pkgs.bmxd}/sbin/bmxd \
|
||||||
--rt_table_offset=${toString rt_table} \
|
--rt_table_offset=${toString rt_table} \
|
||||||
--no_fork 1 \
|
--no_fork 1 \
|
||||||
--throw-rules 0 \
|
--throw-rules 0 \
|
||||||
|
@ -193,7 +191,9 @@ in {
|
||||||
stubnet 10.200.0.0/15;
|
stubnet 10.200.0.0/15;
|
||||||
interface "core" {
|
interface "core" {
|
||||||
authentication cryptographic;
|
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" {
|
interface "core" {
|
||||||
#authentication cryptographic;
|
#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 = {
|
virtualHosts = {
|
||||||
"c3d2.ffdd" = {
|
"c3d2.ffdd" = {
|
||||||
default = true;
|
default = true;
|
||||||
root = <this-host/assets>;
|
root = ./assets;
|
||||||
locations = let
|
locations = let
|
||||||
sysinfo-json = {
|
sysinfo-json = {
|
||||||
alias = "/run/nginx/sysinfo.json";
|
alias = "/run/nginx/sysinfo.json";
|
||||||
|
@ -241,9 +243,7 @@ in {
|
||||||
index = "index.html";
|
index = "index.html";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
etag off;
|
etag off;
|
||||||
add_header etag "\"${
|
add_header etag "\"${builtins.substring 11 32 (./assets)}\"";
|
||||||
builtins.substring 11 32 (<this-host> + "/assets")
|
|
||||||
}\"";
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
"=/sysinfo-json.cgi" = sysinfo-json;
|
"=/sysinfo-json.cgi" = sysinfo-json;
|
|
@ -1,6 +1,7 @@
|
||||||
{ pkgs ? import <nixpkgs> { }, ffdd-server ?
|
{ pkgs ? import <nixpkgs> { }, ffdd-server ? pkgs.fetchgit {
|
||||||
builtins.fetchGit "https://github.com/Freifunk-Dresden/ffdd-server.git", bmxd
|
url = "https://github.com/Freifunk-Dresden/ffdd-server.git";
|
||||||
, ddmeshNode, ... }:
|
sha256 = "15iijpywfp0zd785na5ry0g8z41x3zg238piih5rp8khc5xis09c";
|
||||||
|
}, ddmeshNode, ... }:
|
||||||
|
|
||||||
with pkgs;
|
with pkgs;
|
||||||
let
|
let
|
||||||
|
|
|
@ -24,6 +24,5 @@ let
|
||||||
in {
|
in {
|
||||||
scrape = deployContainer "scrape" "172.20.73.32";
|
scrape = deployContainer "scrape" "172.20.73.32";
|
||||||
ledstripes = deployContainer "ledstripes" "172.22.99.168";
|
ledstripes = deployContainer "ledstripes" "172.22.99.168";
|
||||||
freifunk = deployContainer "freifunk" "172.20.72.40";
|
|
||||||
kibana = deployContainer "kibana" "172.20.73.44";
|
kibana = deployContainer "kibana" "172.20.73.44";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
{ pkgs ? import <nixpkgs> { }, src ? builtins.fetchGit
|
{ stdenv, fetchgit, fetchpatch, }:
|
||||||
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware.git", }:
|
|
||||||
|
|
||||||
with pkgs;
|
|
||||||
let
|
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";
|
path = "feeds/19.07/feeds-own/bmxd";
|
||||||
makefile = builtins.readFile "${src}/${path}/Makefile";
|
makefile = builtins.readFile "${src}/${path}/Makefile";
|
||||||
makeDef = name:
|
makeDef = name:
|
||||||
|
@ -12,10 +14,11 @@ let
|
||||||
name = makeDef "PKG_NAME";
|
name = makeDef "PKG_NAME";
|
||||||
version = makeDef "PKG_VERSION";
|
version = makeDef "PKG_VERSION";
|
||||||
release = makeDef "PKG_RELEASE";
|
release = makeDef "PKG_RELEASE";
|
||||||
patch = fetchurl {
|
patch = fetchpatch {
|
||||||
|
name = "timercpy.patch";
|
||||||
url =
|
url =
|
||||||
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware/merge_requests/36.patch";
|
"https://gitlab.freifunk-dresden.de/firmware-developer/firmware/merge_requests/36.patch";
|
||||||
sha256 = "10gm1fqg2s8c261i0j1py3sfyyzr0h5b6wwdsgg3icn7lfjd6k75";
|
sha256 = "sha256-40BbcCZ10cQzvkfsAi8ApCgmC4hGMh2J8xU6gjD3cng=";
|
||||||
};
|
};
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
name = "${name}-${version}-${release}";
|
name = "${name}-${version}-${release}";
|
9
nixpkgs-overlay/default.nix
Normal file
9
nixpkgs-overlay/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
final: prev:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
bmxd = prev.callPackage ./bmdx.nix { };
|
||||||
|
|
||||||
|
pile = prev.callPackage ./pile.nix { };
|
||||||
|
|
||||||
|
}
|
25
nixpkgs-overlay/pile.nix
Normal file
25
nixpkgs-overlay/pile.nix
Normal 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
31
overlay/bmdx.nix
Normal 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
9
overlay/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
final: prev:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
bmxd = prev.callPackage ./bmdx.nix { };
|
||||||
|
|
||||||
|
pile = prev.callPackage ./pile.nix { };
|
||||||
|
|
||||||
|
}
|
25
overlay/pile.nix
Normal file
25
overlay/pile.nix
Normal 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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user