Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 16.09 54 lines 1.5 kB view raw
1{ stdenv, R, libcxx, xvfb_run, utillinux, Cocoa, Foundation, gettext, gfortran }: 2 3{ name, buildInputs ? [], ... } @ attrs: 4 5stdenv.mkDerivation ({ 6 buildInputs = buildInputs ++ [R] ++ 7 stdenv.lib.optionals attrs.requireX [utillinux xvfb_run] ++ 8 stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gettext gfortran]; 9 10 NIX_CFLAGS_COMPILE = 11 stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; 12 13 configurePhase = '' 14 runHook preConfigure 15 export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library" 16 runHook postConfigure 17 ''; 18 19 buildPhase = '' 20 runHook preBuild 21 runHook postBuild 22 ''; 23 24 installFlags = if attrs.doCheck or true then 25 [] 26 else 27 [ "--no-test-load" ]; 28 29 rCommand = if attrs.requireX or false then 30 # Unfortunately, xvfb-run has a race condition even with -a option, so that 31 # we acquire a lock explicitly. 32 "flock ${xvfb_run} xvfb-run -a -e xvfb-error R" 33 else 34 "R"; 35 36 installPhase = '' 37 runHook preInstall 38 mkdir -p $out/library 39 $rCommand CMD INSTALL $installFlags --configure-args="$configureFlags" -l $out/library . 40 runHook postInstall 41 ''; 42 43 postFixup = '' 44 if test -e $out/nix-support/propagated-native-build-inputs; then 45 ln -s $out/nix-support/propagated-native-build-inputs $out/nix-support/propagated-user-env-packages 46 fi 47 ''; 48 49 checkPhase = '' 50 # noop since R CMD INSTALL tests packages 51 ''; 52} // attrs // { 53 name = "r-" + name; 54})