]> Untitled Git - lemmy.git/blob - default.nix
2cb1b9cf17c49893ad3d9d1040dacca2b9940ac7
[lemmy.git] / default.nix
1 { lib, stdenv, rustPlatform, fetchFromGitHub, openssl, postgresql, libiconv
2 , Security, protobuf, rustfmt, nixosTests, lemmy-translations }:
3
4 rustPlatform.buildRustPackage rec {
5   version = "0.18.4";
6   pname = "lemmy-server";
7
8   src = ./.;
9
10   preConfigure = ''
11     echo 'pub const VERSION: &str = "${version}";' > crates/utils/src/version.rs
12   '';
13
14   preBuild = ''
15     ln -sf ${lemmy-translations} crates/utils/translations
16   '';
17
18   cargoSha256 = "sha256-NPGKXA7S/pk13z9defahDuVAm3u444rLUGa+JhPxkfA=";
19
20   buildInputs = [ postgresql ]
21     ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
22
23   # Using OPENSSL_NO_VENDOR is not an option on darwin
24   # As of version 0.10.35 rust-openssl looks for openssl on darwin
25   # with a hardcoded path to /usr/lib/libssl.x.x.x.dylib
26   # https://github.com/sfackler/rust-openssl/blob/master/openssl-sys/build/find_normal.rs#L115
27   OPENSSL_LIB_DIR = "${lib.getLib openssl}/lib";
28   OPENSSL_INCLUDE_DIR = "${openssl.dev}/include";
29
30   PROTOC = "${protobuf}/bin/protoc";
31   PROTOC_INCLUDE = "${protobuf}/include";
32   nativeBuildInputs = [ protobuf rustfmt ];
33
34   passthru.tests.lemmy-server = nixosTests.lemmy;
35
36   meta = with lib; {
37     description = "🐀 Building a federated alternative to reddit in rust";
38     homepage = "https://join-lemmy.org/";
39     license = licenses.agpl3Only;
40     maintainers = with maintainers; [ happysalada billewanick ];
41     mainProgram = "lemmy_server";
42   };
43 }