From 487aa0781d2151e5be83f0f39f73c3941ba24028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Wed, 26 Jan 2022 14:03:05 +0100 Subject: [PATCH 1/3] breitbandmessung: init at 3.1.0 --- nixos/tests/all-tests.nix | 1 + nixos/tests/breitbandmessung.nix | 32 ++++ .../networking/breitbandmessung/default.nix | 153 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 188 insertions(+) create mode 100644 nixos/tests/breitbandmessung.nix create mode 100644 pkgs/applications/networking/breitbandmessung/default.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 62bc8acef606..44015e1e4b77 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -55,6 +55,7 @@ in borgbackup = handleTest ./borgbackup.nix {}; botamusique = handleTest ./botamusique.nix {}; bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {}; + breitbandmessung = handleTest ./breitbandmessung.nix {}; brscan5 = handleTest ./brscan5.nix {}; btrbk = handleTest ./btrbk.nix {}; buildbot = handleTest ./buildbot.nix {}; diff --git a/nixos/tests/breitbandmessung.nix b/nixos/tests/breitbandmessung.nix new file mode 100644 index 000000000000..0ad82d45331d --- /dev/null +++ b/nixos/tests/breitbandmessung.nix @@ -0,0 +1,32 @@ +import ./make-test-python.nix ({ lib, ... }: { + name = "breitbandmessung"; + meta.maintainers = with lib.maintainers; [ b4dm4n ]; + + machine = { pkgs, ... }: { + imports = [ + ./common/user-account.nix + ./common/x11.nix + ]; + + test-support.displayManager.auto.user = "alice"; + + environment.systemPackages = with pkgs; [ breitbandmessung ]; + environment.variables.XAUTHORITY = "/home/alice/.Xauthority"; + + # breitbandmessung is unfree + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "breitbandmessung" ]; + }; + + enableOCR = true; + + testScript = '' + machine.wait_for_x() + # increase screen size to make the whole program visible + machine.succeed("xrandr --output Virtual-1 --mode 1280x1024") + machine.execute("su - alice -c breitbandmessung >&2 &") + machine.wait_for_window("Breitbandmessung") + machine.wait_for_text("Breitbandmessung") + machine.wait_for_text("Datenschutz") + machine.screenshot("breitbandmessung") + ''; +}) diff --git a/pkgs/applications/networking/breitbandmessung/default.nix b/pkgs/applications/networking/breitbandmessung/default.nix new file mode 100644 index 000000000000..2a57379d9916 --- /dev/null +++ b/pkgs/applications/networking/breitbandmessung/default.nix @@ -0,0 +1,153 @@ +{ lib +, stdenv +, alsa-lib +, at-spi2-atk +, at-spi2-core +, atk +, autoPatchelfHook +, cairo +, cups +, dbus +, dpkg +, expat +, fetchurl +, gdk-pixbuf +, glib +, gtk3 +, libdrm +, libxkbcommon +, makeWrapper +, mesa +, nixosTests +, nspr +, nss +, pango +, pciutils +, systemd +, undmg +, writeShellScriptBin +, xorg +}: + +let + inherit (stdenv.hostPlatform) system; + + version = "3.1.0"; + + # At first start, the program checks for supported operating systems by calling `lsb_release -a` + # and only runs when it finds Debian/Ubuntu. So we present us as Debian an make it happy. + fake-lsb-release = writeShellScriptBin "lsb_release" '' + echo "Distributor ID: Debian" + echo "Description: Debian GNU/Linux 10 (buster)" + echo "Release: 10" + echo "Codename: buster" + ''; + + binPath = lib.makeBinPath [ + fake-lsb-release + ]; + + systemArgs = rec { + x86_64-linux = rec { + src = fetchurl { + url = "https://download.breitbandmessung.de/bbm/Breitbandmessung-${version}-linux.deb"; + sha256 = "sha256-jSP+H9ej9Wd+swBZSy9uMi2ExSTZ191FGZhqaocTl7w="; + }; + + dontUnpack = true; + + nativeBuildInputs = [ + autoPatchelfHook + dpkg + makeWrapper + ]; + + buildInputs = runtimeDependencies; + + runtimeDependencies = [ + alsa-lib + at-spi2-atk + at-spi2-core + atk + cairo + cups + dbus + expat + gdk-pixbuf + glib + gtk3 + libdrm + libxkbcommon + mesa + nspr + nss + pango + pciutils + systemd + xorg.libX11 + xorg.libXcomposite + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXrandr + xorg.libxcb + xorg.libxshmfence + ]; + + installPhase = '' + dpkg-deb -x $src $out + mkdir -p $out/bin + + chmod -R g-w $out + + addAutoPatchelfSearchPath --no-recurse $out/opt/Breitbandmessung + autoPatchelfFile $out/opt/Breitbandmessung/breitbandmessung + + makeWrapper $out/opt/Breitbandmessung/breitbandmessung $out/bin/breitbandmessung \ + --prefix PATH : ${binPath} + + mv $out/usr/share $out/share + rmdir $out/usr + + # Fix the desktop link + substituteInPlace $out/share/applications/breitbandmessung.desktop \ + --replace /opt/Breitbandmessung $out/bin + ''; + + dontAutoPatchelf = true; + dontPatchELF = true; + }; + + x86_64-darwin = { + src = fetchurl { + url = "https://download.breitbandmessung.de/bbm/Breitbandmessung-${version}-mac.dmg"; + sha256 = "sha256-2c8mDKJuHDSw7p52EKnJO5vr2kNTLU6r9pmGPANjE20="; + }; + + nativeBuildInputs = [ undmg ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/Applications/Breitbandmessung.app + cp -R . $out/Applications/Breitbandmessung.app + runHook postInstall + ''; + }; + + aarch64-darwin = x86_64-darwin; + }.${system} or (throw "Unsupported system: ${system}"); +in +stdenv.mkDerivation ({ + pname = "breitbandmessung"; + inherit version; + + passthru.tests = { inherit (nixosTests) breitbandmessung; }; + + meta = with lib; { + description = "Broadband internet speed test app from the german Bundesnetzagentur"; + homepage = "https://www.breitbandmessung.de"; + license = licenses.unfree; + maintainers = with maintainers; [ b4dm4n ]; + platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + }; +} // systemArgs) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 54e661d6af0f..63fcff0c5cd9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1083,6 +1083,8 @@ with pkgs; archi = callPackage ../tools/misc/archi { }; + breitbandmessung = callPackage ../applications/networking/breitbandmessung { }; + contour = libsForQt5.callPackage ../applications/terminal-emulators/contour { }; cool-retro-term = libsForQt5.callPackage ../applications/terminal-emulators/cool-retro-term { }; From 9ec1d80c55807213d54548708c52a8c1c9a7df4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Thu, 27 Jan 2022 14:39:02 +0100 Subject: [PATCH 2/3] nixos/tests/breitbandmessung: use virtualisation.resolution option --- nixos/tests/breitbandmessung.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/tests/breitbandmessung.nix b/nixos/tests/breitbandmessung.nix index 0ad82d45331d..12b1a094839b 100644 --- a/nixos/tests/breitbandmessung.nix +++ b/nixos/tests/breitbandmessung.nix @@ -8,6 +8,9 @@ import ./make-test-python.nix ({ lib, ... }: { ./common/x11.nix ]; + # increase screen size to make the whole program visible + virtualisation.resolution = { x = 1280; y = 1024; }; + test-support.displayManager.auto.user = "alice"; environment.systemPackages = with pkgs; [ breitbandmessung ]; @@ -21,8 +24,6 @@ import ./make-test-python.nix ({ lib, ... }: { testScript = '' machine.wait_for_x() - # increase screen size to make the whole program visible - machine.succeed("xrandr --output Virtual-1 --mode 1280x1024") machine.execute("su - alice -c breitbandmessung >&2 &") machine.wait_for_window("Breitbandmessung") machine.wait_for_text("Breitbandmessung") From e533f9d3b2f2c0d578c935741674d72a7a1ecee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Thu, 27 Jan 2022 23:25:59 +0100 Subject: [PATCH 3/3] breitbandmessung: throw later for unsupported systems This will provide at least the `name` and `meta` attributes when evaluating on such a system. `meta.platforms` and therefore `meta.broken` can then be used to determine if the package can be evaluated further. --- pkgs/applications/networking/breitbandmessung/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/networking/breitbandmessung/default.nix b/pkgs/applications/networking/breitbandmessung/default.nix index 2a57379d9916..31f33be38670 100644 --- a/pkgs/applications/networking/breitbandmessung/default.nix +++ b/pkgs/applications/networking/breitbandmessung/default.nix @@ -135,7 +135,7 @@ let }; aarch64-darwin = x86_64-darwin; - }.${system} or (throw "Unsupported system: ${system}"); + }.${system} or { src = throw "Unsupported system: ${system}"; }; in stdenv.mkDerivation ({ pname = "breitbandmessung";