nixpkgs/pkgs/tools/networking/netbird/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
2.9 KiB
Nix
Raw Normal View History

2023-04-20 10:33:04 +00:00
{ stdenv
, lib
, nixosTests
, nix-update-script
2023-04-20 10:33:04 +00:00
, buildGoModule
, fetchFromGitHub
, installShellFiles
2022-08-14 14:37:41 +00:00
, pkg-config
2023-04-20 10:33:04 +00:00
, gtk3
, libayatana-appindicator
, libX11
, libXcursor
, libXxf86vm
, Cocoa
, IOKit
, Kernel
, UserNotifications
, WebKit
, ui ? false
}:
2022-08-14 14:37:41 +00:00
let
2023-04-20 10:33:04 +00:00
modules =
if ui then {
"client/ui" = "netbird-ui";
} else {
client = "netbird";
management = "netbird-mgmt";
signal = "netbird-signal";
};
2022-08-14 14:37:41 +00:00
in
buildGoModule rec {
pname = "netbird";
2023-09-30 21:08:55 +00:00
version = "0.23.6";
2022-08-14 14:37:41 +00:00
src = fetchFromGitHub {
owner = "netbirdio";
repo = pname;
rev = "v${version}";
2023-09-30 21:08:55 +00:00
sha256 = "sha256-foyHV3+8fh7q3jCQqHAznlVLmBTwIiLyxVJraoJ5+P4=";
2022-08-14 14:37:41 +00:00
};
2023-08-13 22:10:16 +00:00
vendorHash = "sha256-CwozOBAPFSsa1XzDOHBgmFSwGiNekWT8t7KGR2KOOX4=";
2022-08-14 14:37:41 +00:00
nativeBuildInputs = [ installShellFiles ] ++ lib.optional ui pkg-config;
buildInputs = lib.optionals (stdenv.isLinux && ui) [
gtk3
2022-08-14 14:37:41 +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/version.version=${version}"
2022-08-14 14:37:41 +00:00
"-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'
'';
2023-04-20 10:33:04 +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)
'')
modules) + lib.optionalString (stdenv.isLinux && ui) ''
mkdir -p $out/share/pixmaps
cp $src/client/ui/disconnected.png $out/share/pixmaps/netbird.png
2022-08-14 14:37:41 +00:00
2023-04-20 10:33:04 +00:00
mkdir -p $out/share/applications
cp $src/client/ui/netbird.desktop $out/share/applications/netbird.desktop
2022-08-14 14:37:41 +00:00
2023-04-20 10:33:04 +00:00
substituteInPlace $out/share/applications/netbird.desktop \
--replace "Exec=/usr/bin/netbird-ui" "Exec=$out/bin/netbird-ui"
'';
2022-08-14 14:37:41 +00:00
passthru = {
tests.netbird = nixosTests.netbird;
updateScript = nix-update-script { };
};
2022-08-14 16:59:15 +00:00
2022-08-14 14:37:41 +00:00
meta = with lib; {
homepage = "https://netbird.io";
2022-09-02 16:31:22 +00:00
changelog = "https://github.com/netbirdio/netbird/releases/tag/v${version}";
2022-08-14 14:37:41 +00:00
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 ];
};
}