mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-13 21:32:23 +03:00
Merge pull request #21566 from bjornfor/hostname
nixos: provide /etc/hostname
This commit is contained in:
commit
1cc8b83079
@ -910,20 +910,23 @@ in
|
|||||||
domainname "${cfg.domain}"
|
domainname "${cfg.domain}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
environment.etc = mkIf (cfg.hostId != null)
|
environment.etc."hostid" = mkIf (cfg.hostId != null)
|
||||||
[
|
{ source = pkgs.runCommand "gen-hostid" {} ''
|
||||||
{
|
hi="${cfg.hostId}"
|
||||||
target = "hostid";
|
${if pkgs.stdenv.isBigEndian then ''
|
||||||
source = pkgs.runCommand "gen-hostid" {} ''
|
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out
|
||||||
hi="${cfg.hostId}"
|
'' else ''
|
||||||
${if pkgs.stdenv.isBigEndian then ''
|
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out
|
||||||
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out
|
''}
|
||||||
'' else ''
|
'';
|
||||||
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 =
|
environment.systemPackages =
|
||||||
[ pkgs.host
|
[ pkgs.host
|
||||||
|
Loading…
Reference in New Issue
Block a user