-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
114 lines (97 loc) · 3.19 KB
/
default.nix
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{ nixpkgs ? import <nixpkgs> {}
, lib ? nixpkgs.lib
, pkgconfig ? nixpkgs.pkgconfig
, cmake ? nixpkgs.cmake
, pkgs ? nixpkgs
, gitHash
, gitDescribe
}:
let
##
# Use the stdenv of pkgs, so we get the static compiler.
##
stdenv = pkgs.stdenv;
isStatic = stdenv.hostPlatform.isStatic;
xlibressl = (pkgs.libressl.override {
inherit cmake;
}).overrideAttrs(old: rec {
# Fixes build issues on Windows
cmakeFlags = lib.remove "-DENABLE_NC=ON" old.cmakeFlags;
outputs = lib.remove "nc" old.outputs;
});
xcurlFull = (pkgs.curlFull.override {
openssl = xlibressl;
libssh2 = pkgs.libssh2.override { openssl = xlibressl; };
nghttp2 = pkgs.nghttp2.override { openssl = xlibressl; };
http2Support = true;
idnSupport = !stdenv.hostPlatform.isWindows;
zlibSupport = true;
sslSupport = true;
scpSupport = true;
c-aresSupport = !stdenv.hostPlatform.isWindows;
ldapSupport = false;
gnutlsSupport = false;
wolfsslSupport = false;
gssSupport = false;
brotliSupport = false;
}).overrideAttrs(old: rec {
configureFlags = old.configureFlags ++ [
"--disable-file" "--disable-ldap" "--disable-ldaps"
"--disable-rtsp" "--disable-proxy" "--disable-dict"
"--disable-telnet" "--disable-pop3" "--disable-imap"
"--disable-smb" "--disable-smtp" "--disable-cookies"
"--disable-openssl-auto-load-config"
"--without-ca-bundle" "--without-ca-path"
]
++ lib.optionals stdenv.hostPlatform.isWindows [
"--with-winidn"
];
NIX_CFLAGS_COMPILE = lib.optionals isStatic ["-DNGHTTP2_STATICLIB"];
});
xuriparser = pkgs.uriparser.overrideDerivation(old: {
nativeBuildInputs = [ cmake ];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=${if isStatic then "OFF" else "ON"}"
"-DURIPARSER_BUILD_DOCS=OFF"
"-DURIPARSER_BUILD_TESTS=OFF" # gtest breaks when building statically
"-DURIPARSER_BUILD_TOOLS=OFF"
"-DURIPARSER_ENABLE_INSTALL=ON"
];
});
in
stdenv.mkDerivation rec {
inherit xlibressl;
inherit xcurlFull;
inherit xuriparser;
pname = "nimrodg-agent";
version = gitDescribe;
src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
nativeBuildInputs = [ nixpkgs.gitMinimal pkgconfig cmake ];
buildInputs = [ xlibressl.dev xcurlFull.dev xuriparser ];
##
# Nimrod's always used -pc, not -unknown. I'm not game to change it.
##
platformString = with stdenv.hostPlatform; if parsed.vendor.name == "unknown" then
"${parsed.cpu.name}-pc-${parsed.kernel.name}-${parsed.abi.name}"
else
config;
cmakeFlags = [
"-DNIMRODG_PLATFORM_STRING=${platformString}"
"-DUSE_LTO=ON"
"-DCMAKE_BUILD_TYPE=MinSizeRel"
"-DOPENSSL_USE_STATIC_LIBS=${if isStatic then "ON" else "OFF"}"
"-DLIBCURL_USE_STATIC_LIBS=${if isStatic then "ON" else "OFF"}"
"-DGIT_HASH=${gitHash}"
];
enableParallelBuilding = true;
installPhase = ''
mkdir -p "$out/bin"
cp bin/agent-* "$out/bin"
'';
meta = with lib; {
description = "Nimrod/G Agent";
homepage = "https://rcc.uq.edu.au/nimrod";
platforms = platforms.all;
license = licenses.asl20;
};
}