mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +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 { };
|
ulogd = handleTest ./ulogd/ulogd.nix { };
|
||||||
umurmur = handleTest ./umurmur.nix { };
|
umurmur = handleTest ./umurmur.nix { };
|
||||||
unbound = handleTest ./unbound.nix { };
|
unbound = handleTest ./unbound.nix { };
|
||||||
unifi = handleTest ./unifi.nix { };
|
unifi = runTest ./unifi.nix;
|
||||||
unit-php = runTest ./web-servers/unit-php.nix;
|
unit-php = runTest ./web-servers/unit-php.nix;
|
||||||
unit-perl = handleTest ./web-servers/unit-perl.nix { };
|
unit-perl = handleTest ./web-servers/unit-perl.nix { };
|
||||||
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
|
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
|
||||||
|
|
|
@ -1,45 +1,30 @@
|
||||||
# Test UniFi controller
|
{ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
system ? builtins.currentSystem,
|
name = "unifi";
|
||||||
config ? {
|
|
||||||
allowUnfree = true;
|
|
||||||
},
|
|
||||||
pkgs ? import ../.. { inherit system config; },
|
|
||||||
}:
|
|
||||||
|
|
||||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
meta.maintainers = with lib.maintainers; [
|
||||||
with pkgs.lib;
|
patryk27
|
||||||
|
zhaofengli
|
||||||
|
];
|
||||||
|
|
||||||
let
|
node.pkgsReadOnly = false;
|
||||||
makeAppTest =
|
|
||||||
unifi:
|
|
||||||
makeTest {
|
|
||||||
name = "unifi-controller-${unifi.version}";
|
|
||||||
meta = with pkgs.lib.maintainers; {
|
|
||||||
maintainers = [
|
|
||||||
patryk27
|
|
||||||
zhaofengli
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
nodes.server = {
|
nodes.machine = {
|
||||||
nixpkgs.config = config;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
services.unifi = {
|
services.unifi.enable = true;
|
||||||
enable = true;
|
};
|
||||||
unifiPackage = unifi;
|
|
||||||
openFirewall = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
server.wait_for_unit("unifi.service")
|
import json
|
||||||
server.wait_until_succeeds("curl -Lk https://localhost:8443 >&2", timeout=300)
|
|
||||||
'';
|
start_all()
|
||||||
};
|
|
||||||
in
|
machine.wait_for_unit("unifi.service")
|
||||||
with pkgs;
|
machine.wait_for_open_port(8880)
|
||||||
{
|
|
||||||
unifi8 = makeAppTest unifi8;
|
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,
|
lib,
|
||||||
stdenv,
|
stdenvNoCC,
|
||||||
dpkg,
|
dpkg,
|
||||||
fetchurl,
|
fetchurl,
|
||||||
nixosTests,
|
nixosTests,
|
||||||
systemd,
|
systemd,
|
||||||
|
autoPatchelfHook,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||||
pname = "unifi-controller";
|
pname = "unifi-controller";
|
||||||
version = "9.0.114";
|
version = "9.0.114";
|
||||||
|
|
||||||
# see https://community.ui.com/releases / https://www.ui.com/download/unifi
|
# see https://community.ui.com/releases / https://www.ui.com/download/unifi
|
||||||
src = fetchurl {
|
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=";
|
hash = "sha256-3xumIIzr+tx60kPhPfSs2Kz2iJ39Kt5934Vca/MpUu4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ dpkg ];
|
nativeBuildInputs = [
|
||||||
|
dpkg
|
||||||
|
autoPatchelfHook
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
systemd
|
||||||
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cd ./usr/lib/unifi
|
cp -ar usr/lib/unifi/{dl,lib,webapps} $out
|
||||||
cp -ar dl lib webapps $out
|
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postInstall =
|
passthru.tests = { inherit (nixosTests) unifi; };
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "http://www.ubnt.com/";
|
homepage = "https://www.ui.com";
|
||||||
description = "Controller for Ubiquiti UniFi access points";
|
description = "Controller for Ubiquiti UniFi access points";
|
||||||
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
||||||
license = licenses.unfree;
|
license = licenses.unfree;
|
||||||
platforms = platforms.unix;
|
platforms = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
maintainers = with maintainers; [
|
maintainers = with maintainers; [
|
||||||
globin
|
globin
|
||||||
patryk27
|
patryk27
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue