start correct services at boot
- uncontrolled services that are not dependent on a controlled service - controllers - _not_ controlled services or any other service that depends on one
This commit is contained in:
parent
6daeaf29a0
commit
b15542b668
@ -1,4 +1,4 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (pkgs)
|
inherit (pkgs)
|
||||||
execline
|
execline
|
||||||
@ -6,17 +6,38 @@ let
|
|||||||
s6-init-bin
|
s6-init-bin
|
||||||
s6-linux-init
|
s6-linux-init
|
||||||
stdenvNoCC;
|
stdenvNoCC;
|
||||||
|
inherit (lib.lists) unique concatMap;
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.services) bundle;
|
inherit (pkgs.liminix.services) bundle;
|
||||||
|
|
||||||
s6-rc-db =
|
s6-rc-db =
|
||||||
let
|
let
|
||||||
|
# In the default bundle we need to have all the services
|
||||||
|
# in config.services except for controlled services and
|
||||||
|
# anything that depends on one. But we do need the controllers
|
||||||
|
# themselves.
|
||||||
|
|
||||||
|
# So, find all required services and their transitive
|
||||||
|
# dependencies and their controllers. remove all controlled
|
||||||
|
# services and all services that have a controlled service as
|
||||||
|
# dependency
|
||||||
|
|
||||||
|
isControlled = s : s ? controller && s.controller != null;
|
||||||
|
deps = s : s.dependencies ++
|
||||||
|
lib.optional (isControlled s) s.controller;
|
||||||
|
flatDeps = s : [s] ++ concatMap flatDeps (deps s);
|
||||||
|
allServices = unique (concatMap flatDeps (builtins.attrValues config.services));
|
||||||
|
isDependentOnControlled = s :
|
||||||
|
isControlled s ||
|
||||||
|
(lib.lists.any isDependentOnControlled s.dependencies);
|
||||||
|
|
||||||
|
defaultStart =
|
||||||
|
builtins.filter
|
||||||
|
(s: !(isDependentOnControlled s))
|
||||||
|
(lib.debug.traceValSeqN 2 allServices);
|
||||||
defaultDefaultTarget = bundle {
|
defaultDefaultTarget = bundle {
|
||||||
name = "default";
|
name = "default";
|
||||||
contents =
|
contents = defaultStart;
|
||||||
builtins.map
|
|
||||||
(s: if (s ? controller && s.controller != null) then s.controller else s)
|
|
||||||
(builtins.attrValues config.services));
|
|
||||||
};
|
};
|
||||||
servicesAttrs = {
|
servicesAttrs = {
|
||||||
default = defaultDefaultTarget;
|
default = defaultDefaultTarget;
|
||||||
|
Loading…
Reference in New Issue
Block a user