Skip to content

initrd: Include hostname in udhcpc DHCP options#229488

Open
eduarrrd wants to merge 1 commit intoNixOS:masterfrom
eduarrrd:dhcphostoption
Open

initrd: Include hostname in udhcpc DHCP options#229488
eduarrrd wants to merge 1 commit intoNixOS:masterfrom
eduarrrd:dhcphostoption

Conversation

@eduarrrd
Copy link
Copy Markdown
Contributor

@eduarrrd eduarrrd commented May 2, 2023

Use case: host discovery for remote unlock. E.g.

  • fixed address assigned based on the DHCP client's hostname (as opposed to e.g. MAC address)
  • automated DNS record creation/update based on the DHCP client's hostname

Tested using Tcpdump.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels May 2, 2023
@eduarrrd eduarrrd force-pushed the dhcphostoption branch 3 times, most recently from e415875 to 7004376 Compare May 2, 2023 15:22
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 2, 2023
@eduarrrd eduarrrd marked this pull request as ready for review May 2, 2023 19:35
@eduarrrd eduarrrd requested a review from dasJ as a code owner May 2, 2023 19:35
@eduarrrd eduarrrd requested a review from SuperSandro2000 May 4, 2023 19:46
Comment on lines 42 to 44
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
udhcpcHostnameArg = if cfg.udhcpc.hostName != ""
then "-x hostname:${config.networking.hostName}"
else "";
udhcpcHostnameArg = lib.optionalString (cfg.udhcpc.hostName != "") "-x hostname:${config.networking.hostName}";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this should probably be rather a default or apply option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied your suggestion, it's certainly cleaner.

Also this should probably be rather a default

What do you mean here? The value of the option has a sensible default already, no? Are you talking about some function I should be using that simplifies this?

or apply option.

I'm not sure what you mean by this. Some searching reveals a apply argument, but it doesn't seem official as per https://nixos.org/manual/nixos/unstable/index.html#sec-option-declarations

Does using it mean that value of cfg.udhcpc.hostName will be the string -x hostname:... ? If so, that makes re-use hard, no?

Use case: host discovery for remote unlock. E.g.

* fixed address assigned based on the DHCP client's hostname
  (as opposed to e.g. MAC address)
* automated DNS record creation/update based on the DHCP client's hostname
@eduarrrd eduarrrd requested a review from RaitoBezarius May 7, 2023 20:17
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants