Skip to content

nixos/netbird: add client options for DNS, routing, SSH, rosenpass an… - #487627

Closed
shuuri-labs wants to merge 2 commits into
NixOS:masterfrom
shuuri-labs:update-netbird-client-module
Closed

nixos/netbird: add client options for DNS, routing, SSH, rosenpass an…#487627
shuuri-labs wants to merge 2 commits into
NixOS:masterfrom
shuuri-labs:update-netbird-client-module

Conversation

@shuuri-labs

@shuuri-labs shuuri-labs commented Feb 6, 2026

Copy link
Copy Markdown

…d connection

Motivation

The NetBird client module currently requires users to manually set NB_* environment variables via the environment option to configure features like DNS, routing, SSH, Rosenpass, and self-hosted server URLs. However, environment uses NixOS module merging, which rejects conflicts with module-computed keys (like NB_STATE_DIR), making it awkward to use as an escape hatch.

Rather than adding individual typed options for every upstream setting (which RFC 0042 recommends against) this adds a proper extraEnvironment escape hatch and documents how to use it alongside the existing config option.

Changes

  • extraEnvironment option: New attrsOf str option that merges with computed environment variables using //, so user values cleanly override module defaults. This is the RFC 0042 "structural escape hatch" pattern.
  • Documentation rewrite (netbird.md): Replaces the minimal docs with categorized examples showing how to configure DNS, routing, firewall, Rosenpass, SSH, connection behavior, hostname/debug, and self-hosted deployments using extraEnvironment and config. Links to the upstream env var reference.
  • Redirects (redirects.json): Adds entries for the new documentation sections.
  • Tests (nixos/tests/netbird.nix): Adds test clients exercising both escape hatches - envtest verifies NB_* vars from extraEnvironment appear in the systemd service environment, configtest verifies config values appear in config.d/50-nixos.json.
  • Hardened option description: Updates the rosenpass cross-reference to point at extraEnvironment instead of a non-existent typed option.

How to test

nix build .#checks.x86_64-linux.nixosTests.netbird -L

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@nixpkgs-ci nixpkgs-ci Bot added the 12.first-time contribution This PR is the author's first one; please be gentle! label Feb 6, 2026
@shuuri-labs
shuuri-labs force-pushed the update-netbird-client-module branch from 7191262 to fd9865c Compare February 6, 2026 13:53
@nixpkgs-ci
nixpkgs-ci Bot requested a review from GetPsyched February 6, 2026 13:58
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: documentation This PR adds or changes documentation labels Feb 6, 2026
@eyJhb

eyJhb commented Feb 9, 2026

Copy link
Copy Markdown
Member

Most of what this PR does seems to go against https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md . Having these options just adds more maintenance burden onto the module, while also somewhat limiting it.

I think the reasonable thing to do, would instead be to explain better how services.netbird.clients.<name>.environment works, ie. link to the Netbird documentation specifying you can do NB_<flag-name>.

In theory the module (the one currently merged into nixpkgs), could also make use of deprecating some of the options, as they don't make any sense to include in the module.

@shuuri-labs
shuuri-labs force-pushed the update-netbird-client-module branch 5 times, most recently from 5d7913f to 3f359f9 Compare February 24, 2026 16:34
@shuuri-labs

Copy link
Copy Markdown
Author

@eyJhb thanks for taking a look at this + directing me to RFC 0042. The convention makes sense to me and definitely seems more "nix-y" than what I had done before.

In this latest version I've removed all the typed options and instead added:

  • An extraEnvironment option - an attrsOf str that merges with the module's computed env vars using //, so user values cleanly override defaults. This should adhere to the RFC 0042 "structural escape hatch" pattern. (The existing environment option uses module merging which rejects conflicts with computed keys like NB_STATE_DIR, so extraEnvironment is needed as a separate option.)

  • A rewritten netbird.md that explains both escape hatches (extraEnvironment for NB_* env vars, config for config.json keys), shows categorized examples for each feature area (DNS, routing, rosenpass, SSH, etc.), and links to the upstream env var reference.

  • Updated tests

Also realized I forgot to set myself as the maintainer for this module (whoops), so I've done that too.

@nixpkgs-ci nixpkgs-ci Bot added the 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` label Feb 24, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 14, 2026
Instead of adding individual typed options for every upstream setting
(which goes against RFC 0042), add an extraEnvironment escape hatch
and document how to use NB_* environment variables and the config
option for full client configuration.
@shuuri-labs
shuuri-labs force-pushed the update-netbird-client-module branch from 3f359f9 to c393335 Compare April 21, 2026 16:28
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 21, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from nazarewk April 21, 2026 16:34
on demand, for example to connect to work-related or otherwise conflicting network only when required.
See the option description for more information.

[environment](#opt-services.netbird.clients._name_.environment) allows you to pass additional configurations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why has been this setting removed from the docs?

{
services.netbird.clients.work = {
port = 51820;
extraEnvironment = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, why do we need extraEnvironment? All the examples now are with extraEnvironment instead of environment. I still don't get why is extraEnvironment introduced 🤔 Could you expand and show examples comparing against environment?

@RafaelKr

Copy link
Copy Markdown
Contributor

For reference shuuri-labs @ #487367 (comment):

I'm no longer with netbird, and since I've switched to Tailscale in my own homelab, so I'll be ceasing work on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 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. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants