btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / su / surrealist / package.nix
blob82d872ea1f7b18ed1e78c01acba1e19cb98f66ed
1 { buildGoModule
2 , cairo
3 , cargo
4 , cargo-tauri
5 , esbuild
6 , fetchFromGitHub
7 , gdk-pixbuf
8 , glib-networking
9 , gobject-introspection
10 , lib
11 , libsoup_3
12 , makeBinaryWrapper
13 , nodejs
14 , openssl
15 , pango
16 , pkg-config
17 , pnpm
18 , rustc
19 , rustPlatform
20 , stdenv
21 , webkitgtk_4_1
24 let
25   cargo-tauri_2 = let
26     version = "2.0.0-rc.3";
27     src = fetchFromGitHub {
28       owner = "tauri-apps";
29       repo = "tauri";
30       rev = "tauri-v${version}";
31       hash = "sha256-PV8m/MzYgbY4Hv71dZrqVbrxmxrwFfOAraLJIaQk6FQ=";
32     };
33   in cargo-tauri.overrideAttrs (drv: {
34     inherit src version;
35     cargoDeps = drv.cargoDeps.overrideAttrs (lib.const {
36       inherit src;
37       name = "tauri-${version}-vendor.tar.gz";
38       outputHash = "sha256-BrIH0JkGMp68O+4B+0g7X3lSdNSPXo+otlBgslCzPZE=";
39     });
40   });
42   esbuild_21-5 = let
43     version = "0.21.5";
44   in esbuild.override {
45     buildGoModule = args:
46       buildGoModule (args // {
47         inherit version;
48         src = fetchFromGitHub {
49           owner = "evanw";
50           repo = "esbuild";
51           rev = "v${version}";
52           hash = "sha256-FpvXWIlt67G8w3pBKZo/mcp57LunxDmRUaCU/Ne89B8=";
53         };
54         vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
55       });
56   };
58 in stdenv.mkDerivation (finalAttrs: {
59   pname = "surrealist";
60   version = "2.1.6";
62   src = fetchFromGitHub {
63     owner = "surrealdb";
64     repo = "surrealist";
65     rev = "surrealist-v${finalAttrs.version}";
66     hash = "sha256-jOjOdrVOcGPenFW5mkkXKA64C6c+/f9KzlvtUmw6vXc=";
67   };
69   # HACK: A dependency (surrealist -> tauri -> **reqwest**) contains hyper-tls
70   # as an actually optional dependency. It ends up in the `Cargo.lock` file of
71   # tauri, but not in the one of surrealist. We apply a patch to `Cargo.toml`
72   # and `Cargo.lock` to ensure that we have it in our vendor archive. This may
73   # be a result of the following bug:
74   # https://github.com/rust-lang/cargo/issues/10801
75   patches = [
76     ./0001-Cargo.patch
77   ];
79   cargoDeps = rustPlatform.fetchCargoTarball {
80     inherit (finalAttrs) patches src;
81     sourceRoot = finalAttrs.cargoRoot;
82     name = "${finalAttrs.pname}-${finalAttrs.version}";
83     hash = "sha256-LtQS0kH+2P4odV7BJYiH6T51+iZHAM9W9mV96rNfNWs=";
84   };
86   pnpmDeps = pnpm.fetchDeps {
87     inherit (finalAttrs) pname version src;
88     hash = "sha256-Y14wBYiAsctMf4Ljt7G/twGEQP2nCSDQZVG8otImnIE=";
89   };
91   nativeBuildInputs = [
92     cargo
93     (cargo-tauri.hook.override { cargo-tauri = cargo-tauri_2; })
94     gobject-introspection
95     makeBinaryWrapper
96     nodejs
97     pnpm.configHook
98     pkg-config
99     rustc
100     rustPlatform.cargoSetupHook
101   ];
103   buildInputs = [
104     cairo
105     gdk-pixbuf
106     libsoup_3
107     openssl
108     pango
109     webkitgtk_4_1
110   ];
112   env = {
113     ESBUILD_BINARY_PATH = lib.getExe esbuild_21-5;
114     OPENSSL_NO_VENDOR = 1;
115   };
117   cargoRoot = "src-tauri";
118   buildAndTestSubdir = finalAttrs.cargoRoot;
120   postFixup = ''
121     wrapProgram "$out/bin/surrealist" \
122       --set GIO_EXTRA_MODULES ${glib-networking}/lib/gio/modules \
123       --set WEBKIT_DISABLE_COMPOSITING_MODE 1
124   '';
126   meta = with lib; {
127     description = "Surrealist is the ultimate way to visually manage your SurrealDB database";
128     homepage = "https://surrealdb.com/surrealist";
129     license = licenses.mit;
130     mainProgram = "surrealist";
131     maintainers = with maintainers; [ frankp ];
132     platforms = platforms.linux;
133   };