From 535eb70bb9615a52a40e5f54665608b19cceef1f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 31 Aug 2023 23:52:59 +0100 Subject: [PATCH] convert all route defns to module-based-service --- examples/arhcive.nix | 7 +------ examples/extneder.nix | 9 +------- pkgs/liminix-tools/networking/default.nix | 25 ++--------------------- vanilla-configuration.nix | 6 ++---- 4 files changed, 6 insertions(+), 41 deletions(-) diff --git a/examples/arhcive.nix b/examples/arhcive.nix index 183168d..7f86b2e 100644 --- a/examples/arhcive.nix +++ b/examples/arhcive.nix @@ -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]; diff --git a/examples/extneder.nix b/examples/extneder.nix index e4e26dd..db5dc8a 100644 --- a/examples/extneder.nix +++ b/examples/extneder.nix @@ -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]; diff --git a/pkgs/liminix-tools/networking/default.nix b/pkgs/liminix-tools/networking/default.nix index 02c761a..aed7c4e 100644 --- a/pkgs/liminix-tools/networking/default.nix +++ b/pkgs/liminix-tools/networking/default.nix @@ -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; - }; } diff --git a/vanilla-configuration.nix b/vanilla-configuration.nix index f608b9e..e1da819 100644 --- a/vanilla-configuration.nix +++ b/vanilla-configuration.nix @@ -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 ];