av1an: 0.4.3 -> 0.4.4 (#370509)
[NixPkgs.git] / pkgs / applications / networking / breitbandmessung / default.nix
blob56315779dd1112a8c99a45de6f52968523b0bf87
2   lib,
3   stdenv,
4   fetchurl,
5   asar,
6   dpkg,
7   electron,
8   makeWrapper,
9   nixosTests,
10   undmg,
13 let
14   inherit (stdenv.hostPlatform) system;
16   sources = import ./sources.nix;
18   systemArgs =
19     rec {
20       x86_64-linux = {
21         src = fetchurl sources.x86_64-linux;
23         nativeBuildInputs = [
24           asar
25           dpkg
26           makeWrapper
27         ];
29         installPhase = ''
30           mkdir -p $out/bin
31           mv usr/share $out/share
32           mkdir -p $out/share/breitbandmessung/resources
34           asar e opt/Breitbandmessung/resources/app.asar $out/share/breitbandmessung/resources
36           # At first start, the program checks for supported operating systems by using the `bizzby-lsb-release`
37           # module and only runs when it finds Debian/Ubuntu. So we present us as Debian and make it happy.
38           cat <<EOF > $out/share/breitbandmessung/resources/node_modules/bizzby-lsb-release/lib/lsb-release.js
39           module.exports = function release() {
40             return {
41               distributorID: "Debian",
42               description: "Debian GNU/Linux 10 (buster)",
43               release: "10",
44               codename: "buster"
45             }
46           }
47           EOF
49           makeWrapper ${electron}/bin/electron $out/bin/breitbandmessung \
50             --add-flags $out/share/breitbandmessung/resources/build/electron.js
52           # Fix the desktop link
53           substituteInPlace $out/share/applications/breitbandmessung.desktop \
54             --replace /opt/Breitbandmessung $out/bin
55         '';
56       };
58       x86_64-darwin = {
59         src = fetchurl sources.x86_64-darwin;
61         nativeBuildInputs = [ undmg ];
63         installPhase = ''
64           runHook preInstall
65           mkdir -p $out/Applications/Breitbandmessung.app
66           cp -R . $out/Applications/Breitbandmessung.app
67           runHook postInstall
68         '';
69       };
71       aarch64-darwin = x86_64-darwin;
72     }
73     .${system} or {
74       src = throw "Unsupported system: ${system}";
75     };
77 stdenv.mkDerivation (
78   {
79     pname = "breitbandmessung";
80     inherit (sources) version;
82     passthru.tests = { inherit (nixosTests) breitbandmessung; };
83     passthru.updateScript = ./update.sh;
85     meta = with lib; {
86       description = "Broadband internet speed test app from the german Bundesnetzagentur";
87       homepage = "https://www.breitbandmessung.de";
88       license = licenses.unfree;
89       sourceProvenance = with sourceTypes; [ binaryNativeCode ];
90       maintainers = with maintainers; [ b4dm4n ];
91       platforms = [
92         "x86_64-linux"
93         "x86_64-darwin"
94         "aarch64-darwin"
95       ];
96     };
97   }
98   // systemArgs