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/netbird: harden and extend options #287236

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

nazarewk
Copy link
Member

@nazarewk nazarewk commented Feb 8, 2024

Description of changes

I have recently extensively tested and fixed all features of Netbird in my own implementation of multi-instance Netbird installations.

While doing so I discovered another multi-instance implementation got merged into nixpkgs #246055 which is slightly different, but still a solid base to upstream the rest of my changes:

  • running as DynamicUser it's own user with minimal set of permissions
    • it was there before, but was lacking some of capabilities,
  • made some configurations situational
  • add more unmanaged interface configurations
  • quality of life improvements:
    • configure log level for each interface
    • optionally turn off starting during boot
    • openFirewall by default
    • add shortcuts/wrappers for each created instance

I think it's a pretty good time to upstream, because I will be extensively using it at work: just launched my first Colmena-managed NixOS into GCE.

There are plans to support multi-account connections on the same daemon in Q2/2024 (see the slack message), but it's not known what shape it will take at all.

I decided to implement following significant changes:

  • instances must specify a port they will be listening on as it doesn't make much sense to give an immediately conflicting default,
  • aliased tunnels to clients, because a word tunnel does not exist in Netbird's nomenclature (unlike some other VPNs) and is pretty misleading. Also clients.* play nicely with my plan to implement a server in near future.
  • skipped destructuring expressions (eg: {name, ...}: name -> client: client.name) because they make the code very hard to follow and update with increased number of options,

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 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/` labels Feb 8, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Feb 8, 2024
@nazarewk nazarewk changed the title nixos/netbird: run as DynamicUser with more configuration options nixos/netbird: bring back DynamicUser with more configuration options Feb 9, 2024
@nazarewk nazarewk marked this pull request as draft February 9, 2024 08:43
@nazarewk nazarewk changed the title nixos/netbird: bring back DynamicUser with more configuration options nixos/netbird: harden and extend options Feb 9, 2024
@nazarewk nazarewk force-pushed the netbird-improvements branch 5 times, most recently from 0cf761f to 4179661 Compare February 9, 2024 12:47
@nazarewk nazarewk marked this pull request as ready for review February 9, 2024 12:54
nazarewk added a commit to nazarewk-iac/nix-configs that referenced this pull request Feb 9, 2024
@Tom-Hubrecht Tom-Hubrecht assigned mlvzk and unassigned mlvzk Feb 10, 2024
nixos/modules/services/networking/netbird.nix Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.md Outdated Show resolved Hide resolved
nixos/tests/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/netbird.nix Outdated Show resolved Hide resolved
@nazarewk nazarewk force-pushed the netbird-improvements branch 3 times, most recently from a734f1e to 35a7c67 Compare February 13, 2024 11:08
@nazarewk
Copy link
Member Author

(And this still modifies old release notes)

any idea how to prevent that? nixpkgs is not activatable without this modification

@Mic92
Copy link
Member

Mic92 commented Jan 20, 2025

I'd merge but NixOS tests seem to be broken or hanging? @Mic92 how to unblock this?

Fixing the test? I am not using netbird and have currently other things on my list. Sorry.

@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Jan 20, 2025

I'm not sure if and how the test is even broken. All that's observable is that it's running seemingly forever, and I wondered how to re-trigger it or something. Is any of that ofborg stuff documented anywhere @dasJ?

@nazarewk
Copy link
Member Author

I'd merge but NixOS tests seem to be broken or hanging? @Mic92 how to unblock this?

Fixing the test? I am not using netbird and have currently other things on my list. Sorry.

I'll adress remaining things this week. Otherwise I didn't touch it apart from rebasing for months already.

@wegank wegank added the 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people label Jan 20, 2025
@nazarewk nazarewk force-pushed the netbird-improvements branch from b33acd9 to c5f469a Compare January 23, 2025 10:29
@nix-owners nix-owners bot requested a review from vrifox January 23, 2025 10:38
@nazarewk nazarewk force-pushed the netbird-improvements branch from c5f469a to c65c0c2 Compare January 23, 2025 10:47
@nazarewk
Copy link
Member Author

I have fixed the tests (I did some incompatible changes to the module on the way), but even though I've added option rename, the manual still doesn't build:

imports = [
(mkRenamedOptionModule [ "services" "netbird" "tunnels" ] [ "services" "netbird" "clients" ])
];

@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin and removed 10.rebuild-darwin: 1-10 labels Jan 23, 2025
@wegank wegank removed the 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people label Jan 23, 2025
@nazarewk nazarewk force-pushed the netbird-improvements branch from c65c0c2 to 55da707 Compare January 27, 2025 08:42
@nazarewk nazarewk force-pushed the netbird-improvements branch from 55da707 to 7c2eccb Compare January 27, 2025 08:46
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Jan 27, 2025
@nazarewk
Copy link
Member Author

nazarewk commented Jan 27, 2025

I have fixed the tests (I did some incompatible changes to the module on the way), but even though I've added option rename, the manual still doesn't build:

imports = [
(mkRenamedOptionModule [ "services" "netbird" "tunnels" ] [ "services" "netbird" "clients" ])
];

seems like there is some (actually quite a lot, just not AS relevant as this one) precedent to removing & editing old release notes:
e3812e1#diff-9538c800780031db3dfa7746f5a36fbbc895c60fdc896385bedd36940927427dL79-L81

@nazarewk nazarewk force-pushed the netbird-improvements branch from 7c2eccb to 3ac6ed7 Compare January 27, 2025 09:02
@nazarewk nazarewk force-pushed the netbird-improvements branch 2 times, most recently from 183cced to 64a2ccd Compare January 27, 2025 09:36
@nazarewk
Copy link
Member Author

I have fixed the tests (I did some incompatible changes to the module on the way), but even though I've added option rename, the manual still doesn't build:

imports = [
(mkRenamedOptionModule [ "services" "netbird" "tunnels" ] [ "services" "netbird" "clients" ])
];

seems like there is some (actually quite a lot, just not AS relevant as this one) precedent to removing & editing old release notes: e3812e1#diff-9538c800780031db3dfa7746f5a36fbbc895c60fdc896385bedd36940927427dL79-L81

As per #287236 (comment) , I am temporarily using mkAliasOptionModule until there is a better implementation to build release notes without errors.

@nazarewk nazarewk force-pushed the netbird-improvements branch from 64a2ccd to 5e9af4a Compare January 27, 2025 10:32
@fricklerhandwerk fricklerhandwerk merged commit 9962b33 into NixOS:master Jan 28, 2025
26 of 28 checks passed
@fricklerhandwerk
Copy link
Contributor

Thanks a great deal for sticking through it, and sorry for the long delay.

@nazarewk nazarewk deleted the netbird-improvements branch February 5, 2025 08:47
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: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.