nixpkgs/pkgs/by-name/da/dasel/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

60 lines
1.8 KiB
Nix

{ lib
, stdenv
, buildGoModule
, fetchFromGitHub
, installShellFiles
}:
buildGoModule rec {
pname = "dasel";
version = "2.8.1";
src = fetchFromGitHub {
owner = "TomWright";
repo = "dasel";
rev = "v${version}";
hash = "sha256-vq4lRCsqD2hmQw0yH84Wji5LeJ/aiMGJJIyCDvATA+I=";
};
vendorHash = "sha256-edyFs5oURklkqsTF7JA1in3XteSBx/6YEVu4MjIcGN4=";
ldflags = [
"-s" "-w" "-X github.com/tomwright/dasel/v2/internal.Version=${version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd dasel \
--bash <($out/bin/dasel completion bash) \
--fish <($out/bin/dasel completion fish) \
--zsh <($out/bin/dasel completion zsh)
'';
doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
installCheckPhase = ''
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"
else
return 1
fi
runHook postInstallCheck
'';
meta = with lib; {
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";
changelog = "https://github.com/TomWright/dasel/blob/v${version}/CHANGELOG.md";
license = licenses.mit;
mainProgram = "dasel";
maintainers = with maintainers; [ _0x4A6F ];
};
}