|
| 1 | +{ rev ? "c7e0e9ed5abd0043e50ee371129fcb8640264fc4" |
| 2 | +, sha256 ? "0c28mpvjhjc8kiwj2w8zcjsr2rayw989a1wnsqda71zpcyas3mq2" |
| 3 | +, pkgs ? import (builtins.fetchTarball { inherit sha256; |
| 4 | + url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; |
| 5 | + }) { } |
| 6 | + |
| 7 | +, stdenv ? if useClang |
| 8 | + then (if pkgs.stdenv.cc.isClang |
| 9 | + then pkgs.stdenv |
| 10 | + else pkgs.llvmPackages_latest.stdenv) |
| 11 | + else (if pkgs.stdenv.cc.isGNU |
| 12 | + then pkgs.stdenv |
| 13 | + else pkgs.gcc.stdenv) |
| 14 | +, lib ? pkgs.lib |
| 15 | + |
| 16 | +, debug ? false # Debug Build |
| 17 | +, useClang ? false # Use Clang over GCC |
| 18 | +, useJemalloc ? true # Use the Dynamic Memory Allocator |
| 19 | +, withGraphicsMagick ? true # Allow Media Thumbnails |
| 20 | +}: |
| 21 | + |
| 22 | +stdenv.mkDerivation rec { |
| 23 | + pname = "matrix-construct"; |
| 24 | + version = "development"; |
| 25 | + |
| 26 | + src = lib.cleanSource ./.; |
| 27 | + |
| 28 | + preAutoreconf = let |
| 29 | + VERSION_COMMIT_CMD = "git rev-parse --short HEAD"; |
| 30 | + VERSION_BRANCH_CMD = "git rev-parse --abbrev-ref HEAD"; |
| 31 | + VERSION_TAG_CMD = "git describe --tags --abbrev=0 --dirty --always"; |
| 32 | + VERSION_CMD = "git describe --tags --always"; |
| 33 | + runWithGit = id: cmd: lib.removeSuffix "\n" (builtins.readFile (pkgs.runCommandNoCCLocal "construct-${id}" { |
| 34 | + buildInputs = [ pkgs.git ]; |
| 35 | + } "cd ${./.} && ${cmd} > $out")); |
| 36 | + in '' |
| 37 | + substituteInPlace configure.ac --replace "${VERSION_COMMIT_CMD}" "echo ${runWithGit "version-commit" VERSION_COMMIT_CMD}" |
| 38 | + substituteInPlace configure.ac --replace "${VERSION_BRANCH_CMD}" "echo ${runWithGit "version-branch" VERSION_BRANCH_CMD}" |
| 39 | + substituteInPlace configure.ac --replace "${VERSION_TAG_CMD}" "echo ${runWithGit "version-tag" VERSION_TAG_CMD}" |
| 40 | + substituteInPlace configure.ac --replace "${VERSION_CMD}" "echo ${runWithGit "version" VERSION_CMD}" |
| 41 | + ''; |
| 42 | + |
| 43 | + configureFlags = [ |
| 44 | + "--enable-generic" |
| 45 | + "--with-custom-branding=nix" |
| 46 | + "--with-custom-version=dev" |
| 47 | + "--with-boost-libdir=${pkgs.boost.out}/lib" |
| 48 | + "--with-boost=${pkgs.boost.dev}" |
| 49 | + "--with-magic-file=${pkgs.file}/share/misc/magic.mgc" |
| 50 | + ] ++ lib.optional useJemalloc "--enable-jemalloc" |
| 51 | + ++ lib.optional withGraphicsMagick [ |
| 52 | + "--with-imagemagick-includes=${pkgs.graphicsmagick}/include/GraphicsMagick" |
| 53 | + ] ++ lib.optional debug "--with-log-level=DEBUG"; |
| 54 | + |
| 55 | + preBuild = '' |
| 56 | + make clean |
| 57 | + ''; |
| 58 | + |
| 59 | + enableParallelBuilding = true; |
| 60 | + |
| 61 | + nativeBuildInputs = with pkgs; [ |
| 62 | + autoreconfHook pkg-config |
| 63 | + ] ++ lib.optional useClang llvmPackages_latest.llvm |
| 64 | + ++ lib.optional useJemalloc jemalloc; |
| 65 | + buildInputs = with pkgs; [ |
| 66 | + libsodium openssl file boost gmp |
| 67 | + (rocksdb.overrideAttrs (super: rec { |
| 68 | + version = "5.16.6"; |
| 69 | + src = pkgs.fetchFromGitHub { |
| 70 | + owner = "facebook"; |
| 71 | + repo = "rocksdb"; |
| 72 | + rev = "v${version}"; |
| 73 | + sha256 = "0yy09myzbi99qdmh2c2mxlddr12pwxzh66ym1y6raaqglrsmax66"; |
| 74 | + }; |
| 75 | + cmakeFlags = builtins.map (f: if f == "-DWITH_TOOLS=0" then "-DWITH_TOOLS=1" else f) super.cmakeFlags; |
| 76 | + NIX_CFLAGS_COMPILE = "${super.NIX_CFLAGS_COMPILE} -Wno-error=redundant-move"; |
| 77 | + })) |
| 78 | + ] ++ lib.optional withGraphicsMagick graphicsmagick; |
| 79 | +} |
0 commit comments