nixpkgs/pkgs/by-name/da/dasel/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.8 KiB
Nix
Raw Normal View History

{ lib
2024-09-08 12:34:45 +00:00
, stdenv
2020-11-04 20:21:54 +00:00
, buildGoModule
, fetchFromGitHub
2023-07-02 15:14:44 +00:00
, installShellFiles
2020-11-04 20:21:54 +00:00
}:
buildGoModule rec {
pname = "dasel";
2024-07-05 17:28:03 +00:00
version = "2.8.1";
2020-11-04 20:21:54 +00:00
src = fetchFromGitHub {
owner = "TomWright";
2021-11-10 21:26:25 +00:00
repo = "dasel";
2020-11-04 20:21:54 +00:00
rev = "v${version}";
2024-07-05 17:28:03 +00:00
hash = "sha256-vq4lRCsqD2hmQw0yH84Wji5LeJ/aiMGJJIyCDvATA+I=";
2020-11-04 20:21:54 +00:00
};
2024-06-28 15:14:45 +00:00
vendorHash = "sha256-edyFs5oURklkqsTF7JA1in3XteSBx/6YEVu4MjIcGN4=";
2020-11-04 20:21:54 +00:00
ldflags = [
2023-01-20 00:10:24 +00:00
"-s" "-w" "-X github.com/tomwright/dasel/v2/internal.Version=${version}"
];
2020-12-04 06:22:07 +00:00
2023-07-02 15:14:44 +00:00
nativeBuildInputs = [ installShellFiles ];
2024-09-08 12:34:45 +00:00
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
2023-07-02 15:14:44 +00:00
installShellCompletion --cmd dasel \
--bash <($out/bin/dasel completion bash) \
--fish <($out/bin/dasel completion fish) \
--zsh <($out/bin/dasel completion zsh)
'';
2024-09-08 12:34:45 +00:00
doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
2020-12-20 19:41:51 +00:00
installCheckPhase = ''
2022-12-07 01:22:46 +00:00
runHook preInstallCheck
if [[ $($out/bin/dasel --version) == "dasel version ${version}" ]]; then
echo '{ "my": { "favourites": { "colour": "blue" } } }' \
| $out/bin/dasel put -t json -r json -t string -v "red" "my.favourites.colour" \
| grep "red"
2020-12-20 19:41:51 +00:00
else
return 1
fi
2022-12-07 01:22:46 +00:00
runHook postInstallCheck
2020-12-20 19:41:51 +00:00
'';
meta = with lib; {
2020-11-04 20:21:54 +00:00
description = "Query and update data structures from the command line";
longDescription = ''
Dasel (short for data-selector) allows you to query and modify data structures using selector strings.
Comparable to jq / yq, but supports JSON, YAML, TOML and XML with zero runtime dependencies.
'';
homepage = "https://github.com/TomWright/dasel";
2021-11-10 21:26:25 +00:00
changelog = "https://github.com/TomWright/dasel/blob/v${version}/CHANGELOG.md";
2020-11-04 20:21:54 +00:00
license = licenses.mit;
2023-08-14 15:12:56 +00:00
mainProgram = "dasel";
2020-11-04 20:21:54 +00:00
maintainers = with maintainers; [ _0x4A6F ];
};
}