mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/modules/system/activation/top-level.nix: allow overriding system.name
The toplevel derivations of systems that have `networking.hostName` set to `""` (because they want their hostname to be set by DHCP) used to be all named `nixos-system-unnamed-${config.system.nixos.label}`. This makes them hard to distinguish. A similar problem existed in NixOS tests where `vmName` is used in the `testScript` to refer to the VM. It defaulted to the `networking.hostName` which when set to `""` won't allow you to refer to the machine from the `testScript`. This commit makes the `system.name` configurable. It still defaults to: ``` if config.networking.hostName == "" then "unnamed" else config.networking.hostName; ``` but in case `networking.hostName` needs to be to `""` the `system.name` can be set to a distinguishable name.
This commit is contained in:
parent
27296cc5c5
commit
d06de760f8
2 changed files with 19 additions and 11 deletions
|
@ -92,9 +92,7 @@ let
|
|||
# `switch-to-configuration' that activates the configuration and
|
||||
# makes it bootable.
|
||||
baseSystem = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = let hn = config.networking.hostName;
|
||||
nn = if (hn != "") then hn else "unnamed";
|
||||
in "nixos-system-${nn}-${config.system.nixos.label}";
|
||||
name = "nixos-system-${config.system.name}-${config.system.nixos.label}";
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
buildCommand = systemBuilder;
|
||||
|
@ -265,6 +263,21 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
system.name = mkOption {
|
||||
type = types.str;
|
||||
default =
|
||||
if config.networking.hostName == ""
|
||||
then "unnamed"
|
||||
else config.networking.hostName;
|
||||
defaultText = '''networking.hostName' if non empty else "unnamed"'';
|
||||
description = ''
|
||||
The name of the system used in the <option>system.build.toplevel</option> derivation.
|
||||
</para><para>
|
||||
That derivation has the following name:
|
||||
<literal>"nixos-system-''${config.system.name}-''${config.system.nixos.label}"</literal>
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue