mysqladm-rs/nix/default.nix

36 lines
916 B
Nix
Raw Permalink Normal View History

{
lib
, rustPlatform
, cargoToml
, cargoLock
, src
2024-08-19 02:22:18 +02:00
, installShellFiles
}:
let
2024-08-19 02:22:18 +02:00
mainProgram = (lib.head cargoToml.bin).name;
in
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
inherit src;
cargoLock.lockFile = cargoLock;
2024-08-19 02:22:18 +02:00
nativeBuildInputs = [ installShellFiles ];
postInstall = let
commands = lib.mapCartesianProduct ({ shell, command }: ''
"$out/bin/${mainProgram}" generate-completions --shell "${shell}" --command "${command}" > "$TMP/mysqladm.${shell}"
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/mysqladm.${shell}"
'') {
shell = [ "bash" "zsh" "fish" ];
command = [ "mysqladm" "mysql-dbadm" "mysql-useradm" ];
};
in lib.concatStringsSep "\n" commands;
meta = with lib; {
license = licenses.mit;
platforms = platforms.linux ++ platforms.darwin;
2024-08-19 02:22:18 +02:00
inherit mainProgram;
};
}