Write generation state into a state file and restructure the services.json file produced by nix.

This commit is contained in:
R-VdP 2023-02-09 10:25:04 +00:00
parent 8f31818a27
commit c3be9ceb19
No known key found for this signature in database
6 changed files with 143 additions and 80 deletions

View file

@ -18,16 +18,14 @@ in
};
services =
map
(name:
let
serviceName = "${name}.service";
in
{
name = serviceName;
service = ''${nixosConfig.config.systemd.units."${serviceName}".unit}/${serviceName}'';
})
nixosConfig.config.service-manager.services;
lib.listToAttrs
(map
(name:
let
serviceName = "${name}.service";
in
lib.nameValuePair serviceName { storePath = ''${nixosConfig.config.systemd.units."${serviceName}".unit}/${serviceName}''; })
nixosConfig.config.service-manager.services);
servicesPath = pkgs.writeTextFile {
name = "services";

View file

@ -4,31 +4,32 @@
}:
let
services =
lib.listToAttrs (lib.flip lib.genList 30 (ix: {
name = "service-${toString ix}";
value = {
enable = true;
description = "service-${toString ix}";
wants = [ "network-online.target" ];
after = [
"network-online.target"
"avahi-daemon.service"
"chrony.service"
"nss-lookup.target"
"tinc.service"
"pulseaudio.service"
];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecReload = "true";
};
wantedBy = [ "multi-user.target" ];
script = ''
sleep ${if ix > 20 then "3" else "1"}
'';
};
}));
lib.listToAttrs
(lib.flip lib.genList 10 (ix:
lib.nameValuePair "service-${toString ix}"
{
enable = true;
description = "service-${toString ix}";
wants = [ "network-online.target" ];
after = [
"network-online.target"
"avahi-daemon.service"
"chrony.service"
"nss-lookup.target"
"tinc.service"
"pulseaudio.service"
];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecReload = "true";
};
wantedBy = [ "multi-user.target" ];
script = ''
sleep ${if ix > 5 then "3" else "1"}
'';
})
);
in
{
options = {