about summary refs log tree commit diff
path: root/pkgs/by-name/ni/nix-weather/package.nix
blob: 02f31ee19739e3e1e85f18288c0b22e51d07fdc3 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
  lib,
  stdenv,
  fetchFromGitHub,
  rustPlatform,
  pkg-config,
  openssl,
  darwin,
  libiconv,
  installShellFiles,
  nix-update-script,
}:

rustPlatform.buildRustPackage rec {
  pname = "nix-weather";
  version = "0.0.4";

  # fetch from GitHub and not upstream forgejo because cafkafk doesn't want to
  # pay for bandwidth
  src = fetchFromGitHub {
    owner = "cafkafk";
    repo = "nix-weather";
    rev = "v${version}";
    hash = "sha256-15FUA4fszbAVXop3IyOHfxroyTt9/SkWZsSTUh9RtwY=";
  };

  cargoHash = "sha256-vMeljXNWfFRyeQ4ZQ/Qe1vcW5bg5Y14aEH5HgEwOX3Q=";
  cargoExtraArgs = "-p nix-weather";

  nativeBuildInputs = [ pkg-config ];
  buildInputs =
    [
      openssl
      installShellFiles
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      libiconv
      darwin.apple_sdk.frameworks.Security
      darwin.apple_sdk.frameworks.SystemConfiguration
    ];

  outputs = [
    "out"
    "man"
  ];

  # This is where `build.rs` puts manpages
  MAN_OUT = "./man";

  postInstall = ''
    cd crates/nix-weather
    installManPage man/nix-weather.1
    installShellCompletion \
      --fish man/nix-weather.fish \
      --bash man/nix-weather.bash \
      --zsh  man/_nix-weather
    mkdir -p $out
    cd ../..
  '';

  # We are the only distro that will ever package this, thus ryanbot will not
  # be able to find updates through repology and we need this.
  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Check Cache Availablility of NixOS Configurations";
    longDescription = ''
      Fast rust tool to check availability of your entire system in caches. It
      so to speak "checks the weather" before going to update. Useful for
      debugging cache utilization and timing updates and deployments.

      Heavily inspired by guix weather.
    '';
    homepage = "https://git.fem.gg/cafkafk/nix-weather";
    changelog = "https://git.fem.gg/cafkafk/nix-weather/releases/tag/v${version}";
    license = licenses.eupl12;
    mainProgram = "nix-weather";
    maintainers = with maintainers; [
      cafkafk
      freyacodes
    ];
    platforms = platforms.all;
  };
}