nixos-generate-config: Configure networking.hostId by default
The host id value gets generated by reading a 32-bit value from /dev/urandom. This makes programs that rely on a correct host id more reliable. It also makes using ZFS more seamless, as you don't need to configure the hostId manually; instead, it becomes part of your config from the moment you install NixOS.
This commit is contained in:
parent
e9affb4274
commit
7a7bf8368e
@ -476,6 +476,14 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate a random 32-bit value to use as the host id
|
||||||
|
open my $rnd, "<", "/dev/urandom" or die $!;
|
||||||
|
read $rnd, $hostIdBin, 4;
|
||||||
|
close $rnd;
|
||||||
|
|
||||||
|
# Convert the 32-bit value to a hex string
|
||||||
|
my $hostIdHex = unpack("H*", $hostIdBin);
|
||||||
|
|
||||||
write_file($fn, <<EOF);
|
write_file($fn, <<EOF);
|
||||||
# Edit this configuration file to define what should be installed on
|
# Edit this configuration file to define what should be installed on
|
||||||
# your system. Help is available in the configuration.nix(5) man page
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
@ -491,6 +499,7 @@ EOF
|
|||||||
|
|
||||||
$bootLoaderConfig
|
$bootLoaderConfig
|
||||||
# networking.hostName = "nixos"; # Define your hostname.
|
# networking.hostName = "nixos"; # Define your hostname.
|
||||||
|
networking.hostId = "$hostIdHex";
|
||||||
# networking.wireless.enable = true; # Enables wireless.
|
# networking.wireless.enable = true; # Enables wireless.
|
||||||
|
|
||||||
# Select internationalisation properties.
|
# Select internationalisation properties.
|
||||||
|
Loading…
Reference in New Issue
Block a user