Compare commits

..

No commits in common. "c4185617c039dacfe1afdc6b051c9507069fa99f" and "29a869b4faeac291947c5783d15580e92fcb1018" have entirely different histories.

14 changed files with 11 additions and 127 deletions

View File

@ -5114,50 +5114,6 @@ service that's down
s6-rc -u change $service
for s in $(s6-rc-db -d all-dependencies $service); do
if (s6-rc-db all-dependencies $s | grep controlled); do
# do nothing: if it's stopped, we don't want to start it,
# and if it's already running there's no need to.
# XXX what if it's running but its children are not?
# XXX 2 this fails as written because _every_ service $s depends
# on the controlled service $service
start s: nothing
else
start s
"[service] Names cannot be duplicated and cannot contain a slash or a
newline; they can contain spaces and tabs, but using anything else
than alphanumerical characters, underscores and dashes is discouraged"
would this be simpler in fennel?
(each [l (lines (io.popen (%. "s6-rc-db -d all-dependencies %s" service)))]
(if (not (controlled-ancestor l))
(tset to-start l true)))
Sat Jun 15 08:51:21 BST 2024
# do this at boot
for s in $(s6-rc-db -d dependencies controlled); do
mkdir -p /run/services/controlled
touch /run/services/controlled/$s
done
# now we can do this to start a service tree
for controlled in $(cd /run/services/controlled/ && echo *); do
if down $controlled; then
blocks="$blocks $controlled "
fi
done
for s in $(s6-rc-db -d all-dependencies $service); do
for dep in $(s6-rc-db all-dependencies $s)
case "$blocks" in
"* $dep *")
: don't start
;;
*)
s6-rc -u change $s
;;
esac
done
done

View File

@ -36,22 +36,18 @@ in rec {
username = "user";
password = "one2one";
authType = "chap";
};
services.dhcpc = svc.network.dhcp.client.build {
interface = config.services.wwan;
dependencies = [ config.services.hostname ];
};
services.sshd = svc.ssh.build { };
services.resolvconf = oneshot rec {
dependencies = [ services.dhcpc ];
dependencies = [ services.wwan ];
name = "resolvconf";
up = ''
. ${serviceFns}
( in_outputs ${name}
for i in $(output ${services.dhcpc} dns); do
for i in $(output ${services.wwan} dns); do
echo "nameserver $i" > resolv.conf
done
)

View File

@ -53,6 +53,7 @@ let
};
symlink = "/dev/modem";
});
# XXX need an ip-up script here to collect the IP address
up = ''
ls -l /dev/modem
test -L /dev/modem || exit 1

View File

