Unverified Commit cf0bb40f authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

ente-cli: use finalAttrs pattern (#399553)

parents 8fc2f7bf ec76c85c
Loading
Loading
Loading
Loading
+19 −21
Original line number Diff line number Diff line
{
  lib,
  buildGoModule,
  ente-cli,
  fetchFromGitHub,
  installShellFiles,
  nix-update-script,
  stdenv,
  testers,
}:
let
  version = "0.2.3";

  canExecute = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in
buildGoModule {
buildGoModule (finalAttrs: {
  pname = "ente-cli";
  inherit version;
  version = "0.2.3";

  src = fetchFromGitHub {
    owner = "ente-io";
    repo = "ente";
    tag = "cli-v${version}";
    tag = "cli-v${finalAttrs.version}";
    hash = "sha256-qKMFoNtD5gH0Y+asD0LR5d3mxGpr2qVWXIUzJTSezeI=";
    sparseCheckout = [ "cli" ];
  };
@@ -34,7 +29,7 @@ buildGoModule {
  ldflags = [
    "-s"
    "-w"
    "-X main.AppVersion=cli-v${version}"
    "-X main.AppVersion=cli-v${finalAttrs.version}"
  ];

  nativeBuildInputs = [ installShellFiles ];
@@ -50,7 +45,10 @@ buildGoModule {
    # also guarding with `isLinux` because ENTE_CLI_SECRETS_PATH doesn't help on darwin:
    # > error setting password in keyring: exit status 195
    #
    + lib.optionalString (stdenv.buildPlatform.isLinux && canExecute) ''
    +
      lib.optionalString
        (stdenv.buildPlatform.isLinux && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
        ''
          export ENTE_CLI_CONFIG_PATH=$TMP
          export ENTE_CLI_SECRETS_PATH=$TMP/secrets

@@ -64,13 +62,13 @@ buildGoModule {
    # only works on linux, see comment above about ENTE_CLI_SECRETS_PATH on darwin
    tests.version = lib.optionalAttrs stdenv.hostPlatform.isLinux (
      testers.testVersion {
        package = ente-cli;
        package = finalAttrs.finalPackage;
        command = ''
          env ENTE_CLI_CONFIG_PATH=$TMP \
              ENTE_CLI_SECRETS_PATH=$TMP/secrets \
              ente version
        '';
        version = "Version cli-v${ente-cli.version}";
        version = "Version cli-v${finalAttrs.version}";
      }
    );
    updateScript = nix-update-script {
@@ -87,11 +85,11 @@ buildGoModule {
      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.
    '';
    homepage = "https://github.com/ente-io/ente/tree/main/cli#readme";
    changelog = "https://github.com/ente-io/ente/releases/tag/cli-v${version}";
    changelog = "https://github.com/ente-io/ente/releases/tag/cli-v${finalAttrs.version}";
    license = lib.licenses.agpl3Only;
    maintainers = [
      lib.maintainers.zi3m5f
    ];
    mainProgram = "ente";
  };
}
})