nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 117 lines 3.0 kB view raw
1{ 2 lib, 3 stdenv, 4 clang_20, 5 buildNpmPackage, 6 nodejs_22, 7 bruno, 8 pkg-config, 9 pango, 10 testers, 11 bruno-cli, 12}: 13 14let 15 pname = "bruno-cli"; 16in 17buildNpmPackage { 18 inherit pname; 19 20 # since they only make releases and git tags for bruno, 21 # we lie about bruno-cli's version and say it's the same as bruno's 22 # to keep them in sync with easier maintenance 23 inherit (bruno) version src npmDepsHash; 24 25 # npm dependency install fails with nodejs_24: https://github.com/NixOS/nixpkgs/issues/474535 26 nodejs = nodejs_22; 27 28 npmWorkspace = "packages/bruno-cli"; 29 npmFlags = [ "--legacy-peer-deps" ]; 30 31 nativeBuildInputs = [ 32 pkg-config 33 ] 34 ++ lib.optional stdenv.isDarwin clang_20; # clang_21 breaks gyp builds 35 36 buildInputs = [ 37 pango 38 ]; 39 40 postConfigure = '' 41 # sh: line 1: /build/source/packages/bruno-converters/node_modules/.bin/rimraf: cannot execute: required file not found 42 patchShebangs packages/*/node_modules 43 ''; 44 45 ELECTRON_SKIP_BINARY_DOWNLOAD = 1; 46 47 buildPhase = '' 48 runHook preBuild 49 50 npm run build --workspace=packages/bruno-common 51 npm run build --workspace=packages/bruno-graphql-docs 52 npm run build --workspace=packages/bruno-schema-types 53 npm run build --workspace=packages/bruno-converters 54 npm run build --workspace=packages/bruno-query 55 npm run build --workspace=packages/bruno-filestore 56 npm run build --workspace=packages/bruno-requests 57 58 npm run sandbox:bundle-libraries --workspace=packages/bruno-js 59 60 runHook postBuild 61 ''; 62 63 npmPackFlags = [ "--ignore-scripts" ]; 64 65 postInstall = '' 66 cp -r packages $out/lib/node_modules/usebruno 67 68 echo "Removing unnecessary files" 69 pushd $out/lib/node_modules/usebruno 70 71 # packages used by the GUI app, unused by CLI 72 rm -r packages/bruno-{app,electron,tests,toml,docs} 73 rm node_modules/bruno 74 rm node_modules/@usebruno/{app,tests,toml} 75 76 # heavy dependencies that seem to be unused 77 rm -rf node_modules/{@tabler,pdfjs-dist,*redux*,prettier,@types*,*react*,*graphiql*,@swagger-api} 78 rm -r node_modules/.bin 79 80 # unused file types 81 for pattern in '*.map' '*.map.js' '*.ts'; do 82 find . -type f -name "$pattern" -exec rm {} + 83 done 84 85 popd 86 echo "Removed unnecessary files" 87 ''; 88 89 postFixup = '' 90 wrapProgram $out/bin/bru \ 91 --prefix NODE_PATH : $out/lib/node_modules/usebruno/packages/bruno-cli/node_modules \ 92 --prefix NODE_PATH : $out/lib/node_modules 93 ''; 94 95 passthru.tests.help = testers.runCommand { 96 name = "${pname}-help-test"; 97 nativeBuildInputs = [ bruno-cli ]; 98 script = '' 99 bru --help && touch $out 100 ''; 101 }; 102 103 meta = { 104 description = "CLI of the open-source IDE For exploring and testing APIs"; 105 homepage = "https://www.usebruno.com"; 106 license = lib.licenses.mit; 107 mainProgram = "bru"; 108 maintainers = with lib.maintainers; [ 109 gepbird 110 kashw2 111 lucasew 112 mattpolzin 113 water-sucks 114 ]; 115 platforms = lib.platforms.linux ++ lib.platforms.darwin; 116 }; 117}