summary refs log tree commit diff
path: root/pkgs/tools/system
diff options
context:
space:
mode:
authorTim Steinbach <NeQuissimus@users.noreply.github.com>2016-11-02 19:45:21 -0400
committerGitHub <noreply@github.com>2016-11-02 19:45:21 -0400
commit29f679d32e1f04e60ec6ef4becd032720980f4dc (patch)
tree96c16f4be7338f6d87258deedf157c8ec3eb1859 /pkgs/tools/system
parent04b22dd935ee3359adaef20186db50017dbe3975 (diff)
parent8ce23cfec212ed868f81a44871ed9cbd3225523a (diff)
downloadnixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar.gz
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar.bz2
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar.lz
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar.xz
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.tar.zst
nixlib-29f679d32e1f04e60ec6ef4becd032720980f4dc.zip
Merge pull request #19861 from womfoo/fix/netdata
netdata: allow execution without a config file
Diffstat (limited to 'pkgs/tools/system')
-rw-r--r--pkgs/tools/system/netdata/default.nix21
-rw-r--r--pkgs/tools/system/netdata/web_access.patch20
2 files changed, 36 insertions, 5 deletions
diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix
index 13c50fe3ec9e..46932076177f 100644
--- a/pkgs/tools/system/netdata/default.nix
+++ b/pkgs/tools/system/netdata/default.nix
@@ -13,11 +13,22 @@ stdenv.mkDerivation rec{
 
   buildInputs = [ autoreconfHook zlib pkgconfig libuuid ];
 
-  preConfigure = ''
-    export ZLIB_CFLAGS=" "
-    export ZLIB_LIBS="-lz"
-    export UUID_CFLAGS=" "
-    export UUID_LIBS="-luuid"
+  # Allow UI to load when running as non-root
+  patches = [ ./web_access.patch ];
+
+  # Build will fail trying to create /var/{cache,lib,log}/netdata without this
+  postPatch = ''
+   sed -i '/dist_.*_DATA = \.keep/d' src/Makefile.am
+  '';
+
+  configureFlags = [
+    "--localstatedir=/var"
+  ];
+
+  # App fails on runtime if the default config file is not detected
+  # The upstream installer does prepare an empty file too
+  postInstall = ''
+    touch $out/etc/netdata/netdata.conf
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/tools/system/netdata/web_access.patch b/pkgs/tools/system/netdata/web_access.patch
new file mode 100644
index 000000000000..f1e4bd64cbb5
--- /dev/null
+++ b/pkgs/tools/system/netdata/web_access.patch
@@ -0,0 +1,20 @@
+--- a/src/web_client.c.orig
++++ b/src/web_client.c
+@@ -331,7 +331,7 @@
+         buffer_sprintf(w->response.data, "File '%s' does not exist, or is not accessible.", webfilename);
+         return 404;
+     }
+-
++#if 0
+     // check if the file is owned by expected user
+     if(stat.st_uid != web_files_uid()) {
+         error("%llu: File '%s' is owned by user %u (expected user %u). Access Denied.", w->id, webfilename, stat.st_uid, web_files_uid());
+@@ -345,7 +345,7 @@
+         buffer_sprintf(w->response.data, "Access to file '%s' is not permitted.", webfilename);
+         return 403;
+     }
+-
++#endif
+     if((stat.st_mode & S_IFMT) == S_IFDIR) {
+         snprintfz(webfilename, FILENAME_MAX, "%s/index.html", filename);
+         return mysendfile(w, webfilename);