1212 libX11 ,
1313 libXcursor ,
1414 libXxf86vm ,
15- ui ? false ,
1615 netbird-ui ,
1716 versionCheckHook ,
17+ componentName ? "client" ,
1818} :
1919let
20- modules =
21- if ui then
22- {
23- "client/ui" = "netbird-ui" ;
24- }
25- else
26- {
27- client = "netbird" ;
28- management = "netbird-mgmt" ;
29- signal = "netbird-signal" ;
30- } ;
20+ /*
21+ License tagging is based off:
22+ - https://github.com/netbirdio/netbird/blob/9e95841252c62b50ae93805c8dfd2b749ac95ea7/LICENSES/REUSE.toml
23+ - https://github.com/netbirdio/netbird/blob/9e95841252c62b50ae93805c8dfd2b749ac95ea7/LICENSE#L1-L2
24+ */
25+ availableComponents = {
26+ client = {
27+ module = "client" ;
28+ binaryName = "netbird" ;
29+ license = lib . licenses . bsd3 ;
30+ versionCheckProgramArg = "version" ;
31+ hasCompletion = true ;
32+ } ;
33+ ui = {
34+ module = "client/ui" ;
35+ binaryName = "netbird-ui" ;
36+ license = lib . licenses . bsd3 ;
37+ } ;
38+ upload = {
39+ module = "upload-server" ;
40+ binaryName = "netbird-upload" ;
41+ license = lib . licenses . bsd3 ;
42+ } ;
43+ management = {
44+ module = "management" ;
45+ binaryName = "netbird-mgmt" ;
46+ license = lib . licenses . agpl3Only ;
47+ versionCheckProgramArg = "--version" ;
48+ hasCompletion = true ;
49+ } ;
50+ signal = {
51+ module = "signal" ;
52+ binaryName = "netbird-signal" ;
53+ license = lib . licenses . agpl3Only ;
54+ hasCompletion = true ;
55+ } ;
56+ relay = {
57+ module = "relay" ;
58+ binaryName = "netbird-relay" ;
59+ license = lib . licenses . agpl3Only ;
60+ } ;
61+ } ;
62+ isUI = componentName == "ui" ;
63+ component = availableComponents . ${ componentName } ;
3164in
3265buildGoModule ( finalAttrs : {
33- pname = "netbird" ;
34- version = "0.49 .0" ;
66+ pname = "netbird- ${ componentName } " ;
67+ version = "0.54 .0" ;
3568
3669 src = fetchFromGitHub {
3770 owner = "netbirdio" ;
3871 repo = "netbird" ;
3972 tag = "v${ finalAttrs . version } " ;
40- hash = "sha256-Hv0A9/NTMzRAf9YvYGvRLyy2gdigF9y2NfylE8bLcTw =" ;
73+ hash = "sha256-qKYJa7q7scEbbxLHaosaurrjXR5ABxCAnuUcy80yKEc =" ;
4174 } ;
4275
43- vendorHash = "sha256-t/X/muMwHVwg8Or+pFTSEQEsnkKLuApoVUmMhyCImWI =" ;
76+ vendorHash = "sha256-uVVm+iDGP2eZ5GVXWJrWZQ7LpHdZccRIiHPIFs6oAPo =" ;
4477
45- nativeBuildInputs = [ installShellFiles ] ++ lib . optional ui pkg-config ;
78+ nativeBuildInputs = [ installShellFiles ] ++ lib . optional isUI pkg-config ;
4679
47- buildInputs = lib . optionals ( stdenv . hostPlatform . isLinux && ui ) [
80+ buildInputs = lib . optionals ( stdenv . hostPlatform . isLinux && isUI ) [
4881 gtk3
4982 libayatana-appindicator
5083 libX11
5184 libXcursor
5285 libXxf86vm
5386 ] ;
5487
55- subPackages = lib . attrNames modules ;
88+ subPackages = [ component . module ] ;
5689
5790 ldflags = [
5891 "-s"
@@ -73,35 +106,36 @@ buildGoModule (finalAttrs: {
73106 '' ;
74107
75108 postInstall =
76- lib . concatStringsSep "\n " (
77- lib . mapAttrsToList (
78- module : binary :
79- ''
80- mv $out/bin/${ lib . last ( lib . splitString "/" module ) } $out/bin/${ binary }
109+ let
110+ builtBinaryName = lib . last ( lib . splitString "/" component . module ) ;
111+ in
112+ ''
113+ mv $out/bin/${ builtBinaryName } $out/bin/${ component . binaryName }
114+ ''
115+ +
116+ lib . optionalString
117+ ( stdenv . buildPlatform . canExecute stdenv . hostPlatform && ( component . hasCompletion or false ) )
81118 ''
82- + lib . optionalString ( stdenv . buildPlatform . canExecute stdenv . hostPlatform && ! ui ) ''
83- installShellCompletion --cmd ${ binary } \
84- --bash <($out/bin/${ binary } completion bash) \
85- --fish <($out/bin/${ binary } completion fish) \
86- --zsh <($out/bin/${ binary } completion zsh)
119+ installShellCompletion --cmd ${ component . binaryName } \
120+ --bash <($out/bin/${ component . binaryName } completion bash) \
121+ --fish <($out/bin/${ component . binaryName } completion fish) \
122+ --zsh <($out/bin/${ component . binaryName } completion zsh)
87123 ''
88- ) modules
89- )
90- + lib . optionalString ( stdenv . hostPlatform . isLinux && ui ) ''
124+ # assemble & adjust netbird.desktop files for the GUI
125+ + lib . optionalString ( stdenv . hostPlatform . isLinux && isUI ) ''
91126 install -Dm644 "$src/client/ui/assets/netbird-systemtray-connected.png" "$out/share/pixmaps/netbird.png"
92127 install -Dm644 "$src/client/ui/build/netbird.desktop" "$out/share/applications/netbird.desktop"
93128
94129 substituteInPlace $out/share/applications/netbird.desktop \
95- --replace-fail "Exec=/usr/bin/netbird-ui" "Exec=$out/bin/netbird-ui "
130+ --replace-fail "Exec=/usr/bin/netbird-ui" "Exec=$out/bin/${ component . binaryName } "
96131 '' ;
97132
98133 nativeInstallCheckInputs = [
99134 versionCheckHook
100135 ] ;
101- versionCheckProgram = "${ placeholder "out" } /bin/${ finalAttrs . meta . mainProgram } " ;
102- versionCheckProgramArg = "version" ;
103- # Disabled for the `netbird-ui` version because it does a network request.
104- doInstallCheck = ! ui ;
136+ versionCheckProgram = "${ placeholder "out" } /bin/${ component . binaryName } " ;
137+ versionCheckProgramArg = component . versionCheckProgramArg or "version" ;
138+ doInstallCheck = component ? versionCheckProgramArg ;
105139
106140 passthru = {
107141 tests = {
@@ -115,11 +149,12 @@ buildGoModule (finalAttrs: {
115149 homepage = "https://netbird.io" ;
116150 changelog = "https://github.com/netbirdio/netbird/releases/tag/v${ finalAttrs . version } " ;
117151 description = "Connect your devices into a single secure private WireGuard®-based mesh network with SSO/MFA and simple access controls" ;
118- license = lib . licenses . bsd3 ;
152+ license = component . license ;
119153 maintainers = with lib . maintainers ; [
154+ nazarewk
120155 saturn745
121156 loc
122157 ] ;
123- mainProgram = if ui then "netbird-ui" else "netbird" ;
158+ mainProgram = component . binaryName ;
124159 } ;
125160} )
0 commit comments