mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixos/unifi: refactor test and package
- use autoPatchElf - correct supported platforms - use finalAttrs and stdenvNoCC - use runTest - attest the status of the service
This commit is contained in:
parent
c11863f1e9
commit
65506ebf0f
3 changed files with 43 additions and 62 deletions
|
@ -1395,7 +1395,7 @@ in
|
|||
ulogd = handleTest ./ulogd/ulogd.nix { };
|
||||
umurmur = handleTest ./umurmur.nix { };
|
||||
unbound = handleTest ./unbound.nix { };
|
||||
unifi = handleTest ./unifi.nix { };
|
||||
unifi = runTest ./unifi.nix;
|
||||
unit-php = runTest ./web-servers/unit-php.nix;
|
||||
unit-perl = handleTest ./web-servers/unit-perl.nix { };
|
||||
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
|
||||
|
|
|
@ -1,45 +1,30 @@
|
|||
# Test UniFi controller
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
system ? builtins.currentSystem,
|
||||
config ? {
|
||||
allowUnfree = true;
|
||||
},
|
||||
pkgs ? import ../.. { inherit system config; },
|
||||
}:
|
||||
name = "unifi";
|
||||
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
with pkgs.lib;
|
||||
meta.maintainers = with lib.maintainers; [
|
||||
patryk27
|
||||
zhaofengli
|
||||
];
|
||||
|
||||
let
|
||||
makeAppTest =
|
||||
unifi:
|
||||
makeTest {
|
||||
name = "unifi-controller-${unifi.version}";
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [
|
||||
patryk27
|
||||
zhaofengli
|
||||
];
|
||||
};
|
||||
node.pkgsReadOnly = false;
|
||||
|
||||
nodes.server = {
|
||||
nixpkgs.config = config;
|
||||
nodes.machine = {
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
services.unifi = {
|
||||
enable = true;
|
||||
unifiPackage = unifi;
|
||||
openFirewall = false;
|
||||
};
|
||||
};
|
||||
services.unifi.enable = true;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
server.wait_for_unit("unifi.service")
|
||||
server.wait_until_succeeds("curl -Lk https://localhost:8443 >&2", timeout=300)
|
||||
'';
|
||||
};
|
||||
in
|
||||
with pkgs;
|
||||
{
|
||||
unifi8 = makeAppTest unifi8;
|
||||
testScript = ''
|
||||
import json
|
||||
|
||||
start_all()
|
||||
|
||||
machine.wait_for_unit("unifi.service")
|
||||
machine.wait_for_open_port(8880)
|
||||
|
||||
status = json.loads(machine.succeed("curl --silent --show-error --fail-with-body http://localhost:8880/status"))
|
||||
assert status["meta"]["rc"] == "ok"
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,59 +1,55 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
stdenvNoCC,
|
||||
dpkg,
|
||||
fetchurl,
|
||||
nixosTests,
|
||||
systemd,
|
||||
autoPatchelfHook,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "unifi-controller";
|
||||
version = "9.0.114";
|
||||
|
||||
# see https://community.ui.com/releases / https://www.ui.com/download/unifi
|
||||
src = fetchurl {
|
||||
url = "https://dl.ui.com/unifi/${version}/unifi_sysvinit_all.deb";
|
||||
url = "https://dl.ui.com/unifi/${finalAttrs.version}/unifi_sysvinit_all.deb";
|
||||
hash = "sha256-3xumIIzr+tx60kPhPfSs2Kz2iJ39Kt5934Vca/MpUu4=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ dpkg ];
|
||||
nativeBuildInputs = [
|
||||
dpkg
|
||||
autoPatchelfHook
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
systemd
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
cd ./usr/lib/unifi
|
||||
cp -ar dl lib webapps $out
|
||||
cp -ar usr/lib/unifi/{dl,lib,webapps} $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall =
|
||||
if stdenv.hostPlatform.system == "x86_64-linux" then
|
||||
''
|
||||
patchelf --add-needed "${systemd}/lib/libsystemd.so.0" "$out/lib/native/Linux/x86_64/libubnt_sdnotify_jni.so"
|
||||
''
|
||||
else if stdenv.hostPlatform.system == "aarch64-linux" then
|
||||
''
|
||||
patchelf --add-needed "${systemd}/lib/libsystemd.so.0" "$out/lib/native/Linux/aarch64/libubnt_sdnotify_jni.so"
|
||||
''
|
||||
else
|
||||
null;
|
||||
|
||||
passthru.tests = {
|
||||
unifi = nixosTests.unifi;
|
||||
};
|
||||
passthru.tests = { inherit (nixosTests) unifi; };
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "http://www.ubnt.com/";
|
||||
homepage = "https://www.ui.com";
|
||||
description = "Controller for Ubiquiti UniFi access points";
|
||||
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
||||
license = licenses.unfree;
|
||||
platforms = platforms.unix;
|
||||
platforms = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
maintainers = with maintainers; [
|
||||
globin
|
||||
patryk27
|
||||
];
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue