nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 rustPlatform,
5 pandoc,
6 pkg-config,
7 openssl,
8 installShellFiles,
9 copyDesktopItems,
10 makeDesktopItem,
11 nix-update-script,
12 testers,
13 writeText,
14 runCommand,
15 fend,
16}:
17
18rustPlatform.buildRustPackage (finalAttrs: {
19 pname = "fend";
20 version = "1.5.8";
21
22 src = fetchFromGitHub {
23 owner = "printfn";
24 repo = "fend";
25 tag = "v${finalAttrs.version}";
26 hash = "sha256-XIdz7s8DCmXSeFIC06C+/wLDyMBcqIrjDSQUAhxX72s=";
27 };
28
29 cargoHash = "sha256-mDsAZvnBGXhEl2Qbww2svPznl6k9b44zGdMkeejIWVU=";
30
31 nativeBuildInputs = [
32 pandoc
33 installShellFiles
34 pkg-config
35 copyDesktopItems
36 ];
37
38 buildInputs = [
39 pkg-config
40 openssl
41 ];
42
43 postBuild = ''
44 patchShebangs --build ./documentation/build.sh
45 ./documentation/build.sh
46 '';
47
48 preFixup = ''
49 installManPage documentation/fend.1
50 '';
51
52 doInstallCheck = true;
53
54 installCheckPhase = ''
55 [[ "$($out/bin/fend "1 km to m")" = "1000 m" ]]
56 '';
57
58 postInstall = ''
59 install -D -m 444 $src/icon/icon.svg $out/share/icons/hicolor/scalable/apps/fend.svg
60 '';
61
62 desktopItems = [
63 (makeDesktopItem {
64 name = "fend";
65 desktopName = "fend";
66 genericName = "Calculator";
67 comment = "Arbitrary-precision unit-aware calculator";
68 icon = "fend";
69 exec = "fend";
70 terminal = true;
71 categories = [
72 "Utility"
73 "Calculator"
74 "ConsoleOnly"
75 ];
76 })
77 ];
78
79 passthru = {
80 updateScript = nix-update-script { };
81 tests = {
82 version = testers.testVersion { package = fend; };
83 units = testers.testEqualContents {
84 assertion = "fend does simple math and unit conversions";
85 expected = writeText "expected" ''
86 36 kph
87 '';
88 actual = runCommand "actual" { } ''
89 ${lib.getExe fend} '(100 meters) / (10 seconds) to kph' > $out
90 '';
91 };
92 };
93 };
94
95 meta = {
96 description = "Arbitrary-precision unit-aware calculator";
97 homepage = "https://github.com/printfn/fend";
98 changelog = "https://github.com/printfn/fend/releases/tag/${finalAttrs.src.tag}";
99 license = lib.licenses.mit;
100 maintainers = with lib.maintainers; [
101 djanatyn
102 liff
103 ];
104 mainProgram = "fend";
105 };
106})