mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/systemd/initrd: Set /etc/hostname in the initrd.
With the the Systemd-based initrd, systemd-journald is doing the logging. One of Journald's Trusted Journal Fields is `_HOSTNAME` (systemd.journal-fields(7)). Without explicitly setting the hostname via this file or the kernel cmdline, `localhost` is used and captured in the journal. As a result, a boot's log references multiple hostnames. With centralized log collection this breaks filtering (more so when logs from multiple Systemd-based initrds are streaming in simultaneously. Fixes #318907.
This commit is contained in:
parent
cb9a96f23c
commit
7cc66df3ec
1 changed files with 4 additions and 1 deletions
|
@ -160,7 +160,7 @@ in {
|
|||
description = "Set of files that have to be linked into the initrd";
|
||||
example = literalExpression ''
|
||||
{
|
||||
"/etc/hostname".text = "mymachine";
|
||||
"/etc/machine-id".source = /etc/machine-id;
|
||||
}
|
||||
'';
|
||||
default = {};
|
||||
|
@ -444,6 +444,9 @@ in {
|
|||
"/etc/os-release".source = config.boot.initrd.osRelease;
|
||||
"/etc/initrd-release".source = config.boot.initrd.osRelease;
|
||||
|
||||
# For systemd-journald's _HOSTNAME field; needs to be set early, cannot be backfilled.
|
||||
"/etc/hostname".text = config.networking.hostName;
|
||||
|
||||
} // optionalAttrs (config.environment.etc ? "modprobe.d/nixos.conf") {
|
||||
"/etc/modprobe.d/nixos.conf".source = config.environment.etc."modprobe.d/nixos.conf".source;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue