separate files for networking and services
This commit is contained in:
parent
4bfba33170
commit
676c94782b
4 changed files with 36 additions and 30 deletions
|
@ -2,7 +2,10 @@ final: prev: {
|
||||||
pseudofile = final.callPackage ./pkgs/pseudofile {};
|
pseudofile = final.callPackage ./pkgs/pseudofile {};
|
||||||
s6-init-files = final.callPackage ./pkgs/s6-init-files {};
|
s6-init-files = final.callPackage ./pkgs/s6-init-files {};
|
||||||
strace = prev.strace.override { libunwind = null; };
|
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 {};
|
writeAshScript = final.callPackage ./pkgs/write-ash-script {};
|
||||||
|
|
||||||
pppoe = prev.rpPPPoE.overrideAttrs (o: {
|
pppoe = prev.rpPPPoE.overrideAttrs (o: {
|
||||||
|
|
28
pkgs/liminix-tools/networking/default.nix
Normal file
28
pkgs/liminix-tools/networking/default.nix
Normal 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 {};
|
||||||
|
}
|
|
@ -5,8 +5,10 @@
|
||||||
, busybox
|
, busybox
|
||||||
, callPackage
|
, callPackage
|
||||||
, writeAshScript
|
, writeAshScript
|
||||||
} :let
|
}:
|
||||||
|
let
|
||||||
inherit (builtins) concatStringsSep;
|
inherit (builtins) concatStringsSep;
|
||||||
|
output = service: name: "/run/service-state/${service.name}/${name}";
|
||||||
longrun = {
|
longrun = {
|
||||||
name
|
name
|
||||||
, run
|
, run
|
||||||
|
@ -61,33 +63,6 @@
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
};
|
};
|
||||||
bundle = { name, ... } @args : target (args // { name = "${name}.bundle";});
|
bundle = { name, ... } @args : target (args // { name = "${name}.bundle";});
|
||||||
|
|
||||||
in {
|
in {
|
||||||
networking = {
|
inherit target bundle oneshot longrun output;
|
||||||
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}";
|
|
||||||
};
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue