separate files for networking and services

This commit is contained in:
Daniel Barlow 2022-09-26 12:26:54 +01:00
parent 4bfba33170
commit 676c94782b
4 changed files with 36 additions and 30 deletions

View file

@ -2,7 +2,10 @@ final: prev: {
pseudofile = final.callPackage ./pkgs/pseudofile {};
s6-init-files = final.callPackage ./pkgs/s6-init-files {};
strace = prev.strace.override { libunwind = null; };
liminix = final.callPackage ./pkgs/liminix-tools {};
liminix = {
services = final.callPackage ./pkgs/liminix-tools/services {};
networking = final.callPackage ./pkgs/liminix-tools/networking {};
};
writeAshScript = final.callPackage ./pkgs/write-ash-script {};
pppoe = prev.rpPPPoE.overrideAttrs (o: {

View file

@ -0,0 +1,28 @@
{
callPackage
, liminix
}:
let inherit (liminix.services) oneshot longrun;
in {
interface = { type, device } @ args: oneshot {
name = "${device}.link";
up = "ip link set up dev ${device}";
down = "ip link set down dev ${device}";
} // {
inherit device;
};
address = interface: { family, prefixLength, address } @ args:
let inherit (builtins) toString;
in oneshot {
dependencies = [ interface ];
name = "${interface.device}.addr.${address}";
up = "ip address add ${address}/${toString prefixLength} dev ${interface.device} ";
down = "ip address del ${address}/${toString prefixLength} dev ${interface.device} ";
};
udhcpc = callPackage ./udhcpc.nix {};
odhcpc = interface: { ... } @ args: longrun {
name = "${interface.device}.odhcp";
run = "odhcpcd ${interface.device}";
};
pppoe = callPackage ./pppoe.nix {};
}

View file

@ -5,8 +5,10 @@
, busybox
, callPackage
, writeAshScript
} :let
}:
let
inherit (builtins) concatStringsSep;
output = service: name: "/run/service-state/${service.name}/${name}";
longrun = {
name
, run
@ -61,33 +63,6 @@
builder = ./builder.sh;
};
bundle = { name, ... } @args : target (args // { name = "${name}.bundle";});
in {
networking = {
interface = { type, device } @ args: oneshot {
name = "${device}.link";
up = "ip link set up dev ${device}";
down = "ip link set down dev ${device}";
} // {
inherit device;
};
address = interface: { family, prefixLength, address } @ args:
let inherit (builtins) toString;
in oneshot {
dependencies = [ interface ];
name = "${interface.device}.addr.${address}";
up = "ip address add ${address}/${toString prefixLength} dev ${interface.device} ";
down = "ip address del ${address}/${toString prefixLength} dev ${interface.device} ";
};
udhcpc = callPackage ./networking/udhcpc.nix {};
odhcpc = interface: { ... } @ args: longrun {
name = "${interface.device}.odhcp";
run = "odhcpcd ${interface.device}";
};
pppoe = callPackage ./networking/pppoe.nix {};
};
services = {
inherit longrun oneshot bundle target;
output = service: name: "/run/service-state/${service.name}/${name}";
};
inherit target bundle oneshot longrun output;
}