initrd: Optional systemd-based initrd

This commit is contained in:
Will Fancher 2022-03-19 23:00:06 -04:00
parent 25113740a5
commit 2d4ebf1259
7 changed files with 385 additions and 14 deletions

View file

@ -291,16 +291,10 @@ in rec {
};
};
serviceConfig = { name, config, ... }: {
mkServiceConfig = path: { name, config, ... }: {
config = mkMerge
[ { # Default path for systemd services. Should be quite minimal.
path = mkAfter
[ pkgs.coreutils
pkgs.findutils
pkgs.gnugrep
pkgs.gnused
systemd
];
path = mkAfter path;
environment.PATH = "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}";
}
(mkIf (config.preStart != "")
@ -330,6 +324,16 @@ in rec {
];
};
serviceConfig = mkServiceConfig [
pkgs.coreutils
pkgs.findutils
pkgs.gnugrep
pkgs.gnused
systemd
];
initrdServiceConfig = mkServiceConfig [];
mountConfig = { config, ... }: {
config = {
mountConfig =
@ -387,6 +391,15 @@ in rec {
'';
};
initrdServiceToUnit = name: def:
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Service]
${attrsToSection def.serviceConfig}
'';
};
socketToUnit = name: def:
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +