Files
muscl/nix/default.nix
h7x4 39fa228d1c
All checks were successful
Build and test / check (push) Successful in 1m30s
Build and test / build (push) Successful in 3m56s
Build and test / test (push) Successful in 2m55s
Build and test / check-license (push) Successful in 5m32s
Build and test / docs (push) Successful in 6m47s
flake.nix: build with crane for vm
2025-11-26 01:10:01 +09:00

42 lines
1.1 KiB
Nix

{
lib
, rustPlatform
, cargoToml
, cargoLock
, src
, installShellFiles
, useCrane ? false
, craneLib ? null
}:
let
mainProgram = (lib.head cargoToml.bin).name;
buildFunction = if useCrane then craneLib.buildPackage else rustPlatform.buildRustPackage;
cargoLock' = if useCrane then cargoLock else { lockFile = cargoLock; };
pname = if useCrane then "${cargoToml.package.name}-crane" else cargoToml.package.name;
in
buildFunction {
pname = pname;
version = cargoToml.package.version;
inherit src;
cargoLock = cargoLock';
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;
inherit mainProgram;
};
}