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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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
@wegank wegank added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package label Dec 21, 2024
@nazarewk nazarewk force-pushed the netbird-improvements branch from 257f218 to 0a02a10 Compare December 27, 2024 11:16
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 27, 2024
@wegank wegank removed 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package labels Dec 29, 2024
@nazarewk nazarewk force-pushed the netbird-improvements branch from 0a02a10 to f2dd2b8 Compare January 3, 2025 12:27
@nix-owners nix-owners bot requested a review from vrifox January 3, 2025 12:34
@nazarewk nazarewk force-pushed the netbird-improvements branch from f2dd2b8 to dd07ee7 Compare January 8, 2025 12:26
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 8, 2025
@nazarewk nazarewk force-pushed the netbird-improvements branch 2 times, most recently from 003fa10 to b33acd9 Compare January 9, 2025 14:42
@fricklerhandwerk
Copy link
Contributor

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

@oddlama
Copy link
Contributor

oddlama commented Jan 20, 2025

(And this still modifies old release notes)

@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
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: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.