aboutsummaryrefslogtreecommitdiffstats
path: root/nix/package.nix
blob: 82a348b814c1a857e9f14406758c88ea3e7a39cc (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
# Atuin package definition
#
# This file will be similar to the package definition in nixpkgs:
#     https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/at/atuin/package.nix
#
# Helpful documentation: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md
{
  lib,
  stdenv,
  installShellFiles,
  rustPlatform,
  libiconv,
}:
rustPlatform.buildRustPackage {
  name = "turtle";

  src = lib.cleanSourceWith {
    src = lib.cleanSource ./..;
    filter = name: type:
      (type == "directory")
      || (builtins.elem (builtins.baseNameOf name) [
        "Cargo.toml"
        "Cargo.lock"
        "CONTRIBUTORS"

        "atuin.bash"
        "atuin.fish"
        "atuin.nu"
        "atuin.ps1"
        "atuin.xsh"
        "atuin.zsh"
      ])
      || (lib.strings.hasSuffix ".rs" (builtins.baseNameOf name))
      || (lib.strings.hasSuffix ".proto" (builtins.baseNameOf name))
      || (lib.strings.hasSuffix ".sql" (builtins.baseNameOf name));
  };

  cargoLock = {
    lockFile = ../Cargo.lock;
    # Allow dependencies to be fetched from git and avoid having to set the outputHashes manually
    allowBuiltinFetchGit = true;
  };

  nativeBuildInputs = [installShellFiles];

  buildInputs = lib.optionals stdenv.isDarwin [libiconv];

  postInstall = ''
    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)
  '';

  doCheck = false;

  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;
    mainProgram = "atuin";
  };
}