2022-03-30 09:31:56 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, darwin
|
2022-10-21 18:38:19 +00:00
|
|
|
, pandoc
|
2024-04-21 15:54:59 +00:00
|
|
|
, pkg-config
|
|
|
|
, openssl
|
2022-10-21 18:38:19 +00:00
|
|
|
, installShellFiles
|
2023-10-09 19:29:22 +00:00
|
|
|
, copyDesktopItems
|
|
|
|
, makeDesktopItem
|
|
|
|
, nix-update-script
|
2024-01-02 11:29:13 +00:00
|
|
|
, testers
|
|
|
|
, writeText
|
|
|
|
, runCommand
|
|
|
|
, fend
|
2022-03-30 09:31:56 +00:00
|
|
|
}:
|
2020-11-12 09:05:59 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "fend";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "1.5.0";
|
2020-11-12 09:05:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "printfn";
|
2024-02-29 20:09:43 +00:00
|
|
|
repo = "fend";
|
2020-11-12 09:05:59 +00:00
|
|
|
rev = "v${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-owWBbeZtkjLiMYnXB5d4PfFX4i5BWo0OOnWd3C02VLE=";
|
2020-11-12 09:05:59 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
cargoHash = "sha256-pxy6TPDvAnbXJ6QMxWUCwVeWVzKmvwYxysJWhZpeVvI=";
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeBuildInputs = [ pandoc installShellFiles pkg-config copyDesktopItems ];
|
|
|
|
buildInputs = [ pkg-config openssl ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
|
2021-02-16 17:04:54 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
postBuild = ''
|
|
|
|
patchShebangs --build ./documentation/build.sh
|
|
|
|
./documentation/build.sh
|
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
installManPage documentation/fend.1
|
|
|
|
'';
|
|
|
|
|
2021-02-16 17:04:54 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
|
|
installCheckPhase = ''
|
|
|
|
[[ "$($out/bin/fend "1 km to m")" = "1000 m" ]]
|
|
|
|
'';
|
2020-11-12 09:05:59 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
postInstall = ''
|
2024-02-29 20:09:43 +00:00
|
|
|
install -D -m 444 $src/icon/icon.svg $out/share/icons/hicolor/scalable/apps/fend.svg
|
2023-10-09 19:29:22 +00: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" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-01-02 11:29:13 +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-10-09 19:29:22 +00:00
|
|
|
|
2020-11-12 09:05:59 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Arbitrary-precision unit-aware calculator";
|
|
|
|
homepage = "https://github.com/printfn/fend";
|
2024-01-02 11:29:13 +00:00
|
|
|
changelog = "https://github.com/printfn/fend/releases/tag/v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
license = licenses.mit;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ djanatyn liff ];
|
|
|
|
mainProgram = "fend";
|
2020-11-12 09:05:59 +00:00
|
|
|
};
|
|
|
|
}
|