about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/search/sonic-server/default.nix
blob: 7d39d8cc759acd0819e7ea8269659710b9b905b4 (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
{ lib
, rustPlatform
, fetchFromGitHub
}:

rustPlatform.buildRustPackage {
  pname = "sonic-server";
  version = "1.4.0";

  src = fetchFromGitHub {
    owner = "valeriansaliou";
    repo = "sonic";
    rev = "f5302f5c424256648ba0be32b3c5909d846821fe";
    sha256 = "sha256-WebEluXijgJckZQOka2BDPYn7PqzPTsIcV2T380fxW8=";
  };

  cargoSha256 = "sha256-ObhKGjaIma6fUVUT3xadpy/GPYlnm0nKmRVxFmoePyQ=";

  doCheck = false;

  nativeBuildInputs = [
    rustPlatform.bindgenHook
  ];

  postPatch = ''
    substituteInPlace src/main.rs --replace "./config.cfg" "$out/etc/sonic/config.cfg"
  '';

  postInstall = ''
    mkdir -p $out/etc/
    mkdir -p $out/usr/lib/systemd/system/

    install -Dm444 -t $out/etc/sonic config.cfg
    substitute \
      ./examples/config/systemd.service $out/usr/lib/systemd/system/sonic-server.service \
      --replace /bin/sonic $out/bin/sonic \
      --replace /etc/sonic.cfg $out/etc/sonic/config.cfg
  '';

  meta = with lib; {
    description = "Fast, lightweight and schema-less search backend";
    homepage = "https://github.com/valeriansaliou/sonic";
    license = licenses.mpl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ pleshevskiy ];
  };
}