mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
6a9beaf893
This focuses on Rust packages, since the most commonly used argument parser library (clap/structopt) makes the following pattern natural and thus common: postInstall = '' installShellCompletion --cmd foo \ --bash <($out/bin/foo completion bash) \ … This commit just guards those with lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) splitting the string where unrelated actions are performed.
44 lines
1.1 KiB
Nix
44 lines
1.1 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, rustPlatform
|
|
, installShellFiles
|
|
, DiskArbitration
|
|
, Foundation
|
|
, Security
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "fnm";
|
|
version = "1.37.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "Schniz";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "sha256-x6w2g7U/FbJBycMAF4PUyaoIazp/w6imIpy+N7Cf0qk=";
|
|
};
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [ DiskArbitration Foundation Security ];
|
|
|
|
cargoHash = "sha256-b15m5DjTDNWJBHOaKSEMwkO/o+0mV+JMBDBurml7xOs=";
|
|
|
|
doCheck = false;
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd fnm \
|
|
--bash <($out/bin/fnm completions --shell bash) \
|
|
--fish <($out/bin/fnm completions --shell fish) \
|
|
--zsh <($out/bin/fnm completions --shell zsh)
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Fast and simple Node.js version manager";
|
|
mainProgram = "fnm";
|
|
homepage = "https://github.com/Schniz/fnm";
|
|
license = licenses.gpl3Only;
|
|
maintainers = with maintainers; [ kidonng ];
|
|
};
|
|
}
|