nixpkgs/pkgs/tools/misc/fend/default.nix

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

92 lines
2.2 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, fetchFromGitHub
, rustPlatform
, darwin
2022-10-10 13:33:52 +01:00
, pandoc
2024-03-21 00:19:25 +00:00
, pkg-config
, openssl
2022-10-10 13:33:52 +01:00
, installShellFiles
2023-09-20 18:27:35 +01:00
, copyDesktopItems
, makeDesktopItem
2023-09-20 18:33:00 +01:00
, nix-update-script
2023-10-29 07:58:16 +00:00
, testers
, writeText
, runCommand
, fend
}:
2020-11-09 01:03:25 +00:00
rustPlatform.buildRustPackage rec {
pname = "fend";
2024-09-20 08:09:05 +01:00
version = "1.5.2";
2020-11-09 01:03:25 +00:00
src = fetchFromGitHub {
owner = "printfn";
2024-02-24 05:20:54 +00:00
repo = "fend";
2020-11-09 01:03:25 +00:00
rev = "v${version}";
2024-09-20 08:09:05 +01:00
hash = "sha256-ktCfIFSGXOqHfqFkXt2ZO8jZFGTRd8wTxukGLZD1PTU=";
2020-11-09 01:03:25 +00:00
};
2024-09-20 08:09:05 +01:00
cargoHash = "sha256-R5p7f+eEMDs0rs+45XNJC4znrJ9BrPBv5+dvMgoHFdA=";
2020-11-09 01:03:25 +00:00
2024-03-21 00:19:25 +00:00
nativeBuildInputs = [ pandoc installShellFiles pkg-config copyDesktopItems ];
buildInputs = [ pkg-config openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Security ];
2022-10-10 13:33:52 +01:00
postBuild = ''
patchShebangs --build ./documentation/build.sh
./documentation/build.sh
'';
preFixup = ''
installManPage documentation/fend.1
'';
doInstallCheck = true;
installCheckPhase = ''
[[ "$($out/bin/fend "1 km to m")" = "1000 m" ]]
'';
2023-09-20 18:27:35 +01:00
postInstall = ''
2024-02-24 05:20:54 +00:00
install -D -m 444 $src/icon/icon.svg $out/share/icons/hicolor/scalable/apps/fend.svg
2023-09-20 18:27:35 +01:00
'';
desktopItems = [
(makeDesktopItem {
name = "fend";
desktopName = "fend";
genericName = "Calculator";
comment = "Arbitrary-precision unit-aware calculator";
icon = "fend";
exec = "fend";
terminal = true;
categories = [ "Utility" "Calculator" "ConsoleOnly" ];
})
];
2023-10-29 07:58:16 +00:00
passthru = {
updateScript = nix-update-script { };
tests = {
version = testers.testVersion { package = fend; };
units = testers.testEqualContents {
assertion = "fend does simple math and unit conversions";
expected = writeText "expected" ''
36 kph
'';
actual = runCommand "actual" { } ''
${lib.getExe fend} '(100 meters) / (10 seconds) to kph' > $out
'';
};
};
};
2023-09-20 18:33:00 +01:00
2020-11-09 01:03:25 +00:00
meta = with lib; {
description = "Arbitrary-precision unit-aware calculator";
homepage = "https://github.com/printfn/fend";
2023-10-30 20:37:04 +00:00
changelog = "https://github.com/printfn/fend/releases/tag/v${version}";
2024-03-21 00:19:25 +00:00
license = licenses.mit;
2023-09-20 18:33:41 +01:00
maintainers = with maintainers; [ djanatyn liff ];
2023-09-20 18:27:09 +01:00
mainProgram = "fend";
2020-11-09 01:03:25 +00:00
};
}