diff options
author | Jörg Thalheim <joerg@higgsboson.tk> | 2017-01-02 19:27:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-02 19:27:06 +0100 |
commit | 1cc8b830792eb415c97df939776e29cae26fefdf (patch) | |
tree | 0dd876eabcccc83616ca4c168a9539687f734d75 /nixos | |
parent | f16eda3fb1cdd25a2cee322c20ea8a904b764176 (diff) | |
parent | cb9195b7bcde7ec8a2d5fa99df0a93afacd5c537 (diff) |
Merge pull request #21566 from bjornfor/hostname
nixos: provide /etc/hostname
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index aaa78daeb3a3f..83d9854d3517f 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -910,20 +910,23 @@ in domainname "${cfg.domain}" ''; - environment.etc = mkIf (cfg.hostId != null) - [ - { - target = "hostid"; - 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 - '' else '' - echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out - ''} - ''; - } - ]; + 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 + '' 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 = [ pkgs.host |