1{ lib
2, stdenv
3, buildNpmPackage
4, fetchFromGitHub
5, testers
6, balena-cli
7, nodePackages
8, python3
9, udev
10, darwin
11}:
12
13buildNpmPackage rec {
14 pname = "balena-cli";
15 version = "17.0.0";
16
17 src = fetchFromGitHub {
18 owner = "balena-io";
19 repo = "balena-cli";
20 rev = "v${version}";
21 hash = "sha256-sNpxjSumiP+4fX6b3j+HEl/lr4pvudrhfTzr2TYastE=";
22 };
23
24 npmDepsHash = "sha256-q2Yc6e5dEiP2Q4tFIeqj4mswM1/pX1pdGeoagyiupvs=";
25
26 postPatch = ''
27 ln -s npm-shrinkwrap.json package-lock.json
28 '';
29 makeCacheWritable = true;
30
31 nativeBuildInputs = [
32 nodePackages.node-gyp
33 python3
34 ] ++ lib.optionals stdenv.isDarwin [
35 darwin.cctools
36 ];
37
38 buildInputs = lib.optionals stdenv.isLinux [
39 udev
40 ] ++ lib.optionals stdenv.isDarwin [
41 darwin.apple_sdk.frameworks.Foundation
42 darwin.apple_sdk.frameworks.Cocoa
43 ];
44
45 passthru.tests.version = testers.testVersion {
46 package = balena-cli;
47 command = ''
48 # Override default cache directory so Balena CLI's unavoidable update check does not fail due to write permissions
49 BALENARC_DATA_DIRECTORY=./ balena --version
50 '';
51 inherit version;
52 };
53
54 meta = with lib; {
55 description = "A command line interface for balenaCloud or openBalena";
56 longDescription = ''
57 The balena CLI is a Command Line Interface for balenaCloud or openBalena. It is a software
58 tool available for Windows, macOS and Linux, used through a command prompt / terminal window.
59 It can be used interactively or invoked in scripts. The balena CLI builds on the balena API
60 and the balena SDK, and can also be directly imported in Node.js applications.
61 '';
62 homepage = "https://github.com/balena-io/balena-cli";
63 changelog = "https://github.com/balena-io/balena-cli/blob/v${version}/CHANGELOG.md";
64 license = licenses.asl20;
65 maintainers = [ maintainers.kalebpace maintainers.doronbehar ];
66 mainProgram = "balena";
67 };
68}