initrd: use the new tmpfiles options to create tmpfiles config (#339503)

This commit is contained in:
Will Fancher 2024-09-05 17:02:30 -04:00 committed by GitHub
commit a96e54fe52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View File

@ -205,11 +205,12 @@ in
boot.initrd.systemd = { boot.initrd.systemd = {
contents = { contents = {
"/etc/tmpfiles.d/resolv.conf".text =
"L /etc/resolv.conf - - - - /run/systemd/resolve/stub-resolv.conf";
"/etc/systemd/resolved.conf".text = resolvedConf; "/etc/systemd/resolved.conf".text = resolvedConf;
}; };
tmpfiles.settings.systemd-resolved-stub."/etc/resolv.conf".L.argument =
"/run/systemd/resolve/stub-resolv.conf";
additionalUpstreamUnits = ["systemd-resolved.service"]; additionalUpstreamUnits = ["systemd-resolved.service"];
users.systemd-resolve = {}; users.systemd-resolve = {};
groups.systemd-resolve = {}; groups.systemd-resolve = {};

View File

@ -163,6 +163,20 @@ in
}; };
config = { config = {
warnings =
let
paths = lib.filter (path:
path != null && lib.hasPrefix "/etc/tmpfiles.d/" path
) (map (path: path.target) config.boot.initrd.systemd.storePaths);
in
lib.optional (lib.length paths > 0) (lib.concatStringsSep " " [
"Files inside /etc/tmpfiles.d in the initrd need to be created with"
"boot.initrd.systemd.tmpfiles.settings."
"Creating them by hand using boot.initrd.systemd.contents or"
"boot.initrd.systemd.storePaths will lead to errors in the future."
"Found these problematic files: ${lib.concatStringsSep ", " paths}"
]);
systemd.additionalUpstreamSystemUnits = [ systemd.additionalUpstreamSystemUnits = [
"systemd-tmpfiles-clean.service" "systemd-tmpfiles-clean.service"
"systemd-tmpfiles-clean.timer" "systemd-tmpfiles-clean.timer"