nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 nix-update-script,
6 nixosTests,
7 rustPlatform,
8 sonic-server,
9 testers,
10}:
11
12rustPlatform.buildRustPackage rec {
13 pname = "sonic-server";
14 version = "1.4.9";
15
16 src = fetchFromGitHub {
17 owner = "valeriansaliou";
18 repo = "sonic";
19 tag = "v${version}";
20 hash = "sha256-PTujR3ciLRvbpiqStNMx3W5fkUdW2dsGmCj/iFRTKJM=";
21 };
22
23 cargoHash = "sha256-RO4wY7FMwczZeR4GOxA3mwfBJZKPToOJJKGZb48yHJA=";
24
25 nativeBuildInputs = [
26 rustPlatform.bindgenHook
27 ];
28
29 postPatch = ''
30 substituteInPlace src/main.rs \
31 --replace-fail "./config.cfg" "$out/etc/sonic/config.cfg"
32 '';
33
34 postInstall = ''
35 install -Dm444 -t $out/etc/sonic config.cfg
36 install -Dm444 -t $out/lib/systemd/system debian/sonic.service
37
38 substituteInPlace $out/lib/systemd/system/sonic.service \
39 --replace-fail /usr/bin/sonic $out/bin/sonic \
40 --replace-fail /etc/sonic.cfg $out/etc/sonic/config.cfg
41 '';
42
43 # Found argument '--test-threads' which wasn't expected, or isn't valid in this context
44 doCheck = false;
45
46 passthru = {
47 tests = {
48 inherit (nixosTests) sonic-server;
49 version = testers.testVersion {
50 command = "sonic --version";
51 package = sonic-server;
52 };
53 };
54 updateScript = nix-update-script { };
55 };
56
57 meta = {
58 description = "Fast, lightweight and schema-less search backend";
59 homepage = "https://github.com/valeriansaliou/sonic";
60 changelog = "https://github.com/valeriansaliou/sonic/releases/tag/v${version}";
61 license = lib.licenses.mpl20;
62 platforms = lib.platforms.unix;
63 mainProgram = "sonic";
64 maintainers = with lib.maintainers; [
65 pleshevskiy
66 anthonyroussel
67 ];
68 };
69}