From 20b83a46d62422b7070035a32ae23cce408d4034 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Mon, 25 Sep 2023 04:19:12 +0700 Subject: [PATCH] netdata: disable installation of non-free v2 dashboard The v2 dashboard (included since version 1.41.0) is licensed under Netdata Cloud UI License v1.0, which is a non-free license. Patch the source code so that the v2 is not included in the source and the result derivation. Users that want the v2 dashboard can still request it by overriding this derivation and pass `withCloudUi = true`. Co-authored-by: Raito Bezarius Fixes: https://github.com/NixOS/nixpkgs/issues/256964 --- lib/licenses.nix | 8 ++++++++ pkgs/tools/system/netdata/default.nix | 25 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/licenses.nix b/lib/licenses.nix index 0fd641085374..dcc16edd90df 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -840,6 +840,14 @@ in mkLicense lset) ({ fullName = "University of Illinois/NCSA Open Source License"; }; + ncul1 = { + spdxId = "NCUL1"; + fullName = "Netdata Cloud UI License v1.0"; + free = false; + redistributable = true; # Only if used in Netdata products. + url = "https://raw.githubusercontent.com/netdata/netdata/master/web/gui/v2/LICENSE.md"; + }; + nlpl = { spdxId = "NLPL"; fullName = "No Limit Public License"; diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix index e3dbabe1f52e..f380bf4fd6f6 100644 --- a/pkgs/tools/system/netdata/default.nix +++ b/pkgs/tools/system/netdata/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, makeWrapper +{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkg-config, makeWrapper , CoreFoundation, IOKit, libossp_uuid , nixosTests , netdata-go-plugins @@ -9,6 +9,7 @@ , withIpmi ? (!stdenv.isDarwin), freeipmi , withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct , withCloud ? (!stdenv.isDarwin), json_c +, withCloudUi ? false , withConnPubSub ? false, google-cloud-cpp, grpc , withConnPrometheus ? false, snappy , withSsl ? true, openssl @@ -24,8 +25,17 @@ stdenv.mkDerivation rec { owner = "netdata"; repo = "netdata"; rev = "v${version}"; - hash = "sha256-8L8PhPgNIHvw+Dcx2D6OE8fp2+GEYOc9wEIoPJSqXME="; + hash = if withCloudUi + then "sha256-8L8PhPgNIHvw+Dcx2D6OE8fp2+GEYOc9wEIoPJSqXME=" + else "sha256-J/pKKxTNoSwvsyVaRsnazQQqu2C8zx1QEAkB+gkR5lU="; fetchSubmodules = true; + + # Remove v2 dashboard distributed under NCUL1. Make sure an empty + # Makefile.am exists, as autoreconf will get confused otherwise. + postFetch = lib.optionalString (!withCloudUi) '' + rm -rf $out/web/gui/v2/* + touch $out/web/gui/v2/Makefile.am + ''; }; strictDeps = true; @@ -53,6 +63,12 @@ stdenv.mkDerivation rec { # Avoid build-only inputs in closure leaked by configure command: # https://github.com/NixOS/nixpkgs/issues/175693#issuecomment-1143344162 ./skip-CONFIGURE_COMMAND.patch + + # Allow building without non-free v2 dashboard. + (fetchpatch { + url = "https://github.com/peat-psuwit/netdata/commit/6ccbdd1500db2b205923968688d5f1777430a326.patch"; + hash = "sha256-jAyk5HlxdjFn5IP6jOKP8/SXOraMQSA6r1krThe+s7g="; + }) ]; # Guard against unused buld-time development inputs in closure. Without @@ -98,6 +114,8 @@ stdenv.mkDerivation rec { "--disable-dbengine" ] ++ lib.optionals (!withCloud) [ "--disable-cloud" + ] ++ lib.optionals (!withCloudUi) [ + "--disable-cloud-ui" ]; postFixup = '' @@ -118,7 +136,8 @@ stdenv.mkDerivation rec { description = "Real-time performance monitoring tool"; homepage = "https://www.netdata.cloud/"; changelog = "https://github.com/netdata/netdata/releases/tag/v${version}"; - license = licenses.gpl3Plus; + license = [ licenses.gpl3Plus ] + ++ lib.optionals (withCloudUi) [ licenses.ncul1 ]; platforms = platforms.unix; maintainers = with maintainers; [ raitobezarius ]; };