forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
43 lines (34 loc) · 1.09 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
# Run like this:
# nix-build /path/to/this/directory
# ... and the files are produced in ./result/bin/snabb
{ pkgs ? (import <nixpkgs> {})
, source ? ./.
, version ? "dev"
, supportOpenstack ? true
}:
with pkgs;
stdenv.mkDerivation rec {
name = "snabb-${version}";
inherit version;
src = lib.cleanSource source;
buildInputs = [ makeWrapper ];
patchPhase = ''
patchShebangs .
# some hardcodeism
for f in $(find src/program/snabbnfv/ -type f); do
substituteInPlace $f --replace "/bin/bash" "${bash}/bin/bash"
done
'' + lib.optionalString supportOpenstack ''
# We need a way to pass $PATH to the scripts
sed -i '2iexport PATH=${git}/bin:${mariadb}/bin:${which}/bin:${procps}/bin:${coreutils}/bin' src/program/snabbnfv/neutron_sync_master/neutron_sync_master.sh.inc
sed -i '2iexport PATH=${git}/bin:${coreutils}/bin:${diffutils}/bin:${nettools}/bin' src/program/snabbnfv/neutron_sync_agent/neutron_sync_agent.sh.inc
'';
preBuild = ''
make clean
'';
installPhase = ''
mkdir -p $out/bin
cp src/snabb $out/bin
'';
enableParallelBuilding = true;
}