Unverified Commit bf4cdb20 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

volta: cleanup (#382001)

parents a6015afd 6a8151a2
Loading
Loading
Loading
Loading
+38 −22
Original line number Diff line number Diff line
{
  lib,
  rustPlatform,
  libiconv,
  stdenv,
  installShellFiles,
  darwin,
  rustPlatform,
  fetchFromGitHub,
  installShellFiles,
  buildPackages,
  writableTmpDirAsHomeHook,
  versionCheckHook,
  nix-update-script,
}:
rustPlatform.buildRustPackage rec {
  pname = "volta";
@@ -21,22 +23,35 @@ rustPlatform.buildRustPackage rec {
  useFetchCargoVendor = true;
  cargoHash = "sha256-xlqsubkaX2A6d5MIcGf9E0b11Gzneksgku0jvW+UdbE=";

  buildInputs =
    [ installShellFiles ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      darwin.apple_sdk.frameworks.Security
      libiconv
    ];

  HOME = "$TMPDIR";
  buildInputs = [ installShellFiles ];

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
  postInstall =
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    ''
      installShellCompletion --cmd volta \
      --bash <($out/bin/volta completions bash) \
      --fish <($out/bin/volta completions fish) \
      --zsh <($out/bin/volta completions zsh)
        --bash <(${emulator} $out/bin/volta completions bash) \
        --fish <(${emulator} $out/bin/volta completions fish) \
        --zsh <(${emulator} $out/bin/volta completions zsh)
    '';
  meta = with lib; {

  nativeCheckInputs = [
    writableTmpDirAsHomeHook
  ];

  nativeInstallCheckInputs = [
    versionCheckHook
  ];
  versionCheckProgramArg = [ "--version" ];
  # Tries to create /var/empty/.volta as $HOME is not writable
  doInstallCheck = !stdenv.hostPlatform.isDarwin;

  passthru = {
    updateScript = nix-update-script { };
  };

  meta = {
    description = "Hassle-Free JavaScript Tool Manager";
    longDescription = ''
      With Volta, you can select a Node engine once and then stop worrying
@@ -50,7 +65,8 @@ rustPlatform.buildRustPackage rec {
    '';
    homepage = "https://volta.sh/";
    changelog = "https://github.com/volta-cli/volta/blob/main/RELEASES.md";
    license = with licenses; [ bsd2 ];
    maintainers = with maintainers; [ fbrs ];
    license = with lib.licenses; [ bsd2 ];
    maintainers = with lib.maintainers; [ fbrs ];
    mainProgram = "volta";
  };
}