@ -11,7 +11,7 @@ in {
devout = longrun {
name = "devout";
notification-fd = 10;
run = "exec ${pkgs.devout}/bin/devout /run/devout.sock 4";
run = "${pkgs.devout}/bin/devout /run/devout.sock 4";
};
coldplug = oneshot {
name ="coldplug";

View File

@ -17,7 +17,7 @@ let
ip address replace $ip/$mask dev $interface
(in_outputs ${name}
for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do
(printenv $i || true) > $i
printenv $i > $i
done)
}
case $action in
@ -40,7 +40,7 @@ let
'';
in longrun {
inherit name;
run = "exec /bin/udhcpc -f -i $(output ${interface} ifname) -x hostname:$(cat /proc/sys/kernel/hostname) -s ${script}";
run = "/bin/udhcpc -f -i $(output ${interface} ifname) -x hostname:$(cat /proc/sys/kernel/hostname) -s ${script}";
notification-fd = 10;
dependencies = [ interface ];
}

View File

@ -8,7 +8,7 @@ let
stdenvNoCC;
inherit (lib.lists) unique concatMap;
inherit (pkgs.pseudofile) dir symlink;
inherit (pkgs.liminix.services) oneshot bundle;
inherit (pkgs.liminix.services) bundle;
s6-rc-db =
let
@ -31,25 +31,12 @@ let
isControlled s ||
(lib.lists.any isDependentOnControlled s.dependencies);
# all controlled services depend on this oneshot, which
# makes a list of them so we can identify them at runtime
controlled = oneshot {
name = "controlled";
up = ''
mkdir -p /run/services/controlled
for s in $(s6-rc-db -d dependencies controlled); do
touch /run/services/controlled/$s
done
'';
down = "rm -r /run/services/controlled";
};
defaultStart =
builtins.filter
(s: !(isDependentOnControlled s)) allServices;
defaultDefaultTarget = bundle {
name = "default";
contents = defaultStart ++ [controlled];
contents = defaultStart;
};
servicesAttrs = {
default = defaultDefaultTarget;

View File

@ -98,7 +98,6 @@ in {
run-liminix-vm = callPackage ./run-liminix-vm {};
s6-init-bin = callPackage ./s6-init-bin {};
s6-rc-database = callPackage ./s6-rc-database {};
s6-rc-up-tree = callPackage ./s6-rc-up-tree {};
# schnapps is written by Turris and provides a high-level interface
# to btrfs snapshots. It may be useful on the Turris Omnia to
@ -113,7 +112,6 @@ in {
uevent-watch = callPackage ./uevent-watch {};
usb-modeswitch = callPackage ./usb-modeswitch {};
writeAshScript = callPackage ./write-ash-script {};
writeAshScriptBin = callPackage ./write-ash-script/bin.nix {};
writeFennel = callPackage ./write-fennel {};
writeFennelScript = callPackage ./write-fennel-script {};
}

View File

@ -16,8 +16,6 @@ done
if test -n "$controller" ; then
d=$(dirname $(cd ${controller} && ls -d */type))
echo "$d)" > $out/${name}/controller
# ^ why is there a closing paren here?
touch $out/${name}/dependencies.d/controlled
fi
for i in timeout-up timeout-down run notification-fd up down finish consumer-for producer-for pipeline-name restart-on-upgrade; do

View File

@ -1,4 +0,0 @@
{
writeAshScriptBin
}:
writeAshScriptBin "s6-rc-up-tree" {} (builtins.readFile ./s6-rc-up-tree.sh)

View File

@ -1,24 +0,0 @@
service=$1
blocks=""
for controlled in $(cd /run/services/controlled/ && echo *); do
down=$(s6-rc -b -un0 change $controlled)
echo $controlled $down
if test -n "$down"; then
blocks="$blocks $controlled "
fi
done
for s in $(s6-rc-db -d all-dependencies $service); do
for dep in $(s6-rc-db all-dependencies $s); do
case "$blocks" in
"* $dep *")
echo "not starting $s, blocked by $dep"
;;
*)
echo "starting $s because $service"
s6-rc -b -u change $s
;;
esac
done
done

View File

@ -1,7 +0,0 @@
the service starts
uncontrolled descendants start
controlled descendants don't start
descendants which depend on a _different_ controlled service, which is down, don't start
descendants which depend on a _different_ controlled service, which is up, do start

View File

@ -8,21 +8,17 @@
, fennel
, stdenv
, fennelrepl
, s6-rc-up-tree
, makeWrapper
}:
stdenv.mkDerivation {
name = "uevent-watch";
src = ./.;
nativeBuildInputs = [ fennelrepl makeWrapper ];
propagatedBuildInputs = [ s6-rc-up-tree ];
nativeBuildInputs = [ fennelrepl ];
installPhase = ''
mkdir -p $out/bin
cp -p ${writeFennel "uevent-watch" {
packages = [fennel anoia nellie lualinux];
mainFunction = "run";
} ./watch.fnl} $out/bin/uevent-watch
wrapProgram $out/bin/uevent-watch --prefix PATH : "${s6-rc-up-tree}/bin"
'';
checkPhase = ''
fennelrepl ./test.fnl

View File

@ -18,7 +18,7 @@
(fn start-service [devname linkname service]
(match (if linkname (symlink (.. "/dev/" devname) linkname) true)
ok (pcall system (%% "s6-rc-up-tree %q" service))
ok (pcall system (%% "s6-rc -b -u change %q" service))
(nil err) false))
(fn stop-service [linkname service]

View File

@ -1,13 +0,0 @@
{
writeScriptBin
, lib
}
: name : { runtimeInputs ? [] } : text : writeScriptBin name ''
#!/bin/sh
set -o errexit
set -o nounset
set -o pipefail
export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
${text}
''