diff options
author | Rob Vermaas <rob.vermaas@gmail.com> | 2014-08-06 17:00:54 +0200 |
---|---|---|
committer | Rob Vermaas <rob.vermaas@gmail.com> | 2014-08-06 17:00:54 +0200 |
commit | 34e6cb5083e2752215d9f6819ddb99cc0b3d6b15 (patch) | |
tree | cd678fe8f4f4f92e692e2a788007ebf51329f233 | |
parent | b2f601234e02970904c425cf4b05551843e1c8c4 (diff) | |
parent | 377454ff0ef8f2e643f37edb953760e0dc1503f4 (diff) | |
download | nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar.gz nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar.bz2 nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar.lz nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar.xz nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.tar.zst nixpkgs-34e6cb5083e2752215d9f6819ddb99cc0b3d6b15.zip |
Merge pull request #3476 from wkennington/master.unifi
Add support for the unifi access point controller
-rw-r--r-- | lib/maintainers.nix | 1 | ||||
-rw-r--r-- | nixos/modules/misc/ids.nix | 1 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/networking/unifi.nix | 88 | ||||
-rw-r--r-- | pkgs/servers/unifi/default.nix | 32 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
6 files changed, 125 insertions, 0 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix index a4386b067b5..9c81ef6a37e 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -108,6 +108,7 @@ winden = "Antonio Vargas Gonzalez <windenntw@gmail.com>"; wizeman = "Ricardo M. Correia <rcorreia@wizy.org>"; wjlroe = "William Roe <willroe@gmail.com>"; + wkennington = "William A. Kennington III <william@wkennington.com>"; wmertens = "Wout Mertens <Wout.Mertens@gmail.com>"; z77z = "Marco Maggesi <maggesi@math.unifi.it>"; zef = "Zef Hemel <zef@zef.me>"; diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 4ba81dadb31..853efcc09dc 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -138,6 +138,7 @@ znc = 128; polipo = 129; mopidy = 130; + unifi = 131; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 2cbda50ba29..ea647b43c9d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -233,6 +233,7 @@ ./services/networking/teamspeak3.nix ./services/networking/tftpd.nix ./services/networking/unbound.nix + ./services/networking/unifi.nix ./services/networking/vsftpd.nix ./services/networking/wakeonlan.nix ./services/networking/websockify.nix diff --git a/nixos/modules/services/networking/unifi.nix b/nixos/modules/services/networking/unifi.nix new file mode 100644 index 00000000000..634f760328f --- /dev/null +++ b/nixos/modules/services/networking/unifi.nix @@ -0,0 +1,88 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.unifi; + stateDir = "/var/lib/unifi"; + cmd = "@${pkgs.icedtea7_jre}/bin/java java -jar ${stateDir}/lib/ace.jar"; +in +{ + + options = { + + services.unifi.enable = mkOption { + type = types.uniq types.bool; + default = false; + description = '' + Whether or not to enable the unifi controller service. + ''; + }; + + }; + + config = mkIf cfg.enable { + + users.extraUsers.unifi = { + uid = config.ids.uids.unifi; + description = "UniFi controller daemon user"; + home = "${stateDir}"; + }; + + # We must create the binary directories as bind mounts instead of symlinks + # This is because the controller resolves all symlinks to absolute paths + # to be used as the working directory. + systemd.mounts = map ({ what, where }: { + bindsTo = [ "unifi.service" ]; + requiredBy = [ "unifi.service" ]; + before = [ "unifi.service" ]; + options = "bind"; + what = what; + where = where; + }) [ + { + what = "${pkgs.unifi}/dl"; + where = "${stateDir}/dl"; + } + { + what = "${pkgs.unifi}/lib"; + where = "${stateDir}/lib"; + } + { + what = "${pkgs.mongodb}/bin"; + where = "${stateDir}/bin"; + } + ]; + + systemd.services.unifi = { + description = "UniFi controller daemon"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + preStart = '' + # Ensure privacy of state + chown unifi "${stateDir}" + chmod 0700 "${stateDir}" + + # Create the volatile webapps + mkdir -p "${stateDir}/webapps" + chown unifi "${stateDir}/webapps" + ln -s "${pkgs.unifi}/webapps/ROOT.war" "${stateDir}/webapps/ROOT.war" + ''; + + postStop = '' + rm "${stateDir}/webapps/ROOT.war" + ''; + + serviceConfig = { + Type = "simple"; + ExecStart = "${cmd} start"; + ExecStop = "${cmd} stop"; + User = "unifi"; + PermissionsStartOnly = true; + UMask = "0077"; + WorkingDirectory = "${stateDir}"; + }; + }; + + }; + +} diff --git a/pkgs/servers/unifi/default.nix b/pkgs/servers/unifi/default.nix new file mode 100644 index 00000000000..8aa15ee9f82 --- /dev/null +++ b/pkgs/servers/unifi/default.nix @@ -0,0 +1,32 @@ +{ stdenv, fetchurl, unzip }: + +stdenv.mkDerivation rec { + name = "unifi-controller-${version}"; + version = "3.2.1"; + + src = fetchurl { + url = "http://dl.ubnt.com/unifi/${version}/UniFi.unix.zip"; + sha256 = "0x7s5k9wxkw0rcs4c2mdrmmjpcfmbh5pvvpj8brrwnkgx072n53c"; + }; + + buildInputs = [ unzip ]; + + doConfigure = false; + + buildPhase = '' + rm -rf bin conf readme.txt + ''; + + installPhase = '' + mkdir -p $out + cp -ar * $out + ''; + + meta = with stdenv.lib; { + homepage = http://www.ubnt.com/; + description = "Controller for Ubiquiti UniFi accesspoints"; + license = licenses.unfree; + platforms = platforms.unix; + maintainers = with maintainers; [ wkennington ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0489a953966..e05f8f52362 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7017,6 +7017,8 @@ let axis2 = callPackage ../servers/http/tomcat/axis2 { }; + unifi = callPackage ../servers/unifi { }; + virtuoso6 = callPackage ../servers/sql/virtuoso/6.x.nix { }; virtuoso7 = callPackage ../servers/sql/virtuoso/7.x.nix { }; |