about summary refs log tree commit diff
path: root/pkgs/misc/vencord/default.nix
blob: 73a4b2cf5ea2f7c497e981b19f6286332a7f46a6 (plain) (blame)
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
79
80
81
82
83
{ buildNpmPackage
, fetchFromGitHub
, fetchpatch2
, lib
, esbuild
, buildGoModule
, buildWebExtension ? false
}:
let
  version = "1.4.5";
  gitHash = "98a03c8";
in
buildNpmPackage rec {
  pname = "vencord";
  inherit version;

  src = fetchFromGitHub {
    owner = "Vendicated";
    repo = "Vencord";
    rev = "v${version}";
    sha256 = "sha256-ZoHOCl0j+RBSl2lL9wO2rJ8VR+GNIeWJYe65c3lVoz8=";
  };

  ESBUILD_BINARY_PATH = lib.getExe (esbuild.override {
    buildGoModule = args: buildGoModule (args // rec {
      version = "0.15.18";
      src = fetchFromGitHub {
        owner = "evanw";
        repo = "esbuild";
        rev = "v${version}";
        hash = "sha256-b9R1ML+pgRg9j2yrkQmBulPuLHYLUQvW+WTyR/Cq6zE=";
      };
      vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
    });
  });

  # Supresses an error about esbuild's version.
  npmRebuildFlags = [ "|| true" ];

  npmDepsHash = "sha256-51IK95QY9YX0WerGu4GuOrYKoj8Uoo0R1b6WZpC5v4U=";
  npmFlags = [ "--legacy-peer-deps" ];
  npmBuildScript = if buildWebExtension then "buildWeb" else "build";
  npmBuildFlags = [ "--" "--standalone" "--disable-updater" ];

  prePatch = ''
    cp ${./package-lock.json} ./package-lock.json
  '';

  patches = [
    (fetchpatch2 {
      name = "allow-git-hash-remote-preset.patch";
      url = "https://github.com/Vendicated/Vencord/commit/d9f55664428007199348123b05818f9e08c4f64d.patch";
      hash = "sha256-l4PP8nVtyQJYUqtU9xYGT4j1Oayy08DE6TfbwPun0pY=";
    })
    (fetchpatch2 {
      name = "use-source-date-epoch.patch";
      url = "https://github.com/Vendicated/Vencord/commit/28247c88a949eeaac75b13a8d6653164d9659f56.patch";
      hash = "sha256-mMpsB3GkI9LUiMQ/NFOiRw4z+wVkktmWgUHNTgxUFPU=";
    })
    (fetchpatch2 {
      name = "allow-disabling-updater.patch";
      url = "https://github.com/Vendicated/Vencord/commit/bad1fa0c766b2d42cd2eb0e0d1ab2e0c381bab98.patch";
      hash = "sha256-yp453kFvVC02QEB3Op8PfopnLt3xGkjp4WfP6kPeIJ0=";
    })
  ];

  VENCORD_HASH = gitHash;
  VENCORD_REMOTE = "${src.owner}/${src.repo}";

  installPhase =
    if buildWebExtension then ''
      cp -r dist/chromium-unpacked/ $out
    '' else ''
      cp -r dist/ $out
    '';

  meta = with lib; {
    description = "Vencord web extension";
    homepage = "https://github.com/Vendicated/Vencord";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ FlafyDev NotAShelf Scrumplex ];
  };
}