about summary refs log tree commit diff stats
path: root/pkgs/by-name/at/atuin/package.nix
blob: 7f58697a3cf498c50a139129d5ba4c93fabe1518 (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
85
86
87
88
89
90
91
92
93
94
# This has been taken from nixpkgs at:
# https://github.com/NixOS/nixpkgs/blob/5785b6bb5eaae44e627d541023034e1601455827/pkgs/by-name/at/atuin/package.nix
# I have just removed some features and added a patch for dvorak input.
{
  lib,
  stdenv,
  fetchFromGitHub,
  installShellFiles,
  rustPlatform,
  libiconv,
  buildPackages,
  darwin,
  nixosTests,
}:
rustPlatform.buildRustPackage rec {
  pname = "atuin";
  version = "18.3.0";

  src = fetchFromGitHub {
    owner = "atuinsh";
    repo = "atuin";
    rev = "v${version}";
    hash = "sha256-Q3UI1IUD5Jz2O4xj3mFM7DqY3lTy3WhWYPa8QjJHTKE=";
  };

  # TODO: unify this to one hash because updater do not support this
  cargoHash =
    if stdenv.hostPlatform.isLinux
    then "sha256-K4Vw/d0ZOROWujWr76I3QvfKefLhXLeFufUrgStAyjQ="
    else "sha256-8NAfE7cGFT64ntNXK9RT0D/MbDJweN7vvsG/KlrY4K4=";

  patches = [
    ./set-dvorak-keybindings.patch
  ];

  # atuin's default features include 'check-updates', which do not make sense
  # for distribution builds. List all other default features.
  buildNoDefaultFeatures = true;
  buildFeatures = [
    "client"
    # "sync"
    # "server"
    "clipboard"
    # "daemon"
  ];

  nativeBuildInputs = [installShellFiles];

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    libiconv
    darwin.apple_sdk_11_0.frameworks.AppKit
    darwin.apple_sdk_11_0.frameworks.Security
    darwin.apple_sdk_11_0.frameworks.SystemConfiguration
  ];

  preBuild = ''
    export PROTOC=${buildPackages.protobuf}/bin/protoc
    export PROTOC_INCLUDE="${buildPackages.protobuf}/include";
  '';

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd atuin \
      --bash <($out/bin/atuin gen-completions -s bash) \
      --fish <($out/bin/atuin gen-completions -s fish) \
      --zsh <($out/bin/atuin gen-completions -s zsh)
  '';

  passthru.tests = {
    inherit (nixosTests) atuin;
  };

  # The checks don't compile without the `server` feature
  doCheck = false;
  checkFlags = [
    # tries to make a network access
    "--skip=registration"
    # No such file or directory (os error 2)
    "--skip=sync"
    # PermissionDenied (Operation not permitted)
    "--skip=change_password"
    "--skip=multi_user_test"
    "--skip=store::var::tests::build_vars"
    # Tries to touch files
    "--skip=build_aliases"
  ];

  meta = with lib; {
    description = "Replacement for a shell history which records additional commands context with optional encrypted synchronization between machines";
    homepage = "https://github.com/atuinsh/atuin";
    license = licenses.mit;
    maintainers = with maintainers; [SuperSandro2000 sciencentistguy _0x4A6F];
    mainProgram = "atuin";
  };
}