aboutsummaryrefslogtreecommitdiff
path: root/overlays/minbrowser.nix
blob: 6017c90dbe98e333d6b2052f11e6081e740acf47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
  lib,
  stdenv,
  fetchurl,

  dpkg,
  autoPatchelfHook,

  libxkbcommon,
  libxcb,
  xorg,
  alsa-lib,
  nss,
  at-spi2-core,
  mesa,
  cairo,
  pango,
  cups,
  gtk3,
  glib,

  nix-update-script,
}:

stdenv.mkDerivation (finalAttrs: let
  system = stdenv.hostPlatform.system;

  asset = if lib.strings.hasPrefix "x86_64-linux" system then {
     url = "https://github.com/minbrowser/min/releases/download/v${finalAttrs.version}/min-${finalAttrs.version}-amd64.deb";
    sha256 = "sha256-gpkjGYuHwBY3IwK5bXhzIPPosSTZ67hclmGLT4PTsG4=";
  } else if system == "x86_64-darwin" then {
    url = "https://github.com/minbrowser/min/releases/download/v${finalAttrs.version}/min-v${finalAttrs.version}-mac-x86_64.zip";
    sha256 = "";
  } else if system == "aarch64-darwin" then {
    url = "https://github.com/minbrowser/min/releases/download/v${finalAttrs.version}/min-v${finalAttrs.version}-mac-arm64.zip";
    sha256 = "";
  } else throw "Unsupported plattform: ${system}";
  in {
  pname = "min";
  version = "1.34.1";

  src = fetchurl {
    url = asset.url;
    hash = asset.sha256;
  };

  nativeBuildInputs = [ autoPatchelfHook ];
  nativeBuildInputs = lib.optional (lib.strings.hasPrefix "x86_64-linux" system) dpkg ++ [ autoPatchelHook ];

  buildInputs = [
    libxkbcommon libxcb at-spi2-core mesa cairo cups gtk3 pango
    alsa-lib nss glib stdenv.cc.cc.lib
  ] ++ (with xorg; [ libX11 libXcomposite libXdamage libXext libXfixes libXrandr ]);

  unpackPhase = ''
    ${lib.optionalString (lib.strings.hasPrefix "x86_64-linux" system) ''
      dpkg-deb -x $src $out
      mv $out/usr/share $out
    ''}
    ${lib.optionalString (system == "x86_64-darwin" || system == "aarch64-darwin") ''
      unzip $src -d $out
      # the zip contains e.g. Min.app; flatten:
      mv $out/Min.app/Contents/* $out/
    ''}
    mkdir -p $out/bin
    ln -s $out/opt/Min/min $out/bin/min
  '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Fast, minimal browser that protects your privacy";
    homepage = "https://github.com/minbrowser/min";
    changelog = "https://github.com/minbrowser/min/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ kashw2 ];
  };
})