Files
donquota/nix/package.nix
2026-01-10 00:09:10 +09:00

43 lines
1003 B
Nix

{
lib
, rustPlatform
, stdenv
, buildPackages
, installShellFiles
, cargoToml
, cargoLock
, src
}:
rustPlatform.buildRustPackage {
pname = "donquota";
inherit (cargoToml.package) version;
inherit src;
cargoLock.lockFile = cargoLock;
buildType = "releaselto";
RUSTFLAGS = "-Zhigher-ranked-assumptions";
nativeBuildInputs = [ installShellFiles ];
postInstall = let
emulator = stdenv.hostPlatform.emulator buildPackages;
installShellCompletions = lib.mapCartesianProduct ({ shell, command }: ''
(
export PATH="$out/bin:$PATH"
"${emulator}" "${command}" --completions=${shell} > "$TMP/${command}.${shell}"
)
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/${command}.${shell}"
'') {
shell = [ "bash" "zsh" "fish" ];
command = [ "uquota" ];
};
in lib.concatStringsSep "\n" installShellCompletions;
meta = with lib; {
license = licenses.mit;
platforms = platforms.linux ++ platforms.darwin;
};
}