From 9441f48819ae1b385fc340385d6d7e90c575afae Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 13 Jul 2023 19:44:14 +0100 Subject: [PATCH] new ppp module, used by rotuer The objective here is that services which depend on global config (e.g. kernel config or busybox options or static paths in the filesystem) now live under config.system.service, and are added to that collection by the module that defines the necessary state. This is a first step: the services will be configured by a typechecked attr set instead of the arbitrary arguments that pkgs.liminix.networking.pppoe accepts --- examples/rotuer.nix | 9 ++------- modules/ppp.nix | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 modules/ppp.nix diff --git a/examples/rotuer.nix b/examples/rotuer.nix index 3f2880d..06d5fef 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -14,7 +14,6 @@ let dnsmasq hostapd interface - pppoe route; inherit (pkgs.liminix.services) oneshot longrun bundle target; inherit (pkgs) @@ -35,16 +34,12 @@ in rec { imports = [ ../modules/wlan.nix ../modules/standard.nix + ../modules/ppp.nix ]; rootfsType = "jffs2"; hostname = "rotuer"; kernel = { config = { - PPP = "y"; - PPP_BSDCOMP = "y"; - PPP_DEFLATE = "y"; - PPP_ASYNC = "y"; - PPP_SYNC_TTY = "y"; BRIDGE = "y"; NETFILTER_XT_MATCH_CONNTRACK = "y"; @@ -196,7 +191,7 @@ in rec { services.wan = let iface = config.hardware.networkInterfaces.wan; - in pppoe iface { + in config.system.service.pppoe iface { ppp-options = [ "debug" "+ipv6" "noauth" "name" secrets.l2tp.name diff --git a/modules/ppp.nix b/modules/ppp.nix new file mode 100644 index 0000000..08519e4 --- /dev/null +++ b/modules/ppp.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, config, ...}: +let + inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; + inherit (pkgs.pseudofile) dir symlink; + inherit (pkgs) stdenv wireless-regdb; +in { + options = { + system.service.pppoe = mkOption { + type = types.functionTo (types.functionTo types.package); + }; + }; + config = { + system.service.pppoe = pkgs.liminix.networking.pppoe; + kernel = { + config = { + PPP = "y"; + PPP_BSDCOMP = "y"; + PPP_DEFLATE = "y"; + PPP_ASYNC = "y"; + PPP_SYNC_TTY = "y"; + }; + }; + }; +}