2022-09-09 14:08:57 +00:00
|
|
|
{ stdenv, lib, nixosTests, buildGoModule, fetchFromGitHub, installShellFiles
|
|
|
|
, pkg-config
|
2022-10-21 18:38:19 +00:00
|
|
|
, gtk3, libayatana-appindicator, libX11, libXcursor, libXxf86vm
|
2022-09-09 14:08:57 +00:00
|
|
|
, 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";
|
2023-02-16 17:41:37 +00:00
|
|
|
version = "0.13.0";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "netbirdio";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-02-16 17:41:37 +00:00
|
|
|
sha256 = "sha256-Afj2pllGPL86hhSNDSbvO+GkA62CI8V5dnUa0mjEMCg=";
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
vendorHash = "sha256-3uEcb0nVHrfHZTZ/j/9l6zR1zMfLR0mVaN/Hydyam4Q=";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ] ++ lib.optional ui pkg-config;
|
|
|
|
|
|
|
|
buildInputs = lib.optionals (stdenv.isLinux && ui) [
|
2022-10-21 18:38:19 +00:00
|
|
|
gtk3
|
2022-09-09 14:08:57 +00:00
|
|
|
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";
|
|
|
|
changelog = "https://github.com/netbirdio/netbird/releases/tag/v${version}";
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|