add default service target, get some stuff running
This commit is contained in:
@@ -3,14 +3,16 @@ mkdir -p $out/${name}
|
||||
echo $type > $out/${name}/type
|
||||
mkdir -p $out/${name}/dependencies.d
|
||||
echo $buildInputs > $out/buildInputs
|
||||
test -n "$dependencies" && for d in "$dependencies"; do
|
||||
test -n "$dependencies" && for d in $dependencies; do
|
||||
touch $out/${name}/dependencies.d/$d
|
||||
done
|
||||
test -n "$contents" && for d in "$contents"; do
|
||||
test -n "$contents" && for d in $contents; do
|
||||
mkdir -p $out/${name}/contents.d
|
||||
touch $out/${name}/contents.d/$d
|
||||
done
|
||||
test -n "$run" && (echo "$run" > $out/${name}/run)
|
||||
test -n "$up" && (echo "$up" > $out/${name}/up)
|
||||
test -n "$down" && (echo "$down" > $out/${name}/down)
|
||||
(echo $out/${name} && cd $out/${name} && find . -ls)
|
||||
test -n "$run" && (echo -e "#!$shell\n$run" > $out/${name}/run)
|
||||
test -n "$up" && (echo -e "#!$shell\n$up" > $out/${name}/up)
|
||||
test -n "$down" && (echo -e "#!$shell\n$down" > $out/${name}/down)
|
||||
for i in $out/${name}/{down,up,run} ; do test -f $i && chmod +x $i; done
|
||||
true
|
||||
# (echo $out/${name} && cd $out/${name} && find . -ls)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
stdenvNoCC
|
||||
, s6-rc
|
||||
, lib
|
||||
, busybox
|
||||
} :let
|
||||
inherit (builtins) concatStringsSep;
|
||||
longrun = {
|
||||
@@ -13,6 +15,7 @@
|
||||
type = "longrun";
|
||||
buildInputs = dependencies;
|
||||
dependencies = builtins.map (d: d.name) dependencies;
|
||||
shell = "${busybox}/bin/sh";
|
||||
inherit run;
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
@@ -32,23 +35,27 @@
|
||||
# even though the built output has no references to their
|
||||
# store directories?
|
||||
buildInputs = dependencies;
|
||||
shell = "${busybox}/bin/sh";
|
||||
inherit up down;
|
||||
dependencies = builtins.map (d: d.name) dependencies;
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
bundle = {
|
||||
target = {
|
||||
name
|
||||
, contents ? []
|
||||
, dependencies ? []
|
||||
, ...
|
||||
}: stdenvNoCC.mkDerivation {
|
||||
name = "${name}.bundle";
|
||||
inherit name;
|
||||
type = "bundle";
|
||||
contents = builtins.map (d: d.name) contents;
|
||||
buildInputs = dependencies ++ contents;
|
||||
buildInputs = dependencies ++ (lib.debug.traceSeqN 2 contents contents);
|
||||
dependencies = builtins.map (d: d.name) dependencies;
|
||||
shell = "${busybox}/bin/sh";
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
bundle = { name, ... } @args : target (args // { name = "${name}.bundle";});
|
||||
|
||||
in {
|
||||
networking = {
|
||||
interface = { type, device } @ args: oneshot {
|
||||
@@ -66,7 +73,7 @@ in {
|
||||
};
|
||||
udhcpc = interface: { ... } @ args: longrun {
|
||||
name = "${interface.device}.udhcp";
|
||||
run = "udhchpcd ${interface.device}";
|
||||
run = "${busybox}/bin/udhcpc -f -i ${interface.device}";
|
||||
};
|
||||
odhcpc = interface: { ... } @ args: longrun {
|
||||
name = "${interface.device}.odhcp";
|
||||
@@ -74,7 +81,7 @@ in {
|
||||
};
|
||||
};
|
||||
services = {
|
||||
inherit longrun oneshot bundle;
|
||||
inherit longrun oneshot bundle target;
|
||||
output = service: name: "/run/services/outputs/${service.name}/${name}";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user