blast: fix and enable strictDeps (#366620)
[NixPkgs.git] / pkgs / by-name / br / bruno / package.nix
blobcda28d7311777512590ef2a608663b05fc214884
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   buildNpmPackage,
6   nix-update-script,
7   electron,
8   makeWrapper,
9   copyDesktopItems,
10   makeDesktopItem,
11   pkg-config,
12   pixman,
13   cairo,
14   pango,
15   npm-lockfile-fix,
18 buildNpmPackage rec {
19   pname = "bruno";
20   version = "1.38.1";
22   src = fetchFromGitHub {
23     owner = "usebruno";
24     repo = "bruno";
25     tag = "v${version}";
26     hash = "sha256-VZRVmOJkNjZLpIG5oBIbDVJl8EZhOtBMywwJKdfD9Hc=";
28     postFetch = ''
29       ${lib.getExe npm-lockfile-fix} $out/package-lock.json
30     '';
31   };
33   npmDepsHash = "sha256-qgg/dpkBAbOgBeGC0BiKQTyLsOOKwfsJD3fhs/cXYHo=";
34   npmFlags = [ "--legacy-peer-deps" ];
36   nativeBuildInputs =
37     [
38       pkg-config
39     ]
40     ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
41       makeWrapper
42       copyDesktopItems
43     ];
45   buildInputs = [
46     pixman
47     cairo
48     pango
49   ];
51   desktopItems = [
52     (makeDesktopItem {
53       name = "bruno";
54       desktopName = "Bruno";
55       exec = "bruno %U";
56       icon = "bruno";
57       comment = "Opensource API Client for Exploring and Testing APIs";
58       categories = [ "Development" ];
59       startupWMClass = "Bruno";
60     })
61   ];
63   postPatch = ''
64     substituteInPlace scripts/build-electron.sh \
65       --replace-fail 'if [ "$1" == "snap" ]; then' 'exit 0; if [ "$1" == "snap" ]; then'
67     # disable telemetry
68     substituteInPlace packages/bruno-app/src/providers/App/index.js \
69       --replace-fail "useTelemetry();" ""
70   '';
72   postConfigure = ''
73     # sh: line 1: /build/source/packages/bruno-common/node_modules/.bin/rollup: cannot execute: required file not found
74     patchShebangs packages/*/node_modules
75   '';
77   ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
79   # remove giflib dependency
80   npmRebuildFlags = [ "--ignore-scripts" ];
81   preBuild = ''
82     # upstream keeps removing and adding back canvas, only patch it when it is present
83     if [[ -e node_modules/canvas/binding.gyp ]]; then
84       substituteInPlace node_modules/canvas/binding.gyp \
85         --replace-fail "'with_gif%': '<!(node ./util/has_lib.js gif)'" "'with_gif%': 'false'"
86       npm rebuild
87     fi
88   '';
90   buildPhase = ''
91     runHook preBuild
93     npm run build --workspace=packages/bruno-common
94     npm run build --workspace=packages/bruno-graphql-docs
95     npm run build --workspace=packages/bruno-app
96     npm run build --workspace=packages/bruno-query
98     npm run sandbox:bundle-libraries --workspace=packages/bruno-js
100     bash scripts/build-electron.sh
102     pushd packages/bruno-electron
104     ${
105       if stdenv.hostPlatform.isDarwin then
106         ''
107           cp -r ${electron.dist}/Electron.app ./
108           find ./Electron.app -name 'Info.plist' | xargs -d '\n' chmod +rw
110           substituteInPlace electron-builder-config.js \
111             --replace-fail "identity: 'Anoop MD (W7LPPWA48L)'" 'identity: null' \
112             --replace-fail "afterSign: 'notarize.js'," ""
114           npm exec electron-builder -- \
115             --dir \
116             --config electron-builder-config.js \
117             -c.electronDist=./ \
118             -c.electronVersion=${electron.version} \
119             -c.npmRebuild=false
120         ''
121       else
122         ''
123           npm exec electron-builder -- \
124             --dir \
125             -c.electronDist=${electron.dist} \
126             -c.electronVersion=${electron.version} \
127             -c.npmRebuild=false
128         ''
129     }
131     popd
133     runHook postBuild
134   '';
136   npmPackFlags = [ "--ignore-scripts" ];
138   installPhase = ''
139     runHook preInstall
141     ${
142       if stdenv.hostPlatform.isDarwin then
143         ''
144           mkdir -p $out/Applications
146           cp -R packages/bruno-electron/out/**/Bruno.app $out/Applications/
147         ''
148       else
149         ''
150           mkdir -p $out/opt/bruno $out/bin
152           cp -r packages/bruno-electron/dist/linux*-unpacked/{locales,resources{,.pak}} $out/opt/bruno
154           makeWrapper ${lib.getExe electron} $out/bin/bruno \
155             --add-flags $out/opt/bruno/resources/app.asar \
156             --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
157             --set-default ELECTRON_IS_DEV 0 \
158             --inherit-argv0
160           for s in 16 32 48 64 128 256 512 1024; do
161             size=${"$"}{s}x$s
162             install -Dm644 $src/packages/bruno-electron/resources/icons/png/$size.png $out/share/icons/hicolor/$size/apps/bruno.png
163           done
164         ''
165     }
167     runHook postInstall
168   '';
170   passthru.updateScript = nix-update-script { };
172   meta = {
173     description = "Open-source IDE For exploring and testing APIs";
174     homepage = "https://www.usebruno.com";
175     license = lib.licenses.mit;
176     mainProgram = "bruno";
177     maintainers = with lib.maintainers; [
178       gepbird
179       kashw2
180       lucasew
181       mattpolzin
182       redyf
183       water-sucks
184     ];
185     platforms = lib.platforms.linux ++ lib.platforms.darwin;
186   };