mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
Merge pull request #3476 from wkennington/master.unifi
Add support for the unifi access point controller
This commit is contained in:
commit
34e6cb5083
@ -108,6 +108,7 @@
|
|||||||
winden = "Antonio Vargas Gonzalez <windenntw@gmail.com>";
|
winden = "Antonio Vargas Gonzalez <windenntw@gmail.com>";
|
||||||
wizeman = "Ricardo M. Correia <rcorreia@wizy.org>";
|
wizeman = "Ricardo M. Correia <rcorreia@wizy.org>";
|
||||||
wjlroe = "William Roe <willroe@gmail.com>";
|
wjlroe = "William Roe <willroe@gmail.com>";
|
||||||
|
wkennington = "William A. Kennington III <william@wkennington.com>";
|
||||||
wmertens = "Wout Mertens <Wout.Mertens@gmail.com>";
|
wmertens = "Wout Mertens <Wout.Mertens@gmail.com>";
|
||||||
z77z = "Marco Maggesi <maggesi@math.unifi.it>";
|
z77z = "Marco Maggesi <maggesi@math.unifi.it>";
|
||||||
zef = "Zef Hemel <zef@zef.me>";
|
zef = "Zef Hemel <zef@zef.me>";
|
||||||
|
@ -138,6 +138,7 @@
|
|||||||
znc = 128;
|
znc = 128;
|
||||||
polipo = 129;
|
polipo = 129;
|
||||||
mopidy = 130;
|
mopidy = 130;
|
||||||
|
unifi = 131;
|
||||||
|
|
||||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||||
|
|
||||||
|
@ -233,6 +233,7 @@
|
|||||||
./services/networking/teamspeak3.nix
|
./services/networking/teamspeak3.nix
|
||||||
./services/networking/tftpd.nix
|
./services/networking/tftpd.nix
|
||||||
./services/networking/unbound.nix
|
./services/networking/unbound.nix
|
||||||
|
./services/networking/unifi.nix
|
||||||
./services/networking/vsftpd.nix
|
./services/networking/vsftpd.nix
|
||||||
./services/networking/wakeonlan.nix
|
./services/networking/wakeonlan.nix
|
||||||
./services/networking/websockify.nix
|
./services/networking/websockify.nix
|
||||||
|
88
nixos/modules/services/networking/unifi.nix
Normal file
88
nixos/modules/services/networking/unifi.nix
Normal file
@ -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}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
32
pkgs/servers/unifi/default.nix
Normal file
32
pkgs/servers/unifi/default.nix
Normal file
@ -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 ];
|
||||||
|
};
|
||||||
|
}
|
@ -7017,6 +7017,8 @@ let
|
|||||||
|
|
||||||
axis2 = callPackage ../servers/http/tomcat/axis2 { };
|
axis2 = callPackage ../servers/http/tomcat/axis2 { };
|
||||||
|
|
||||||
|
unifi = callPackage ../servers/unifi { };
|
||||||
|
|
||||||
virtuoso6 = callPackage ../servers/sql/virtuoso/6.x.nix { };
|
virtuoso6 = callPackage ../servers/sql/virtuoso/6.x.nix { };
|
||||||
|
|
||||||
virtuoso7 = callPackage ../servers/sql/virtuoso/7.x.nix { };
|
virtuoso7 = callPackage ../servers/sql/virtuoso/7.x.nix { };
|
||||||
|
Loading…
Reference in New Issue
Block a user