Files
nixpkgs/pkgs/by-name/ya/yamlfmt/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

55 lines
1.2 KiB
Nix

{
lib,
buildGoModule,
fetchFromGitHub,
versionCheckHook,
}:
buildGoModule (finalAttrs: {
pname = "yamlfmt";
version = "0.17.2";
src = fetchFromGitHub {
owner = "google";
repo = "yamlfmt";
tag = "v${finalAttrs.version}";
hash = "sha256-WSw4WhWNyvkCwRCQYFAKhtkvOSSCrSlX3+i6cMHRtOQ=";
leaveDotGit = true;
postFetch = ''
git -C "$out" rev-parse --short HEAD > "$out/.git_head"
rm -rf "$out/.git"
'';
};
vendorHash = "sha256-Cy1eBvKkQ90twxjRL2bHTk1qNFLQ22uFrOgHKmnoUIQ=";
ldflags = [
"-s"
"-w"
"-X=main.version=${finalAttrs.version}"
];
preBuild = ''
ldflags+=" -X=main.commit=$(<.git_head)"
'';
# Test failure in vendored yaml package, see:
# https://github.com/google/yamlfmt/issues/256
checkFlags = [ "-run=!S/TestNodeRoundtrip" ];
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
versionCheckProgramArg = "--version";
meta = {
description = "Extensible command line tool or library to format yaml files";
homepage = "https://github.com/google/yamlfmt";
changelog = "https://github.com/google/yamlfmt/releases/tag/v${finalAttrs.version}";
license = lib.licenses.asl20;
maintainers = [ ];
mainProgram = "yamlfmt";
};
})