summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/pr/proxyman/linux.nix
blob: efdefd4ba196fdd4fb20a377694abc25fe39cb50 (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
{
  appimageTools,
  fetchurl,
  asar,
  pname,
  updateScript,
  meta,
}:
let
  version = "3.16.1";

  src = fetchurl {
    url = "https://github.com/ProxymanApp/proxyman-windows-linux/releases/download/${version}/Proxyman-${version}.AppImage";
    hash = "sha256-rykOZVrh3MATFDzwLS7gEj5sMD9udsWAi+68Quqzk0c=";
  };

  appimageContents = appimageTools.extract {
    inherit pname version src;
    postExtract = ''
      ${asar}/bin/asar extract $out/resources/app.asar app

      # This will fix the issue with Proxyman not detecting NixOS as a valid Linux environment
      substituteInPlace app/dist/main/main.js \
        --replace-fail 'systemTrustFilename:"/etc/ca-certificates/trust-source/anchors/%s.crt",trustCommands:["update-ca-trust extract"]' 'systemTrustFilename:"/etc/ssl/certs/%s.crt",trustCommands:[]' \
        --replace-fail '{path:"/etc/ca-certificates/trust-source/anchors/",distroFamily:"arch"}' '{path:"/etc/ssl/certs/",distroFamily:"arch"}'

      # This will permanently mark the certificate as installed, as this should be done through Nix config rather than
      # placing / editing a file in /etc like Proxyman would expect.
      # Configure the certificate located in "~/.config/Proxyman/certificate/certs/ca.pem" using security.pki.certificates in your nix config
      substituteInPlace app/dist/main/main.js --replace-fail "return this.isFile(this.getNewCertPath(e))" "return true"

      ${asar}/bin/asar pack app $out/resources/app.asar
    '';
  };

in
appimageTools.wrapAppImage {
  inherit pname version;
  src = appimageContents;

  extraInstallCommands = ''
    install -Dm444 ${appimageContents}/proxyman.desktop -t $out/share/applications
    install -Dm444 ${appimageContents}/proxyman.png -t $out/share/icons/hicolor/256x256/apps
    substituteInPlace $out/share/applications/proxyman.desktop \
      --replace-fail "Exec=AppRun" "Exec=proxyman --"
  '';

  passthru = {
    inherit updateScript;
    inherit src;
  };

  meta = meta // {
    changelog = "https://proxyman.com/changelog-windows";
    platforms = [ "x86_64-linux" ];
  };
}