convert all route defns to module-based-service

This commit is contained in:
Daniel Barlow 2023-08-31 23:52:59 +01:00
parent 51ad051443
commit 535eb70bb9
4 changed files with 6 additions and 41 deletions

View file

@ -11,10 +11,6 @@
...
}: let
secrets = import ./extneder-secrets.nix;
inherit
(pkgs.liminix.networking)
route
;
inherit (pkgs.liminix.services) oneshot longrun bundle target;
inherit (pkgs.pseudofile) dir symlink;
inherit (pkgs) writeText dropbear ifwait serviceFns;
@ -135,8 +131,7 @@ in rec {
srv = dir {};
};
services.defaultroute4 = route {
name = "defaultroute";
services.defaultroute4 = svc.network.route.build {
via = "$(output ${services.dhcpc} router)";
target = "default";
dependencies = [services.dhcpc];

View file

@ -11,12 +11,6 @@
...
}: let
secrets = import ./extneder-secrets.nix;
inherit
(pkgs.liminix.networking)
address
interface
route
;
inherit (pkgs.liminix.services) oneshot longrun bundle target;
inherit (pkgs.pseudofile) dir symlink;
inherit (pkgs) dropbear ifwait serviceFns;
@ -138,8 +132,7 @@ in rec {
};
};
services.defaultroute4 = route {
name = "defaultroute";
services.defaultroute4 = svc.network.route.build {
via = "$(output ${services.dhcpc} router)";
target = "default";
dependencies = [services.dhcpc];

View file

@ -1,13 +1,8 @@
{
callPackage
, liminix
, ifwait
, lib
ifwait
, serviceFns
}:
let
inherit (liminix.services) oneshot longrun;
inherit (lib) concatStringsSep optional;
{
ifup = name : ifname : ''
. ${serviceFns}
${ifwait}/bin/ifwait -v ${ifname} present
@ -16,20 +11,4 @@ let
echo ${ifname} > ifname
)
'';
in {
inherit ifup;
route = { name, target, via, dependencies, dev ? null }:
let with_dev = if dev != null then "dev ${dev}" else "";
in oneshot {
inherit name;
up = ''
ip route add ${target} via ${via} ${with_dev}
'';
down = ''
ip route del ${target} via ${via} ${with_dev}
'';
inherit dependencies;
};
}

View file

@ -1,6 +1,5 @@
{ config, pkgs, ... } :
let
inherit (pkgs.liminix.networking) interface address route;
inherit (pkgs.liminix.services) oneshot longrun bundle target;
inherit (pkgs) writeText;
svc = config.system.service;
@ -10,15 +9,14 @@ in rec {
./modules/wlan.nix
./modules/network
./modules/ntp
./modules/vlan
];
services.loopback = config.hardware.networkInterfaces.lo;
services.dhcpv4 =
let iface = svc.network.link.build { ifname = "eth1"; };
in svc.network.dhcp.client.build { interface = iface; };
services.defaultroute4 = route {
name = "defautlrote";
services.defaultroute4 = svc.network.route.build {
via = "$(output ${services.dhcpv4} address)";
target = "default";
dependencies = [ services.dhcpv4 ];