summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/du/dua/package.nix
blob: d2e09e88c2d12393728eeed029ef90a226cb5eb9 (plain)
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
{
  stdenv,
  lib,
  rustPlatform,
  fetchFromGitHub,
  versionCheckHook,
  nix-update-script,
  installShellFiles,
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "dua";
  version = "2.45.0";

  src = fetchFromGitHub {
    owner = "Byron";
    repo = "dua-cli";
    tag = "v${finalAttrs.version}";
    hash = "sha256-++7lCGXeam6C1FhULNpaj1Z4sZSYiu9GRZzEruiE4ho=";
    # Remove unicode file names which leads to different checksums on HFS+
    # vs. other filesystems because of unicode normalisation.
    postFetch = ''
      rm -r $out/tests/fixtures
    '';
  };

  cargoHash = "sha256-yw12S2Lvk7h7CJB5Sq/tS5qEZG+Gyft8OwPSnP0/35c=";

  checkFlags = [
    # Skip interactive tests
    "--skip=interactive::app::tests::journeys_readonly::quit_instantly_when_nothing_marked"
    "--skip=interactive::app::tests::journeys_readonly::quit_requires_two_presses_when_items_marked"
    "--skip=interactive::app::tests::journeys_readonly::once_allows_replayed_quit_to_exit stdout"
    "--skip=interactive::app::tests::journeys_readonly::simple_user_journey_read_only"
    "--skip=interactive::app::tests::journeys_with_writes::basic_user_journey_with_deletion"
    "--skip=interactive::app::tests::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels"
    "--skip=interactive::app::tests::unit::it_can_handle_ending_traversal_without_reaching_the_top"
  ];

  nativeInstallCheckInputs = [ versionCheckHook ];
  doInstallCheck = true;

  nativeBuildInputs = [ installShellFiles ];
  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    # TODO: Upstream also provides Elvish and PowerShell completions,
    # but `installShellCompletion` only has support for Bash, Zsh and Fish at the moment.
      installShellCompletion --cmd dua \
        --bash <($out/bin/dua completions bash) \
        --fish <($out/bin/dua completions fish) \
        --zsh  <($out/bin/dua completions zsh)
  '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Tool to conveniently learn about the disk usage of directories";
    homepage = "https://github.com/Byron/dua-cli";
    changelog = "https://github.com/Byron/dua-cli/blob/v${finalAttrs.version}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      killercup
      defelo
    ];
    mainProgram = "dua";
  };
})