btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / fl / flclash / package.nix
blobd72a16afc6a14a2906c9a8c7483662368a2ddd3a
2   lib,
3   fetchFromGitHub,
4   flutter,
5   keybinder3,
6   libayatana-appindicator,
7   buildGoModule,
8   makeDesktopItem,
9   copyDesktopItems,
11 let
12   pname = "flclash";
13   version = "0.8.66";
14   src =
15     (fetchFromGitHub {
16       owner = "chen08209";
17       repo = "FlClash";
18       rev = "v${version}";
19       hash = "sha256-LkaAALJcP3DGXBMZ3QWLUiyT9Kr4yTxKIRqYhrW1WOw=";
20       fetchSubmodules = true;
21     }).overrideAttrs
22       (_: {
23         GIT_CONFIG_COUNT = 1;
24         GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf";
25         GIT_CONFIG_VALUE_0 = "git@github.com:";
26       });
27   libclash = buildGoModule {
28     inherit pname version src;
29     modRoot = "./core";
30     vendorHash = "sha256-K+PrLFvDHyaxf1NKzcqf0qmfQwT8rctScv1CN+TxY0M=";
31     buildPhase = ''
32       runHook preBuild
33       mkdir -p $out/lib
34       go build -ldflags="-w -s" -tags=with_gvisor -buildmode=c-shared -o $out/lib/libclash.so
35       runHook postBuild
36     '';
37   };
39 flutter.buildFlutterApplication {
40   inherit pname version src;
42   desktopItems = [
43     (makeDesktopItem {
44       name = "FlClash";
45       exec = "FlClash %U";
46       icon = "FlClash";
47       genericName = "FlClash";
48       desktopName = "FlClash";
49       categories = [
50         "Network"
51       ];
52       keywords = [
53         "FlClash"
54         "Clash"
55         "ClashMeta"
56         "Proxy"
57       ];
58     })
59   ];
61   patchPhase = ''
62     runHook prePatch
63     substituteInPlace lib/clash/core.dart --replace-fail 'DynamicLibrary.open("libclash.so")' 'DynamicLibrary.open("${libclash}/lib/libclash.so")'
64     runHook postPatch
65   '';
67   preBuild = ''
68     mkdir -p ./libclash/linux/
69     cp ${libclash}/lib/libclash.so ./libclash/linux/libclash.so
70   '';
72   postInstall = ''
73     mkdir -p $out/share/pixmaps/
74     cp ./assets/images/icon.png $out/share/pixmaps/FlClash.png
75   '';
77   pubspecLock = lib.importJSON ./pubspec.lock.json;
79   nativeBuildInputs = [
80     copyDesktopItems
81   ];
83   buildInputs = [
84     keybinder3
85     libayatana-appindicator
86   ];
88   meta = {
89     description = "Multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free";
90     homepage = "https://github.com/chen08209/FlClash";
91     mainProgram = "FlClash";
92     license = with lib.licenses; [ gpl3Plus ];
93     maintainers = with lib.maintainers; [ aucub ];
94     platforms = lib.platforms.linux;
95   };