git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #14297 from elitak/mfi

mfi: init at 2.1.11

commitb9ba6e2f6bd0b8ec555cfb4d5019a6fb873f1bb6 authorjoachifm <joachifm@users.noreply.github.com> dateFri 1 Apr 2016, 14:57 (11 years ago) parente4874ac0de2d2f
8 files changed+229
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/networking/mfi.nix+90 pkgs/development/libraries/v8/3.14.nix+28 pkgs/development/libraries/v8/fix-GetLocalizedMessage-usage.patch+27 pkgs/servers/mfi/default.nix+28 pkgs/servers/nosql/mongodb/2.4.8.nix+45 pkgs/top-level/all-packages.nix+8
nixos/modules/misc/ids.nix+2
@@ -258,6 +258,7 @@
258258 hydra-queue-runner = 235;
259259 hydra-www = 236;
260260 syncthing = 237;
261+ mfi = 238;
261262
262263 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
263264
@@ -487,6 +488,7 @@
487488 octoprint = 230;
488489 radicale = 234;
489490 syncthing = 237;
491+ #mfi = 238; # unused
490492
491493 # When adding a gid, make sure it doesn't match an existing
492494 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -334,6 +334,7 @@
334334 ./services/networking/lambdabot.nix
335335 ./services/networking/libreswan.nix
336336 ./services/networking/mailpile.nix
337+ ./services/networking/mfi.nix
337338 ./services/networking/mjpg-streamer.nix
338339 ./services/networking/minidlna.nix
339340 ./services/networking/miniupnpd.nix
nixos/modules/services/networking/mfi.nixnew file+90
@@ -0,0 +1,90 @@
1+{ config, lib, pkgs, utils, ... }:
2+with lib;
3+let
4+ name = "Ubiquiti mFi Controller";
5+ cfg = config.services.mfi;
6+ stateDir = "/var/lib/mfi";
7+ # XXX 2 runtime exceptions using jre8: JSPException on GET / ; can't initialize ./data/keystore on first run.
8+ cmd = "@${pkgs.jre7}/bin/java java -jar ${stateDir}/lib/ace.jar";
9+ mountPoints = [
10+ { what = "${pkgs.mfi}/dl"; where = "${stateDir}/dl"; }
11+ { what = "${pkgs.mfi}/lib"; where = "${stateDir}/lib"; }
12+ { what = "${pkgs.mongodb248}/bin"; where = "${stateDir}/bin"; }
13+ ];
14+ systemdMountPoints = map (m: "${utils.escapeSystemdPath m.where}.mount") mountPoints;
15+ ports = [ 6080 6880 6443 6843 ];
16+in
17+{
18+ options = {
19+ services.mfi = {
20+ enable = mkEnableOption name;
21+ openPorts = mkOption {
22+ type = types.bool;
23+ default = true;
24+ description = "Whether to open TCP ports ${concatMapStrings (a: "${toString a} ") ports}for the services.";
25+ };
26+ };
27+ };
28+
29+ config = mkIf cfg.enable {
30+
31+ networking.firewall.allowedTCPPorts = mkIf config.services.mfi.openPorts ports;
32+
33+ users.users.mfi = {
34+ uid = config.ids.uids.mfi;
35+ description = "mFi controller daemon user";
36+ home = "${stateDir}";
37+ };
38+
39+ # We must create the binary directories as bind mounts instead of symlinks
40+ # This is because the controller resolves all symlinks to absolute paths
41+ # to be used as the working directory.
42+ systemd.mounts = map ({ what, where }: {
43+ bindsTo = [ "mfi.service" ];
44+ partOf = [ "mfi.service" ];
45+ unitConfig.RequiresMountsFor = stateDir;
46+ options = "bind";
47+ what = what;
48+ where = where;
49+ }) mountPoints;
50+
51+ systemd.services.mfi = {
52+ description = "mFi controller daemon";
53+ wantedBy = [ "multi-user.target" ];
54+ after = [ "network.target" ] ++ systemdMountPoints;
55+ partOf = systemdMountPoints;
56+ bindsTo = systemdMountPoints;
57+ unitConfig.RequiresMountsFor = stateDir;
58+
59+ preStart = ''
60+ # Clear ./webapps each run.
61+ rm -rf "${stateDir}/webapps"
62+ mkdir -p "${stateDir}/webapps"
63+ ln -s "${pkgs.mfi}/webapps/ROOT.war" "${stateDir}/webapps"
64+
65+ # Copy initial config only once.
66+ test -e "${stateDir}/conf" || cp -ar "${pkgs.mfi}/conf" "${stateDir}/conf"
67+ test -e "${stateDir}/data" || cp -ar "${pkgs.mfi}/data" "${stateDir}/data"
68+
69+ # Fix Permissions.
70+ # (Bind-mounts cause errors; ignore exit codes)
71+ chown -fR mfi: "${stateDir}" || true
72+ chmod -fR u=rwX,go= "${stateDir}" || true
73+ '';
74+
75+ postStop = ''
76+ rm -rf "${stateDir}/webapps"
77+ '';
78+
79+ serviceConfig = {
80+ Type = "simple";
81+ ExecStart = "${cmd} start";
82+ ExecStop = "${cmd} stop";
83+ User = "mfi";
84+ PermissionsStartOnly = true;
85+ UMask = "0077";
86+ WorkingDirectory = "${stateDir}";
87+ };
88+ };
89+ };
90+}
pkgs/development/libraries/v8/3.14.nixnew file+28
@@ -0,0 +1,28 @@
1+{ stdenv, callPackage, fetchFromGitHub, python, ... } @ args:
2+with stdenv.lib;
3+let
4+ version = "3.14.5.10";
5+ sha256 = "08vhl84166x13b3cbx8y0g99yqx772zd33gawsa1nxqkyrykql6k";
6+in
7+(callPackage ./generic.nix (args // {
8+ inherit version sha256;
9+})).overrideDerivation (oldAttrs:{
10+ patchPhase = [
11+ oldAttrs.patchPhase
12+ "sed -i 's,#!/usr/bin/python,#!${python}/bin/python,' build/gyp_v8"
13+ ];
14+
15+ # http://code.google.com/p/v8/issues/detail?id=2149
16+ NIX_CFLAGS_COMPILE = concatStringsSep " " [
17+ oldAttrs.NIX_CFLAGS_COMPILE
18+ "-Wno-unused-local-typedefs"
19+ "-Wno-aggressive-loop-optimizations"
20+ ];
21+
22+ src = fetchFromGitHub {
23+ owner = "v8";
24+ repo = "v8";
25+ rev = "${version}";
26+ inherit sha256;
27+ };
28+})
pkgs/development/libraries/v8/fix-GetLocalizedMessage-usage.patchnew file+27
@@ -0,0 +1,27 @@
1+From dbe142c4eda0f15fad9fa85743dd11b81292fa8f Mon Sep 17 00:00:00 2001
2+From: Timothy J Fontaine <tjfontaine@gmail.com>
3+Date: Thu, 23 May 2013 13:57:59 -0700
4+Subject: [PATCH] v8: fix GetLocalizedMessage usage
5+
6+As is the backport of the abort on uncaught exception wouldn't compile
7+because we it was passing in `this` when it was unnecessary.
8+---
9+ deps/v8/src/isolate.cc | 2 +-
10+ 1 file changed, 1 insertion(+), 1 deletion(-)
11+
12+diff --git a/src/isolate.cc b/src/isolate.cc
13+index 04a438b..5a5293e 100644
14+--- a/src/isolate.cc
15++++ b/src/isolate.cc
16+@@ -1161,7 +1161,7 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) {
17+ (report_exception || can_be_caught_externally)) {
18+ fatal_exception_depth++;
19+ fprintf(stderr, "%s\n\nFROM\n",
20+- *MessageHandler::GetLocalizedMessage(this, message_obj));
21++ *MessageHandler::GetLocalizedMessage(message_obj));
22+ PrintCurrentStackTrace(stderr);
23+ OS::Abort();
24+ }
25+--
26+1.8.1.6
27+
pkgs/servers/mfi/default.nixnew file+28
@@ -0,0 +1,28 @@
1+{ stdenv, fetchurl, unzip }:
2+
3+stdenv.mkDerivation rec {
4+ name = "mfi-controller-${version}";
5+ version = "2.1.11";
6+
7+ src = fetchurl {
8+ url = "https://dl.ubnt.com/mfi/${version}/mFi.unix.zip";
9+ sha256 = "0b9q6025zf9zjzq8dcmcyai8rslx67g52j41gacxsk9i5dspmw90";
10+ };
11+
12+ buildInputs = [ unzip ];
13+
14+ dontBuild = true;
15+
16+ installPhase = ''
17+ mkdir -p $out
18+ cp -ar conf data dl lib webapps $out
19+ '';
20+
21+ meta = with stdenv.lib; {
22+ homepage = http://www.ubnt.com/;
23+ description = "Controller for Ubiquiti mFi devices";
24+ license = licenses.unfree;
25+ platforms = platforms.unix;
26+ maintainers = with maintainers; [ elitak ];
27+ };
28+}
pkgs/servers/nosql/mongodb/2.4.8.nixnew file+45
@@ -0,0 +1,45 @@
1+# This derivation was resurrected from 4c8ec5e12e187347fd97b1a1a9a43eb19e009ed0
2+# by elitak for use with the Ubiquiti mFi Controller package, which breaks at
3+# runtime on mongodb3+ and jre8+. We will need to pull in sufficiently old
4+# versions of boost and v8 to build this, as well.
5+{ stdenv, fetchurl, scons, boost155, v8_3_14, gperftools, pcre, snappy }:
6+with stdenv.lib;
7+let
8+ version = "2.4.8";
9+in
10+stdenv.mkDerivation rec {
11+ name = "mongodb-${version}";
12+
13+ src = fetchurl {
14+ url = "http://downloads.mongodb.org/src/mongodb-src-r${version}.tar.gz";
15+ sha256 = "1p6gnharypglfp39halp72fig96fqjhakyy7m76a1prxwpjkqw7x";
16+ };
17+
18+ nativeBuildInputs = [ scons boost155 v8_3_14 gperftools pcre snappy ];
19+
20+ postPatch = ''
21+ substituteInPlace SConstruct \
22+ --replace "Environment( BUILD_DIR" "Environment( ENV = os.environ, BUILD_DIR" \
23+ --replace 'CCFLAGS=["-Werror", "-pipe"]' 'CCFLAGS=["-pipe"]'
24+ '';
25+
26+ NIX_CFLAGS_COMPILE = "-Wno-unused-local-typedefs";
27+
28+ buildPhase = ''
29+ export SCONSFLAGS="-j$NIX_BUILD_CORES"
30+ scons all --use-system-all
31+ '';
32+
33+ installPhase = ''
34+ mkdir -p $out/lib
35+ scons install --use-system-all --full --prefix=$out
36+ '';
37+
38+ meta = {
39+ description = "A scalable, high-performance, open source NoSQL database";
40+ homepage = http://www.mongodb.org;
41+ license = licenses.agpl3;
42+ maintainers = with maintainers; [ bluescreen303 elitak ];
43+ platforms = platforms.linux;
44+ };
45+}
pkgs/top-level/all-packages.nix+8
@@ -8909,6 +8909,10 @@ in
89098909 gnutls = gnutls;
89108910 });
89118911
8912+ v8_3_14 = callPackage ../development/libraries/v8/3.14.nix {
8913+ inherit (pythonPackages) gyp;
8914+ };
8915+
89128916 v8_3_16_14 = callPackage ../development/libraries/v8/3.16.14.nix {
89138917 inherit (pythonPackages) gyp;
89148918 # The build succeeds using gcc5 but it fails to build pkgs.consul-ui
@@ -9626,6 +9630,8 @@ in
96269630
96279631 meteor = callPackage ../servers/meteor/default.nix { };
96289632
9633+ mfi = callPackage ../servers/mfi { };
9634+
96299635 # Backwards compatibility.
96309636 mod_dnssd = pkgs.apacheHttpdPackages.mod_dnssd;
96319637 mod_evasive = pkgs.apacheHttpdPackages.mod_evasive;
@@ -9743,6 +9749,8 @@ in
97439749 sasl = cyrus_sasl;
97449750 };
97459751
9752+ mongodb248 = callPackage ../servers/nosql/mongodb/2.4.8.nix { };
9753+
97469754 riak = callPackage ../servers/nosql/riak/2.1.1.nix { };
97479755
97489756 influxdb = (callPackage ../servers/nosql/influxdb { }).bin // { outputs = [ "bin" ]; };