Merge pull request #21566 from bjornfor/hostname

nixos: provide /etc/hostname
This commit is contained in:
Jörg Thalheim 2017-01-02 19:27:06 +01:00 committed by GitHub
commit 1cc8b83079

View File

@ -910,11 +910,8 @@ in
domainname "${cfg.domain}"
'';
environment.etc = mkIf (cfg.hostId != null)
[
{
target = "hostid";
source = pkgs.runCommand "gen-hostid" {} ''
environment.etc."hostid" = mkIf (cfg.hostId != null)
{ source = pkgs.runCommand "gen-hostid" {} ''
hi="${cfg.hostId}"
${if pkgs.stdenv.isBigEndian then ''
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out
@ -922,8 +919,14 @@ in
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out
''}
'';
}
];
};
# static hostname configuration needed for hostnamectl and the
# org.freedesktop.hostname1 dbus service (both provided by systemd)
environment.etc."hostname" = mkIf (cfg.hostName != "")
{
text = cfg.hostName + "\n";
};
environment.systemPackages =
[ pkgs.host