nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 nix-update-script,
7 stdenv,
8 testers,
9}:
10
11buildGoModule (finalAttrs: {
12 pname = "ente-cli";
13 version = "0.2.3";
14
15 src = fetchFromGitHub {
16 owner = "ente-io";
17 repo = "ente";
18 tag = "cli-v${finalAttrs.version}";
19 hash = "sha256-qKMFoNtD5gH0Y+asD0LR5d3mxGpr2qVWXIUzJTSezeI=";
20 sparseCheckout = [ "cli" ];
21 };
22
23 modRoot = "./cli";
24
25 vendorHash = "sha256-Gg1mifMVt6Ma8yQ/t0R5nf6NXbzLZBpuZrYsW48p0mw=";
26
27 env.CGO_ENABLED = 0;
28
29 ldflags = [
30 "-s"
31 "-w"
32 "-X main.AppVersion=cli-v${finalAttrs.version}"
33 ];
34
35 nativeBuildInputs = [ installShellFiles ];
36
37 postInstall = ''
38 mv $out/bin/{cli,ente}
39 ''
40 # running ente results in the following errors:
41 # > mkdir /homeless-shelter: permission denied
42 # > error getting password from keyring: exec: "dbus-launch": executable file not found in $PATH
43 # fix by setting ENTE_CLI_CONFIG_PATH to $TMP and ENTE_CLI_SECRETS_PATH to a non existing path
44 # also guarding with `isLinux` because ENTE_CLI_SECRETS_PATH doesn't help on darwin:
45 # > error setting password in keyring: exit status 195
46 #
47 +
48 lib.optionalString
49 (stdenv.buildPlatform.isLinux && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
50 ''
51 export ENTE_CLI_CONFIG_PATH=$TMP
52 export ENTE_CLI_SECRETS_PATH=$TMP/secrets
53
54 installShellCompletion --cmd ente \
55 --bash <($out/bin/ente completion bash) \
56 --fish <($out/bin/ente completion fish) \
57 --zsh <($out/bin/ente completion zsh)
58 '';
59
60 passthru = {
61 # only works on linux, see comment above about ENTE_CLI_SECRETS_PATH on darwin
62 tests.version = lib.optionalAttrs stdenv.hostPlatform.isLinux (
63 testers.testVersion {
64 package = finalAttrs.finalPackage;
65 command = ''
66 env ENTE_CLI_CONFIG_PATH=$TMP \
67 ENTE_CLI_SECRETS_PATH=$TMP/secrets \
68 ente version
69 '';
70 version = "Version cli-v${finalAttrs.version}";
71 }
72 );
73 updateScript = nix-update-script {
74 extraArgs = [
75 "--version-regex"
76 "cli-(.+)"
77 ];
78 };
79 };
80
81 meta = {
82 description = "CLI client for downloading your data from Ente";
83 longDescription = ''
84 The Ente CLI is a Command Line Utility for exporting data from Ente. It also does a few more things, for example, you can use it to decrypting the export from Ente Auth.
85 '';
86 homepage = "https://github.com/ente-io/ente/tree/main/cli#readme";
87 changelog = "https://github.com/ente-io/ente/releases/tag/cli-v${finalAttrs.version}";
88 license = lib.licenses.agpl3Only;
89 maintainers = with lib.maintainers; [ zi3m5f ];
90 mainProgram = "ente";
91 };
92})