summary refs log tree commit diff
path: root/pkgs/by-name/fo/fortune-kind/package.nix
blob: fe58b468b1f5e3c51583ef776816f8c8d06500f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ lib
, stdenv
, fetchFromGitHub
, rustPlatform
, darwin
, libiconv
, makeBinaryWrapper
, installShellFiles
, fortuneAlias ? true
}:

rustPlatform.buildRustPackage rec {
  pname = "fortune-kind";
  version = "0.1.7";

  src = fetchFromGitHub {
    owner = "cafkafk";
    repo = "fortune-kind";
    rev = "v${version}";
    hash = "sha256-txFboO7TdmwFm8BPP2onDJs1LSp4fXTwciIyAnC4Q04=";
  };

  cargoHash = "sha256-3HxkKE2cQK91dBTtrsNG9VDk0efo1Ci5VfaG3UjvLNU=";

  nativeBuildInputs = [ makeBinaryWrapper installShellFiles ];
  buildInputs = lib.optionals stdenv.isDarwin [ libiconv darwin.apple_sdk.frameworks.Security ];

  buildNoDefaultFeatures = true;

  MAN_OUT = "./man";

  preBuild = ''
    mkdir -p "./$MAN_OUT";
  '';

  preInstall = ''
    installManPage man/fortune-kind.1
    installShellCompletion \
      --fish man/fortune-kind.fish \
      --bash man/fortune-kind.bash \
      --zsh  man/_fortune-kind
    mkdir -p $out
    cp -r $src/fortunes $out/fortunes;
  '';

  postInstall = ''
    wrapProgram $out/bin/fortune-kind \
      --prefix FORTUNE_DIR : "$out/fortunes"
  ''+ lib.optionalString fortuneAlias ''
    ln -s fortune-kind $out/bin/fortune
  '';

  meta = with lib; {
    description = "A kinder, curated fortune, written in rust";
    longDescription = ''
      Historically, contributions to fortune-mod have had a less-than ideal
      quality control process, and as such, many of the fortunes that a user may
      receive from the program read more like cryptic inside jokes, or at the
      very worst, locker-room banter. One of the major goals of fortune-kind is
      defining and applying a somewhat more rigorous moderation and editing
      process to the fortune adoption workflow.
    '';
    homepage = "https://github.com/cafkafk/fortune-kind";
    changelog = "https://github.com/cafkafk/fortune-kind/releases/tag/v${version}";
    license = licenses.gpl3Only;
    mainProgram = "fortune-kind";
    maintainers = with maintainers; [ cafkafk ];
    platforms = platforms.unix ++ platforms.windows;
  };
}