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