nixos/stage-1-init: Set host id for ZFS

main
Janne Heß 2 years ago
parent 031b95e587
commit 3396c96e4b
No known key found for this signature in database
GPG Key ID: 69165158F05265DF
  1. 21
      nixos/modules/tasks/network-interfaces.nix

@ -403,6 +403,15 @@ let
</itemizedlist>
'';
hostidFile = pkgs.runCommand "gen-hostid" { preferLocalBuild = true; } ''
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
''}
'';
in
{
@ -1383,16 +1392,8 @@ in
domainname "${cfg.domain}"
'';
environment.etc.hostid = mkIf (cfg.hostId != null)
{ source = pkgs.runCommand "gen-hostid" { preferLocalBuild = true; } ''
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 = hostidFile; };
boot.initrd.systemd.contents."/etc/hostid" = mkIf (cfg.hostId != null) { source = hostidFile; };
# static hostname configuration needed for hostnamectl and the
# org.freedesktop.hostname1 dbus service (both provided by systemd)

Loading…
Cancel
Save