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

View file

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

View file

@ -1,13 +1,8 @@
{ {
callPackage ifwait
, liminix
, ifwait
, lib
, serviceFns , serviceFns
}: }:
let {
inherit (liminix.services) oneshot longrun;
inherit (lib) concatStringsSep optional;
ifup = name : ifname : '' ifup = name : ifname : ''
. ${serviceFns} . ${serviceFns}
${ifwait}/bin/ifwait -v ${ifname} present ${ifwait}/bin/ifwait -v ${ifname} present
@ -16,20 +11,4 @@ let
echo ${ifname} > ifname 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, ... } : { config, pkgs, ... } :
let let
inherit (pkgs.liminix.networking) interface address route;
inherit (pkgs.liminix.services) oneshot longrun bundle target; inherit (pkgs.liminix.services) oneshot longrun bundle target;
inherit (pkgs) writeText; inherit (pkgs) writeText;
svc = config.system.service; svc = config.system.service;
@ -10,15 +9,14 @@ in rec {
./modules/wlan.nix ./modules/wlan.nix
./modules/network ./modules/network
./modules/ntp ./modules/ntp
./modules/vlan
]; ];
services.loopback = config.hardware.networkInterfaces.lo;
services.dhcpv4 = services.dhcpv4 =
let iface = svc.network.link.build { ifname = "eth1"; }; let iface = svc.network.link.build { ifname = "eth1"; };
in svc.network.dhcp.client.build { interface = iface; }; in svc.network.dhcp.client.build { interface = iface; };
services.defaultroute4 = route { services.defaultroute4 = svc.network.route.build {
name = "defautlrote";
via = "$(output ${services.dhcpv4} address)"; via = "$(output ${services.dhcpv4} address)";
target = "default"; target = "default";
dependencies = [ services.dhcpv4 ]; dependencies = [ services.dhcpv4 ];