2024-10-05 11:50:12 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
utils,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-30 19:38:13 +02:00
|
|
|
let
|
2024-10-05 11:50:12 +02:00
|
|
|
inherit (lib)
|
|
|
|
mapAttrs'
|
|
|
|
nameValuePair
|
|
|
|
mkMerge
|
|
|
|
mapAttrsToList
|
|
|
|
;
|
2024-09-30 19:38:13 +02:00
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
2024-10-05 11:50:12 +02:00
|
|
|
inherit (utils.systemdUtils.lib)
|
|
|
|
targetToUnit
|
|
|
|
serviceToUnit
|
|
|
|
;
|
|
|
|
|
|
|
|
units-texts = mapAttrs' (
|
|
|
|
_: unit:
|
|
|
|
nameValuePair unit.name {
|
|
|
|
file = unit.text;
|
|
|
|
mode = "0644";
|
|
|
|
}
|
|
|
|
) config.units;
|
|
|
|
units-aliases = mkMerge (
|
|
|
|
mapAttrsToList (
|
|
|
|
_: unit:
|
|
|
|
mkMerge (
|
|
|
|
map (aka: {
|
|
|
|
${aka} = symlink "${unit.name}";
|
|
|
|
}) (unit.aliases or [ ])
|
|
|
|
)
|
|
|
|
) config.units
|
|
|
|
);
|
|
|
|
units-extraWants = mkMerge (
|
|
|
|
mapAttrsToList (
|
|
|
|
_: unit:
|
|
|
|
mkMerge (
|
|
|
|
map (unit2: {
|
|
|
|
"${unit2}.wants" = dir {
|
|
|
|
${unit.name} = symlink "../${unit.name}";
|
|
|
|
};
|
|
|
|
}) (unit.wantedBy or [ ])
|
|
|
|
)
|
|
|
|
) config.units
|
|
|
|
);
|
|
|
|
units-extraUpholds = mkMerge (
|
|
|
|
mapAttrsToList (
|
|
|
|
_: unit:
|
|
|
|
mkMerge (
|
|
|
|
map (unit2: {
|
|
|
|
"${unit2}.upholds" = dir {
|
|
|
|
${unit.name} = symlink "../${unit.name}";
|
|
|
|
};
|
|
|
|
}) (unit.upheldBy or [ ])
|
|
|
|
)
|
|
|
|
) config.units
|
|
|
|
);
|
|
|
|
units-extraRequires = mkMerge (
|
|
|
|
mapAttrsToList (
|
|
|
|
_: unit:
|
|
|
|
mkMerge (
|
|
|
|
map (unit2: {
|
|
|
|
"${unit2}.requires" = dir {
|
|
|
|
${unit.name} = symlink "../${unit.name}";
|
|
|
|
};
|
|
|
|
}) (unit.requiredBy or [ ])
|
|
|
|
)
|
|
|
|
) config.units
|
|
|
|
);
|
2024-10-01 11:00:15 +02:00
|
|
|
|
2024-09-30 19:38:13 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = {
|
2024-10-05 11:50:12 +02:00
|
|
|
units = {
|
|
|
|
default-target = targetToUnit {
|
|
|
|
name = "default.target";
|
|
|
|
aliases = [];
|
|
|
|
wantedBy = [];
|
|
|
|
requiredBy = [];
|
|
|
|
upheldBy = [];
|
|
|
|
unitConfig.Description = "target to boot";
|
|
|
|
};
|
|
|
|
sysinit-target = targetToUnit {
|
|
|
|
name = "sysinit.target";
|
|
|
|
aliases = [];
|
|
|
|
wantedBy = [];
|
|
|
|
requiredBy = [];
|
|
|
|
upheldBy = [];
|
|
|
|
unitConfig.Description = "sysinit.target";
|
|
|
|
};
|
|
|
|
agetty = serviceToUnit {
|
|
|
|
name = "getty.service";
|
|
|
|
aliases = [];
|
|
|
|
wantedBy = [ "default.target" ];
|
|
|
|
requiredBy = [];
|
|
|
|
upheldBy = [];
|
|
|
|
environment = {};
|
|
|
|
unitConfig = {
|
|
|
|
Description = "Serial Shell";
|
|
|
|
Before = [ "default.target" ];
|
|
|
|
};
|
|
|
|
serviceConfig.ExecStart =
|
|
|
|
let
|
|
|
|
login = pkgs.writeScript "login" ''
|
|
|
|
#!/bin/ash
|
|
|
|
. /etc/profile
|
|
|
|
exec /bin/ash
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
"${pkgs.util-linux}/bin/agetty --login-program ${login} ttyS0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-01 11:00:15 +02:00
|
|
|
kernel.config = {
|
|
|
|
CGROUPS = "y";
|
|
|
|
DEVTMPFS = "y";
|
|
|
|
INOTIFY_USER = "y";
|
|
|
|
SIGNALFD = "y";
|
|
|
|
TIMERFD = "y";
|
|
|
|
EPOLL = "y";
|
|
|
|
UNIX = "y";
|
|
|
|
SYSFS = "y";
|
|
|
|
PROC_FS = "y";
|
|
|
|
FHANDLE = "y";
|
|
|
|
};
|
2024-09-30 19:38:13 +02:00
|
|
|
boot.commandLine = [
|
|
|
|
"systemd.log_level=7"
|
|
|
|
#"systemd.crash_shell=true"
|
|
|
|
];
|
|
|
|
filesystem = dir {
|
|
|
|
etc = dir {
|
|
|
|
systemd = dir {
|
2024-10-05 11:50:12 +02:00
|
|
|
system = dir (mkMerge [
|
|
|
|
units-texts
|
|
|
|
units-aliases
|
|
|
|
units-extraWants
|
|
|
|
units-extraUpholds
|
|
|
|
units-extraRequires
|
|
|
|
]);
|
2024-09-30 19:38:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
bin = dir {
|
|
|
|
init = symlink "${pkgs.systemd}/bin/init";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|