|
| 1 | +{ |
| 2 | + fetchFromGitHub, |
| 3 | + fetchYarnDeps, |
| 4 | + fetchpatch, |
| 5 | + lib, |
| 6 | + mqttx-cli, |
| 7 | + nodejs, |
| 8 | + stdenv, |
| 9 | + testers, |
| 10 | + yarnConfigHook, |
| 11 | + yarnInstallHook, |
| 12 | +}: |
| 13 | + |
| 14 | +stdenv.mkDerivation (finalAttrs: { |
| 15 | + pname = "mqttx-cli"; |
| 16 | + version = "1.11.0"; |
| 17 | + |
| 18 | + src = fetchFromGitHub { |
| 19 | + owner = "emqx"; |
| 20 | + repo = "MQTTX"; |
| 21 | + rev = "refs/tags/v${finalAttrs.version}"; |
| 22 | + hash = "sha256-IPIiSav6MPJmzetBgVw9fLGPjJ+JKS3oWMEfCJmEY84="; |
| 23 | + }; |
| 24 | + |
| 25 | + patches = [ |
| 26 | + # moves @faker-js/faker from devDependencies to dependencies |
| 27 | + # because the final package depends on it |
| 28 | + # https://github.com/emqx/MQTTX/pull/1801 |
| 29 | + (fetchpatch { |
| 30 | + url = "https://github.com/emqx/MQTTX/commit/3d89c3a08477e9e2b5d83f2a222ceaa8c08e50ce.patch"; |
| 31 | + hash = "sha256-Rd6YpGHsvAYD7/XCJq6dgvGeKfOiLh7IUQFr/AQz0mY="; |
| 32 | + }) |
| 33 | + ]; |
| 34 | + |
| 35 | + yarnOfflineCache = fetchYarnDeps { |
| 36 | + yarnLock = "${finalAttrs.src}/cli/yarn.lock"; |
| 37 | + hash = "sha256-vwPwSE6adxM1gkdsJBq3LH2eXze9yXADvnM90LsKjjo="; |
| 38 | + }; |
| 39 | + |
| 40 | + nativeBuildInputs = [ |
| 41 | + nodejs |
| 42 | + yarnConfigHook |
| 43 | + yarnInstallHook |
| 44 | + ]; |
| 45 | + |
| 46 | + preConfigure = '' |
| 47 | + cd cli |
| 48 | + ''; |
| 49 | + |
| 50 | + # Using custom build script instead of `yarnBuildHook` |
| 51 | + # because it needs `--ignore-engines` before `build`. |
| 52 | + buildPhase = '' |
| 53 | + runHook preBuild |
| 54 | + yarn --offline --ignore-engines build |
| 55 | + runHook postBuild |
| 56 | + ''; |
| 57 | + |
| 58 | + postInstall = '' |
| 59 | + # rename binary so it does not conflict with the desktop app |
| 60 | + mv $out/bin/mqttx $out/bin/mqttx-cli |
| 61 | + ''; |
| 62 | + |
| 63 | + passthru.tests.version = testers.testVersion { package = mqttx-cli; }; |
| 64 | + |
| 65 | + meta = { |
| 66 | + description = "MQTTX Command Line Tools"; |
| 67 | + homepage = "https://mqttx.app/"; |
| 68 | + changelog = "https://mqttx.app/changelogs/v${finalAttrs.version}"; |
| 69 | + license = lib.licenses.asl20; |
| 70 | + maintainers = with lib.maintainers; [ pineapplehunter ]; |
| 71 | + platforms = lib.platforms.all; |
| 72 | + mainProgram = "mqttx-cli"; |
| 73 | + }; |
| 74 | +}) |
0 commit comments