forked from DGNum/liminix
convert bridge service to serviceDefn
This commit is contained in:
parent
f82501d278
commit
93e04bb834
4 changed files with 25 additions and 33 deletions
|
@ -78,12 +78,12 @@ in rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.int =
|
services.int =
|
||||||
let iface = svc.bridge.primary { ifname = "int"; };
|
let iface = svc.bridge.primary.build { ifname = "int"; };
|
||||||
in address iface {
|
in address iface {
|
||||||
family = "inet4"; address ="10.8.0.1"; prefixLength = 16;
|
family = "inet4"; address ="10.8.0.1"; prefixLength = 16;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.bridge = svc.bridge.members {
|
services.bridge = svc.bridge.members.build {
|
||||||
primary = services.int;
|
primary = services.int;
|
||||||
members = with config.hardware.networkInterfaces; [
|
members = with config.hardware.networkInterfaces; [
|
||||||
wlan_24 lan wlan_5
|
wlan_24 lan wlan_5
|
||||||
|
|
|
@ -2,21 +2,36 @@
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (pkgs.liminix.services) oneshot;
|
inherit (pkgs.liminix.services) oneshot;
|
||||||
|
inherit (pkgs) liminix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
system.service.bridge = {
|
system.service.bridge = {
|
||||||
primary = mkOption {
|
primary = mkOption {
|
||||||
type = types.functionTo pkgs.liminix.lib.types.service;
|
type = liminix.lib.types.serviceDefn;
|
||||||
};
|
};
|
||||||
members = mkOption {
|
members = mkOption {
|
||||||
type = types.functionTo pkgs.liminix.lib.types.service;
|
type = liminix.lib.types.serviceDefn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config.system.service.bridge = {
|
||||||
system.service.bridge.primary = pkgs.callPackage ./primary.nix {};
|
primary = liminix.callService ./primary.nix {
|
||||||
system.service.bridge.members = pkgs.callPackage ./members.nix {};
|
ifname = mkOption {
|
||||||
kernel.config.BRIDGE = "y";
|
type = types.str;
|
||||||
|
description = "interface name for the bridge device";
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
members = liminix.callService ./members.nix {
|
||||||
|
members = mkOption {
|
||||||
|
type = types.listOf liminix.lib.types.service;
|
||||||
|
description = "interfaces to add to the bridge";
|
||||||
|
};
|
||||||
|
primary = mkOption {
|
||||||
|
type = liminix.lib.types.service;
|
||||||
|
description = "bridge interface to add them to";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.kernel.config.BRIDGE = "y";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,11 @@
|
||||||
, ifwait
|
, ifwait
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
|
{ members, primary } :
|
||||||
let
|
let
|
||||||
inherit (liminix.networking) interface;
|
inherit (liminix.networking) interface;
|
||||||
inherit (liminix.services) bundle oneshot;
|
inherit (liminix.services) bundle oneshot;
|
||||||
inherit (liminix.lib) typeChecked;
|
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
t = {
|
|
||||||
members = mkOption {
|
|
||||||
type = types.listOf liminix.lib.types.service;
|
|
||||||
description = "interfaces to add to the bridge";
|
|
||||||
};
|
|
||||||
primary = mkOption {
|
|
||||||
type = liminix.lib.types.service;
|
|
||||||
description = "bridge interface to add them to";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
params:
|
|
||||||
let
|
|
||||||
inherit (typeChecked "bridge-members" t params) members primary;
|
|
||||||
addif = member :
|
addif = member :
|
||||||
oneshot {
|
oneshot {
|
||||||
name = "add-${member.device}-to-br-${primary.device}";
|
name = "add-${member.device}-to-br-${primary.device}";
|
||||||
|
|
|
@ -2,20 +2,11 @@
|
||||||
liminix
|
liminix
|
||||||
, lib
|
, lib
|
||||||
}:
|
}:
|
||||||
|
{ ifname } :
|
||||||
let
|
let
|
||||||
inherit (liminix.networking) interface;
|
inherit (liminix.networking) interface;
|
||||||
inherit (liminix.lib) typeChecked;
|
inherit (liminix.lib) typeChecked;
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
t = {
|
|
||||||
ifname = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "interface name for the bridge device";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
params:
|
|
||||||
let
|
|
||||||
inherit (typeChecked "bridge" t params) ifname;
|
|
||||||
in interface {
|
in interface {
|
||||||
device = ifname;
|
device = ifname;
|
||||||
type = "bridge";
|
type = "bridge";
|
||||||
|
|
Loading…
Reference in a new issue