diff --git a/pkgs/by-name/kd/kdlfmt/package.nix b/pkgs/by-name/kd/kdlfmt/package.nix index 2cd565874e0f..53bcc3f445a3 100644 --- a/pkgs/by-name/kd/kdlfmt/package.nix +++ b/pkgs/by-name/kd/kdlfmt/package.nix @@ -2,28 +2,50 @@ lib, rustPlatform, fetchFromGitHub, + stdenv, + installShellFiles, + versionCheckHook, + nix-update-script, }: -rustPlatform.buildRustPackage rec { +rustPlatform.buildRustPackage (finalAttrs: { pname = "kdlfmt"; - version = "0.1.0"; + version = "0.1.2"; src = fetchFromGitHub { owner = "hougesen"; repo = "kdlfmt"; - rev = "v${version}"; - hash = "sha256-qc2wU/borl3h2fop6Sav0zCrg8WdvHrB3uMA72uwPis="; + tag = "v${finalAttrs.version}"; + hash = "sha256-xDv93cxCEaBybexleyTtcCCKHy2OL3z/BG2gJ7uqIrU="; }; useFetchCargoVendor = true; - cargoHash = "sha256-xoOnFJqDucg3fUDx5XbXsZT4rSjZhzt5rNbH+DZ1kGA="; + cargoHash = "sha256-TwZ/0G3lTCoj01e/qGFRxJCfe4spOpG/55GKhoI0img="; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd kdlfmt \ + --bash <($out/bin/kdlfmt completions bash) \ + --fish <($out/bin/kdlfmt completions fish) \ + --zsh <($out/bin/kdlfmt completions zsh) + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru.updateScript = nix-update-script { }; meta = { description = "Formatter for kdl documents"; - homepage = "https://github.com/hougesen/kdlfmt.git"; - changelog = "https://github.com/hougesen/kdlfmt/blob/v${version}/CHANGELOG.md"; + homepage = "https://github.com/hougesen/kdlfmt"; + changelog = "https://github.com/hougesen/kdlfmt/blob/v${finalAttrs.version}/CHANGELOG.md"; license = lib.licenses.mit; - maintainers = with lib.maintainers; [ airrnot ]; + maintainers = with lib.maintainers; [ + airrnot + defelo + ]; mainProgram = "kdlfmt"; }; -} +})