2023-04-29 16:46:19 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, nixosTests
|
|
|
|
, nix-update-script
|
2024-09-26 11:04:55 +00:00
|
|
|
, buildGoModule
|
2023-04-29 16:46:19 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
2022-09-09 14:08:57 +00:00
|
|
|
, pkg-config
|
2023-04-29 16:46:19 +00:00
|
|
|
, gtk3
|
|
|
|
, libayatana-appindicator
|
|
|
|
, libX11
|
|
|
|
, libXcursor
|
|
|
|
, libXxf86vm
|
|
|
|
, Cocoa
|
|
|
|
, IOKit
|
|
|
|
, Kernel
|
|
|
|
, UserNotifications
|
|
|
|
, WebKit
|
|
|
|
, ui ? false
|
2024-01-02 11:29:13 +00:00
|
|
|
, netbird-ui
|
2023-04-29 16:46:19 +00:00
|
|
|
}:
|
2022-09-09 14:08:57 +00:00
|
|
|
let
|
2023-04-29 16:46:19 +00:00
|
|
|
modules =
|
|
|
|
if ui then {
|
|
|
|
"client/ui" = "netbird-ui";
|
|
|
|
} else {
|
|
|
|
client = "netbird";
|
|
|
|
management = "netbird-mgmt";
|
|
|
|
signal = "netbird-signal";
|
|
|
|
};
|
2022-09-09 14:08:57 +00:00
|
|
|
in
|
2024-09-26 11:04:55 +00:00
|
|
|
buildGoModule rec {
|
2022-09-09 14:08:57 +00:00
|
|
|
pname = "netbird";
|
2024-10-23 06:41:50 +00:00
|
|
|
version = "0.30.2";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "netbirdio";
|
2024-09-19 14:19:46 +00:00
|
|
|
repo = "netbird";
|
2022-09-09 14:08:57 +00:00
|
|
|
rev = "v${version}";
|
2024-10-23 06:41:50 +00:00
|
|
|
hash = "sha256-8PIReuWnD7iMesSWAo6E4J+mWNAa7lHKwBWsCsXUG+E=";
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
2024-10-23 06:41:50 +00:00
|
|
|
vendorHash = "sha256-KScynPcMZ90XZy/N5X3aQfKuVl/JOCJmd8luNxChkZk=";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ] ++ lib.optional ui pkg-config;
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
buildInputs = lib.optionals (stdenv.hostPlatform.isLinux && ui) [
|
2022-10-21 18:38:19 +00:00
|
|
|
gtk3
|
2022-09-09 14:08:57 +00:00
|
|
|
libayatana-appindicator
|
|
|
|
libX11
|
|
|
|
libXcursor
|
|
|
|
libXxf86vm
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && ui) [
|
2022-09-09 14:08:57 +00:00
|
|
|
Cocoa
|
|
|
|
IOKit
|
|
|
|
Kernel
|
|
|
|
UserNotifications
|
|
|
|
WebKit
|
|
|
|
];
|
|
|
|
|
|
|
|
subPackages = lib.attrNames modules;
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2023-04-29 16:46:19 +00:00
|
|
|
"-X github.com/netbirdio/netbird/version.version=${version}"
|
2022-09-09 14:08:57 +00:00
|
|
|
"-X main.builtBy=nix"
|
|
|
|
];
|
|
|
|
|
|
|
|
# needs network access
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# make it compatible with systemd's RuntimeDirectory
|
|
|
|
substituteInPlace client/cmd/root.go \
|
2024-02-29 20:09:43 +00:00
|
|
|
--replace-fail 'unix:///var/run/netbird.sock' 'unix:///var/run/netbird/sock'
|
2022-09-09 14:08:57 +00:00
|
|
|
substituteInPlace client/ui/client_ui.go \
|
2024-02-29 20:09:43 +00:00
|
|
|
--replace-fail 'unix:///var/run/netbird.sock' 'unix:///var/run/netbird/sock'
|
2022-09-09 14:08:57 +00:00
|
|
|
'';
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
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)
|
|
|
|
'')
|
2024-09-26 11:04:55 +00:00
|
|
|
modules) + lib.optionalString (stdenv.hostPlatform.isLinux && ui) ''
|
2023-04-29 16:46:19 +00:00
|
|
|
mkdir -p $out/share/pixmaps
|
2024-02-29 20:09:43 +00:00
|
|
|
cp $src/client/ui/netbird-systemtray-connected.png $out/share/pixmaps/netbird.png
|
2022-09-09 14:08:57 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
mkdir -p $out/share/applications
|
|
|
|
cp $src/client/ui/netbird.desktop $out/share/applications/netbird.desktop
|
2022-09-09 14:08:57 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
substituteInPlace $out/share/applications/netbird.desktop \
|
2024-02-29 20:09:43 +00:00
|
|
|
--replace-fail "Exec=/usr/bin/netbird-ui" "Exec=$out/bin/netbird-ui"
|
2023-04-29 16:46:19 +00:00
|
|
|
'';
|
2022-09-09 14:08:57 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
passthru = {
|
|
|
|
tests.netbird = nixosTests.netbird;
|
2024-01-02 11:29:13 +00:00
|
|
|
tests.netbird-ui = netbird-ui;
|
2023-04-29 16:46:19 +00:00
|
|
|
updateScript = nix-update-script { };
|
|
|
|
};
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
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;
|
2024-09-19 14:19:46 +00:00
|
|
|
maintainers = with maintainers; [ vrifox saturn745 ];
|
2024-02-07 01:22:34 +00:00
|
|
|
mainProgram = "netbird";
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
}
|