Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/modules/system/activation/top-level.nix: allow overriding system.name #85638

Merged
merged 1 commit into from Jul 20, 2020

Conversation

basvandijk
Copy link
Member

@basvandijk basvandijk commented Apr 20, 2020

Motivation for this change

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.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@basvandijk basvandijk changed the title nixos/modules/virtualisation/qemu-vm.nix: allow overriding vmName nixos/modules/system/activation/top-level.nix: allow overriding system.name Apr 23, 2020
@basvandijk basvandijk requested a review from grahamc April 23, 2020 09:38
@basvandijk
Copy link
Member Author

To confirm I didn't screw up NixOS module evaluation:
@GrahamcOfBorg test simple

…m.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.
@basvandijk
Copy link
Member Author

@GrahamcOfBorg test simple

@basvandijk basvandijk merged commit 7d061ce into NixOS:master Jul 20, 2020
@ajs124
Copy link
Member

ajs124 commented Jul 21, 2020

This seems to have broken eval of unstable-small: https://hydra.nixos.org/jobset/nixos/unstable-small#tabs-errors

error: "\u001b[31;1merror:\u001b[0m\u001b[34;1m --- UndefinedVarError --- hydra-eval-jobs\u001b[0m\n\u001b[34;1mat: \u001b[33;1m(499:24)\u001b[34;1m in file: \u001b[0m/nix/store/bv0m96mpsr55m7ra3cnrq7jj981l54gm-source/nixos/modules/virtualisation/qemu-vm.nix\n\n   498|       mkOption {\n   499|         default = \"./${vmName}-efi-vars.fd\";\n      |                        \u001b[31;1m^\u001b[0m\n   500|         description =\n\nundefined variable '\u001b[33;1mvmName\u001b[0m'"

@ajs124 ajs124 mentioned this pull request Jul 21, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants