mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-19 20:09:01 +02:00
Merge pull request #186669 from misuzu/netbird-init
netbird: init at 0.8.9
This commit is contained in:
commit
f8594cd431
|
@ -205,6 +205,13 @@
|
|||
<link linkend="opt-services.outline.enable">services.outline</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://netbird.io">netbird</link>, a zero
|
||||
configuration VPN. Available as
|
||||
<link xlink:href="options.html#opt-services.netbird.enable">services.netbird</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://github.com/aiberia/persistent-evdev">persistent-evdev</link>,
|
||||
|
|
|
@ -76,6 +76,9 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
|
||||
- [Outline](https://www.getoutline.com/), a wiki and knowledge base similar to Notion. Available as [services.outline](#opt-services.outline.enable).
|
||||
|
||||
- [netbird](https://netbird.io), a zero configuration VPN.
|
||||
Available as [services.netbird](options.html#opt-services.netbird.enable).
|
||||
|
||||
- [persistent-evdev](https://github.com/aiberia/persistent-evdev), a daemon to add virtual proxy devices that mirror a physical input device but persist even if the underlying hardware is hot-plugged. Available as [services.persistent-evdev](#opt-services.persistent-evdev.enable).
|
||||
|
||||
- [schleuder](https://schleuder.org/), a mailing list manager with PGP support. Enable using [services.schleuder](#opt-services.schleuder.enable).
|
||||
|
|
|
@ -861,6 +861,7 @@
|
|||
./services/networking/nbd.nix
|
||||
./services/networking/ndppd.nix
|
||||
./services/networking/nebula.nix
|
||||
./services/networking/netbird.nix
|
||||
./services/networking/networkmanager.nix
|
||||
./services/networking/nextdns.nix
|
||||
./services/networking/nftables.nix
|
||||
|
|
64
nixos/modules/services/networking/netbird.nix
Normal file
64
nixos/modules/services/networking/netbird.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.netbird;
|
||||
kernel = config.boot.kernelPackages;
|
||||
interfaceName = "wt0";
|
||||
in {
|
||||
meta.maintainers = with maintainers; [ misuzu ];
|
||||
|
||||
options.services.netbird = {
|
||||
enable = mkEnableOption "Netbird daemon";
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.netbird;
|
||||
defaultText = literalExpression "pkgs.netbird";
|
||||
description = "The package to use for netbird";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
boot.extraModulePackages = optional (versionOlder kernel.kernel.version "5.6") kernel.wireguard;
|
||||
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
networking.dhcpcd.denyInterfaces = [ interfaceName ];
|
||||
|
||||
systemd.network.networks."50-netbird" = mkIf config.networking.useNetworkd {
|
||||
matchConfig = {
|
||||
Name = interfaceName;
|
||||
};
|
||||
linkConfig = {
|
||||
Unmanaged = true;
|
||||
ActivationPolicy = "manual";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.netbird = {
|
||||
description = "A WireGuard-based mesh network that connects your devices into a single private network";
|
||||
documentation = [ "https://netbird.io/docs/" ];
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
AmbientCapabilities = [ "CAP_NET_ADMIN" ];
|
||||
DynamicUser = true;
|
||||
Environment = [
|
||||
"NB_CONFIG=/var/lib/netbird/config.json"
|
||||
"NB_LOG_FILE=console"
|
||||
];
|
||||
ExecStart = "${cfg.package}/bin/netbird service run";
|
||||
Restart = "always";
|
||||
RuntimeDirectory = "netbird";
|
||||
StateDirectory = "netbird";
|
||||
WorkingDirectory = "/var/lib/netbird";
|
||||
};
|
||||
unitConfig = {
|
||||
StartLimitInterval = 5;
|
||||
StartLimitBurst = 10;
|
||||
};
|
||||
stopIfChanged = false;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -358,6 +358,7 @@ in {
|
|||
ncdns = handleTest ./ncdns.nix {};
|
||||
ndppd = handleTest ./ndppd.nix {};
|
||||
nebula = handleTest ./nebula.nix {};
|
||||
netbird = handleTest ./netbird.nix {};
|
||||
neo4j = handleTest ./neo4j.nix {};
|
||||
netdata = handleTest ./netdata.nix {};
|
||||
networking.networkd = handleTest ./networking.nix { networkd = true; };
|
||||
|
|
21
nixos/tests/netbird.nix
Normal file
21
nixos/tests/netbird.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||
{
|
||||
name = "netbird";
|
||||
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [ misuzu ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
node = { ... }: {
|
||||
services.netbird.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
node.wait_for_unit("netbird.service")
|
||||
node.wait_for_file("/var/run/netbird/sock")
|
||||
node.succeed("netbird status | grep -q 'Daemon status: NeedsLogin'")
|
||||
'';
|
||||
})
|
91
pkgs/tools/networking/netbird/default.nix
Normal file
91
pkgs/tools/networking/netbird/default.nix
Normal file
|
@ -0,0 +1,91 @@
|
|||
{ stdenv, lib, nixosTests, buildGoModule, fetchFromGitHub, installShellFiles
|
||||
, pkg-config
|
||||
, libayatana-appindicator, libX11, libXcursor, libXxf86vm
|
||||
, Cocoa, IOKit, Kernel, UserNotifications, WebKit
|
||||
, ui ? false }:
|
||||
let
|
||||
modules = if ui then {
|
||||
"client/ui" = "netbird-ui";
|
||||
} else {
|
||||
client = "netbird";
|
||||
management = "netbird-mgmt";
|
||||
signal = "netbird-signal";
|
||||
};
|
||||
in
|
||||
buildGoModule rec {
|
||||
pname = "netbird";
|
||||
version = "0.8.9";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "netbirdio";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-bQrfYbzYd6T9PD2lLuldp1pGoZKpU71bO1D1SXcoZ7M=";
|
||||
};
|
||||
|
||||
vendorSha256 = "sha256-KtRQwrCBsOX7Jk9mKdDNOD7zfssADfBXCO1RPZbp5Aw=";
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ] ++ lib.optional ui pkg-config;
|
||||
|
||||
buildInputs = lib.optionals (stdenv.isLinux && ui) [
|
||||
libayatana-appindicator
|
||||
libX11
|
||||
libXcursor
|
||||
libXxf86vm
|
||||
] ++ lib.optionals (stdenv.isDarwin && ui) [
|
||||
Cocoa
|
||||
IOKit
|
||||
Kernel
|
||||
UserNotifications
|
||||
WebKit
|
||||
];
|
||||
|
||||
subPackages = lib.attrNames modules;
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X github.com/netbirdio/netbird/client/system.version=${version}"
|
||||
"-X main.builtBy=nix"
|
||||
];
|
||||
|
||||
# needs network access
|
||||
doCheck = false;
|
||||
|
||||
postPatch = ''
|
||||
# make it compatible with systemd's RuntimeDirectory
|
||||
substituteInPlace client/cmd/root.go \
|
||||
--replace 'unix:///var/run/netbird.sock' 'unix:///var/run/netbird/sock'
|
||||
substituteInPlace client/ui/client_ui.go \
|
||||
--replace 'unix:///var/run/netbird.sock' 'unix:///var/run/netbird/sock'
|
||||
'';
|
||||
|
||||
postInstall = lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||
(module: binary: ''
|
||||
mv $out/bin/${lib.last (lib.splitString "/" module)} $out/bin/${binary}
|
||||
'' + lib.optionalString (!ui) ''
|
||||
installShellCompletion --cmd ${binary} \
|
||||
--bash <($out/bin/${binary} completion bash) \
|
||||
--fish <($out/bin/${binary} completion fish) \
|
||||
--zsh <($out/bin/${binary} completion zsh)
|
||||
'')
|
||||
modules) + lib.optionalString (stdenv.isLinux && ui) ''
|
||||
mkdir -p $out/share/pixmaps
|
||||
cp $src/client/ui/disconnected.png $out/share/pixmaps/netbird.png
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
cp $src/client/ui/netbird.desktop $out/share/applications/netbird.desktop
|
||||
|
||||
substituteInPlace $out/share/applications/netbird.desktop \
|
||||
--replace "Exec=/usr/bin/netbird-ui" "Exec=$out/bin/netbird-ui"
|
||||
'';
|
||||
|
||||
passthru.tests.netbird = nixosTests.netbird;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://netbird.io";
|
||||
description = "Connect your devices into a single secure private WireGuard®-based mesh network with SSO/MFA and simple access controls";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ misuzu ];
|
||||
};
|
||||
}
|
|
@ -5150,6 +5150,14 @@ with pkgs;
|
|||
inherit (xorg) libXaw;
|
||||
};
|
||||
|
||||
netbird = callPackage ../tools/networking/netbird {
|
||||
inherit (darwin.apple_sdk_11_0.frameworks) Cocoa IOKit Kernel UserNotifications WebKit;
|
||||
};
|
||||
|
||||
netbird-ui = netbird.override {
|
||||
ui = true;
|
||||
};
|
||||
|
||||
netevent = callPackage ../tools/inputmethods/netevent { };
|
||||
|
||||
netplan = callPackage ../tools/admin/netplan { };
|
||||
|
|
Loading…
Reference in a new issue