1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-23 06:01:15 +00:00

unifi, nixos/unifi: support LTS (5.6.36) and release (5.7.20)

Ubiquiti has both a LTS and current version of their Unifi controller software.

The latter adds new features, but may drop support for some devices.

This adds the capability to use either for the unifi module but defaults
to the LTS version, which was the previous behavior.
This commit is contained in:
Badi Abdul-Wahid 2018-03-25 16:49:54 -04:00 committed by Robin Gloster
parent 68d144b6ed
commit df3566c956
3 changed files with 55 additions and 11 deletions

View file

@ -4,22 +4,22 @@ let
cfg = config.services.unifi;
stateDir = "/var/lib/unifi";
cmd = ''
@${pkgs.jre}/bin/java java \
@${cfg.jrePackage}/bin/java java \
${optionalString (cfg.initialJavaHeapSize != null) "-Xms${(toString cfg.initialJavaHeapSize)}m"} \
${optionalString (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m"} \
-jar ${stateDir}/lib/ace.jar
'';
mountPoints = [
{
what = "${pkgs.unifi}/dl";
what = "${cfg.unifiPackage}/dl";
where = "${stateDir}/dl";
}
{
what = "${pkgs.unifi}/lib";
what = "${cfg.unifiPackage}/lib";
where = "${stateDir}/lib";
}
{
what = "${pkgs.mongodb}/bin";
what = "${cfg.mongodbPackage}/bin";
where = "${stateDir}/bin";
}
{
@ -41,6 +41,33 @@ in
'';
};
services.unifi.jrePackage = mkOption {
type = types.package;
default = pkgs.jre8;
defaultText = "pkgs.jre8";
description = ''
The JRE package to use. Check the release notes to ensure it is supported.
'';
};
services.unifi.unifiPackage = mkOption {
type = types.package;
default = pkgs.unifiLTS;
defaultText = "pkgs.unifiLTS";
description = ''
The unifi package to use.
'';
};
services.unifi.mongodbPackage = mkOption {
type = types.package;
default = pkgs.mongodb;
defaultText = "pkgs.mongodb";
description = ''
The mongodb package to use.
'';
};
services.unifi.dataDir = mkOption {
type = types.str;
default = "${stateDir}/data";
@ -137,7 +164,7 @@ in
rm -rf "${stateDir}/webapps"
mkdir -p "${stateDir}/webapps"
chown unifi "${stateDir}/webapps"
ln -s "${pkgs.unifi}/webapps/ROOT" "${stateDir}/webapps/ROOT"
ln -s "${cfg.unifiPackage}/webapps/ROOT" "${stateDir}/webapps/ROOT"
'';
postStop = ''

View file

@ -2,21 +2,37 @@
, dpkg
, fetchurl
, unzip
, useLTS ? false
}:
stdenv.mkDerivation rec {
name = "unifi-controller-${version}";
version = "5.6.36";
src = fetchurl {
let
versions = {
stable = {
version = "5.7.20";
sha256 = "1ylj4i5mcv6z9n32275ccdf1rqk74zilqsih3r6xzhm30pxrd8dd";
};
lts = {
version = "5.6.36";
sha256 = "075q7vm56fdsjwh72y2cb1pirl2pxdkvqnhvd3bf1c2n64mvp6bi";
};
};
selectedVersion =
let attr = if useLTS then "lts" else "stable";
in versions."${attr}";
in
stdenv.mkDerivation {
name = "unifi-controller-${selectedVersion.version}";
src = with selectedVersion; fetchurl {
url = "https://dl.ubnt.com/unifi/${version}/unifi_sysvinit_all.deb";
sha256 = "075q7vm56fdsjwh72y2cb1pirl2pxdkvqnhvd3bf1c2n64mvp6bi";
inherit sha256;
};
buildInputs = [ dpkg ];
unpackPhase = ''
dpkg-deb -x ${src} ./
dpkg-deb -x $src ./
'';
doConfigure = false;

View file

@ -12909,6 +12909,7 @@ with pkgs;
axis2 = callPackage ../servers/http/tomcat/axis2 { };
unifi = callPackage ../servers/unifi { };
unifiLTS = callPackage ../servers/unifi { useLTS=true; };
virtuoso6 = callPackage ../servers/sql/virtuoso/6.x.nix { };