Merge pull request #21566 from bjornfor/hostname

nixos: provide /etc/hostname

authored by Jörg Thalheim and committed by GitHub 1cc8b830 f16eda3f

+17 -14
+17 -14
nixos/modules/tasks/network-interfaces.nix
··· 910 910 domainname "${cfg.domain}" 911 911 ''; 912 912 913 - environment.etc = mkIf (cfg.hostId != null) 914 - [ 915 - { 916 - target = "hostid"; 917 - source = pkgs.runCommand "gen-hostid" {} '' 918 - hi="${cfg.hostId}" 919 - ${if pkgs.stdenv.isBigEndian then '' 920 - echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out 921 - '' else '' 922 - echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out 923 - ''} 924 - ''; 925 - } 926 - ]; 913 + environment.etc."hostid" = mkIf (cfg.hostId != null) 914 + { source = pkgs.runCommand "gen-hostid" {} '' 915 + hi="${cfg.hostId}" 916 + ${if pkgs.stdenv.isBigEndian then '' 917 + echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > $out 918 + '' else '' 919 + echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > $out 920 + ''} 921 + ''; 922 + }; 923 + 924 + # static hostname configuration needed for hostnamectl and the 925 + # org.freedesktop.hostname1 dbus service (both provided by systemd) 926 + environment.etc."hostname" = mkIf (cfg.hostName != "") 927 + { 928 + text = cfg.hostName + "\n"; 929 + }; 927 930 928 931 environment.systemPackages = 929 932 [ pkgs.host