biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / by-name / br / bruno / package.nix
blobc9eec26b1558310813f33de681d4c4158df11a7d
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   buildNpmPackage,
6   nix-update-script,
7   electron,
8   writeShellScriptBin,
9   makeWrapper,
10   copyDesktopItems,
11   makeDesktopItem,
12   pkg-config,
13   pixman,
14   cairo,
15   pango,
16   npm-lockfile-fix,
17   overrideSDK,
18   darwin,
21 let
22   # fix for: https://github.com/NixOS/nixpkgs/issues/272156
23   buildNpmPackage' = buildNpmPackage.override {
24     stdenv = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
25   };
27 buildNpmPackage' rec {
28   pname = "bruno";
29   version = "1.32.1";
31   src = fetchFromGitHub {
32     owner = "usebruno";
33     repo = "bruno";
34     rev = "v${version}";
35     hash = "sha256-n/3zNS3aME7ZSoJ7TQ7gqVod469g7PGTsLcdNIwB09Y=";
37     postFetch = ''
38       ${lib.getExe npm-lockfile-fix} $out/package-lock.json
39     '';
40   };
42   npmDepsHash = "sha256-p3kdYuDiPZ9SmtrFajXd76Ohd+VUqn/Y8SpAPFrTBZA=";
43   npmFlags = [ "--legacy-peer-deps" ];
45   nativeBuildInputs =
46     [
47       (writeShellScriptBin "phantomjs" "echo 2.1.1")
48       pkg-config
49     ]
50     ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
51       makeWrapper
52       copyDesktopItems
53     ];
55   buildInputs =
56     [
57       pixman
58       cairo
59       pango
60     ]
61     ++ lib.optionals stdenv.hostPlatform.isDarwin [
62       darwin.apple_sdk_11_0.frameworks.CoreText
63     ];
65   desktopItems = [
66     (makeDesktopItem {
67       name = "bruno";
68       desktopName = "Bruno";
69       exec = "bruno %U";
70       icon = "bruno";
71       comment = "Opensource API Client for Exploring and Testing APIs";
72       categories = [ "Development" ];
73       startupWMClass = "Bruno";
74     })
75   ];
77   postPatch = ''
78     substituteInPlace scripts/build-electron.sh \
79       --replace-fail 'if [ "$1" == "snap" ]; then' 'exit 0; if [ "$1" == "snap" ]; then'
80   '';
82   postConfigure = ''
83     # sh: line 1: /build/source/packages/bruno-common/node_modules/.bin/rollup: cannot execute: required file not found
84     patchShebangs packages/*/node_modules
85   '';
87   ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
89   dontNpmBuild = true;
90   postBuild = ''
91     npm run build --workspace=packages/bruno-common
92     npm run build --workspace=packages/bruno-graphql-docs
93     npm run build --workspace=packages/bruno-app
94     npm run build --workspace=packages/bruno-query
96     npm run sandbox:bundle-libraries --workspace=packages/bruno-js
98     bash scripts/build-electron.sh
100     pushd packages/bruno-electron
102     ${
103       if stdenv.hostPlatform.isDarwin then
104         ''
105           cp -r ${electron.dist}/Electron.app ./
106           find ./Electron.app -name 'Info.plist' | xargs -d '\n' chmod +rw
108           substituteInPlace electron-builder-config.js \
109             --replace-fail "identity: 'Anoop MD (W7LPPWA48L)'" 'identity: null' \
110             --replace-fail "afterSign: 'notarize.js'," ""
112           npm exec electron-builder -- \
113             --dir \
114             --config electron-builder-config.js \
115             -c.electronDist=./ \
116             -c.electronVersion=${electron.version} \
117             -c.npmRebuild=false
118         ''
119       else
120         ''
121           npm exec electron-builder -- \
122             --dir \
123             -c.electronDist=${electron.dist} \
124             -c.electronVersion=${electron.version} \
125             -c.npmRebuild=false
126         ''
127     }
129     popd
130   '';
132   npmPackFlags = [ "--ignore-scripts" ];
134   installPhase = ''
135     runHook preInstall
138     ${
139       if stdenv.hostPlatform.isDarwin then
140         ''
141           mkdir -p $out/Applications
143           cp -R packages/bruno-electron/out/**/Bruno.app $out/Applications/
144         ''
145       else
146         ''
147           mkdir -p $out/opt/bruno $out/bin
149           cp -r packages/bruno-electron/dist/linux*-unpacked/{locales,resources{,.pak}} $out/opt/bruno
151           makeWrapper ${lib.getExe electron} $out/bin/bruno \
152             --add-flags $out/opt/bruno/resources/app.asar \
153             --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
154             --set-default ELECTRON_IS_DEV 0 \
155             --inherit-argv0
157           for s in 16 32 48 64 128 256 512 1024; do
158             size=${"$"}{s}x$s
159             install -Dm644 $src/packages/bruno-electron/resources/icons/png/$size.png $out/share/icons/hicolor/$size/apps/bruno.png
160           done
161         ''
162     }
164     runHook postInstall
165   '';
167   passthru.updateScript = nix-update-script { };
169   meta = with lib; {
170     description = "Open-source IDE For exploring and testing APIs";
171     homepage = "https://www.usebruno.com";
172     platforms = platforms.linux ++ platforms.darwin;
173     license = licenses.mit;
174     maintainers = with maintainers; [
175       gepbird
176       kashw2
177       lucasew
178       mattpolzin
179       water-sucks
180       redyf
181     ];
182     mainProgram = "bruno";
183   };