From ea6e048c37eff63e057f767410acd8fc911ba078 Mon Sep 17 00:00:00 2001 From: Daniël de Kok Date: Thu, 12 Mar 2020 12:29:31 +0100 Subject: buildRustCrate: only link build deps into build script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the Cargo documentation: > The build script does not have access to the dependencies listed in > the dependencies or dev-dependencies section (they’re not built > yet!). Also, build dependencies are not available to the package > itself unless also explicitly added in the [dependencies] table. https://doc.rust-lang.org/cargo/reference/build-scripts.html This change separates linkage of regular dependencies and build dependencies. --- .../rust/build-rust-crate/configure-crate.nix | 63 ++++++++++++++++------ pkgs/build-support/rust/build-rust-crate/lib.sh | 1 + .../rust/build-rust-crate/test/default.nix | 30 +++++++++++ 3 files changed, 79 insertions(+), 15 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 013b99a77b4b..2f7d3b77f397 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -56,32 +56,66 @@ in '' i=$1 ln -s -f $i/lib/*.rlib $2 #*/ ln -s -f $i/lib/*.so $i/lib/*.dylib $2 #*/ - if [ -e "$i/lib/link" ]; then - cat $i/lib/link >> target/link - cat $i/lib/link >> target/link.final - fi if [ -e $i/env ]; then source $i/env fi } + # The following steps set up the dependencies of the crate. Two + # kinds of dependencies are distinguished: build dependencies + # (used by the build script) and crate dependencies. For each + # dependency we have to: + # + # - Make its Rust library available to rustc. This is done by + # symlinking all library dependencies into a directory that + # can be provided to rustc. + # - Accumulate linking flags. These flags are largely used for + # linking native libraries. + # + # The crate link flags are added to the `link` and `link.final` + # files. The `link` file is used for linkage in the current + # crate. The `link.final` file will be copied to the output and can + # be used by downstream crates to get the linker flags of this + # crate. + mkdir -p target/{deps,lib,build,buildDeps} chmod uga+w target -R echo ${extraLinkFlags} > target/link echo ${extraLinkFlags} > target/link.final + + # Prepare crate dependencies for i in ${completeDepsDir}; do symlink_dependency $i target/deps + if [ -e "$i/lib/link" ]; then + cat $i/lib/link >> target/link + cat $i/lib/link >> target/link.final + fi done + + # Prepare crate build dependencies that are used for the build script. for i in ${completeBuildDepsDir}; do - symlink_dependency $i target/buildDeps + symlink_dependency $i target/buildDeps + if [ -e "$i/lib/link" ]; then + cat $i/lib/link >> target/link.build + fi done - if [[ -e target/link ]]; then - sort -u target/link > target/link.sorted - mv target/link.sorted target/link - sort -u target/link.final > target/link.final.sorted - mv target/link.final.sorted target/link.final - tr '\n' ' ' < target/link > target/link_ + + # Remove duplicate linker flags from the build dependencies. + if [[ -e target/link.build ]]; then + sort -u target/link.build > target/link.build.sorted + mv target/link.build.sorted target/link.build fi + + # Remove duplicate linker flags from the dependencies. + sort -u target/link > target/link.sorted + mv target/link.sorted target/link + tr '\n' ' ' < target/link > target/link_ + + # Remove duplicate linker flags from the that are written + # to the derivation's output. + sort -u target/link.final > target/link.final.sorted + mv target/link.final.sorted target/link.final + EXTRA_BUILD="" BUILD_OUT_DIR="" export CARGO_PKG_NAME=${crateName} @@ -120,15 +154,14 @@ in '' elif [[ -e "build.rs" ]]; then BUILD="build.rs" fi + + # Compile and run the build script, when available. if [[ ! -z "$BUILD" ]] ; then echo_build_heading "$BUILD" ${libName} mkdir -p target/build/${crateName} EXTRA_BUILD_FLAGS="" - if [ -e target/link_ ]; then - EXTRA_BUILD_FLAGS=$(cat target/link_) - fi if [ -e target/link.build ]; then - EXTRA_BUILD_FLAGS="$EXTRA_BUILD_FLAGS $(cat target/link.build)" + EXTRA_BUILD_FLAGS="$EXTRA_BUILD_FLAGS $(tr '\n' ' ' < target/link.build)" fi noisily rustc --crate-name build_script_build $BUILD --crate-type bin ${rustcOpts} \ ${crateFeatures} --out-dir target/build/${crateName} --emit=dep-info,link \ diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh index 0f08c133e557..5843ee98b0d5 100644 --- a/pkgs/build-support/rust/build-rust-crate/lib.sh +++ b/pkgs/build-support/rust/build-rust-crate/lib.sh @@ -79,6 +79,7 @@ build_bin_test_file() { build_bin_test "$derived_crate_name" "$file" } +# Add additional link options that were provided by the build script. setup_link_paths() { EXTRA_LIB="" if [[ -e target/link_ ]]; then diff --git a/pkgs/build-support/rust/build-rust-crate/test/default.nix b/pkgs/build-support/rust/build-rust-crate/test/default.nix index 710045664686..f24583c41fcb 100644 --- a/pkgs/build-support/rust/build-rust-crate/test/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/test/default.nix @@ -207,6 +207,36 @@ let }) ]; }; + buildScriptDeps = let + depCrate = boolVal: mkCrate { + crateName = "bar"; + src = mkFile "src/lib.rs" '' + pub const baz: bool = ${boolVal}; + ''; + }; + in { + crateName = "foo"; + src = symlinkJoin { + name = "build-script-and-main"; + paths = [ + (mkFile "src/main.rs" '' + extern crate bar; + #[cfg(test)] + #[test] + fn baz_false() { assert!(!bar::baz); } + fn main() { } + '') + (mkFile "build.rs" '' + extern crate bar; + fn main() { assert!(bar::baz); } + '') + ]; + }; + buildDependencies = [ (depCrate "true") ]; + dependencies = [ (depCrate "false") ]; + buildTests = true; + expectedTestOutputs = [ "test baz_false ... ok" ]; + }; # Regression test for https://github.com/NixOS/nixpkgs/issues/74071 # Whenevever a build.rs file is generating files those should not be overlayed onto the actual source dir buildRsOutDirOverlay = { -- cgit 1.4.1 From 412c72d20f067dfb45aaa041c2333fbdc82dca6d Mon Sep 17 00:00:00 2001 From: Daniël de Kok Date: Fri, 13 Mar 2020 11:21:07 +0100 Subject: buildRustCrate: sort linker options in-place --- pkgs/build-support/rust/build-rust-crate/configure-crate.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 2f7d3b77f397..61c39c6b21c0 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -102,19 +102,16 @@ in '' # Remove duplicate linker flags from the build dependencies. if [[ -e target/link.build ]]; then - sort -u target/link.build > target/link.build.sorted - mv target/link.build.sorted target/link.build + sort -uo target/link.build target/link.build fi # Remove duplicate linker flags from the dependencies. - sort -u target/link > target/link.sorted - mv target/link.sorted target/link + sort -uo target/link target/link tr '\n' ' ' < target/link > target/link_ # Remove duplicate linker flags from the that are written # to the derivation's output. - sort -u target/link.final > target/link.final.sorted - mv target/link.final.sorted target/link.final + sort -uo target/link.final target/link.final EXTRA_BUILD="" BUILD_OUT_DIR="" -- cgit 1.4.1 From 2d2de743d0ece3931c01a04043c218b76dfc5cf6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 14 Mar 2020 19:28:24 +0100 Subject: emacs: improve setup hook - Add packages installed in a sub-directory of site-lisp, such as mu4e, to EMACSLOADPATH. - Add ELPA packages to EMACSLOADPATH. - Add each package only once to EMACSLOADPATH. Before, each package would typically be added twice for each transitive dependency leading to a huge variable for a package having many dependencies. Fixed #78680 --- pkgs/build-support/emacs/setup-hook.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/emacs/setup-hook.sh b/pkgs/build-support/emacs/setup-hook.sh index b210511d670d..8f074e0b406c 100644 --- a/pkgs/build-support/emacs/setup-hook.sh +++ b/pkgs/build-support/emacs/setup-hook.sh @@ -1,13 +1,25 @@ addEmacsVars () { - if test -d $1/share/emacs/site-lisp; then - # it turns out, that the trailing : is actually required + for lispDir in \ + "$1/share/emacs/site-lisp" \ + "$1/share/emacs/site-lisp/"* \ + "$1/share/emacs/site-lisp/elpa/"*; do + # Add the path to the Emacs load path if it is a directory + # containing .el files and it has not already been added to the + # load path. + if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then + # It turns out, that the trailing : is actually required # see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html - export EMACSLOADPATH="$1/share/emacs/site-lisp:${EMACSLOADPATH-}" - fi + export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}" + fi + done } -# If this is for a wrapper derivation, emacs and the dependencies are all -# run-time dependencies. If this is for precompiling packages into bytecode, -# emacs is a compile-time dependency of the package. -addEnvHooks "$hostOffset" addEmacsVars -addEnvHooks "$targetOffset" addEmacsVars +if [[ ! -v emacsHookDone ]]; then + emacsHookDone=1 + + # If this is for a wrapper derivation, emacs and the dependencies are all + # run-time dependencies. If this is for precompiling packages into bytecode, + # emacs is a compile-time dependency of the package. + addEnvHooks "$hostOffset" addEmacsVars + addEnvHooks "$targetOffset" addEmacsVars +fi -- cgit 1.4.1 From bc054004ac04b2500247c2efe504e6b3da444e61 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 18 Mar 2020 11:28:52 -0400 Subject: cc-wrapper, clang: `libstdcxxHook` should a propagated build input Lumping it in with the target platform libraries was incorrect, and caused eval failures when gcc couldn't be built for the target platform. --- pkgs/build-support/cc-wrapper/default.nix | 4 ++-- pkgs/development/compilers/llvm/5/default.nix | 4 +++- pkgs/development/compilers/llvm/6/default.nix | 4 +++- pkgs/development/compilers/llvm/7/default.nix | 4 +++- pkgs/development/compilers/llvm/8/default.nix | 4 +++- pkgs/development/compilers/llvm/9/default.nix | 4 +++- 6 files changed, 17 insertions(+), 7 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index b078bf2fbbd3..b7c5ea6e20f2 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -10,7 +10,7 @@ , cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" , propagateDoc ? cc != null && cc ? man -, extraPackages ? [], extraBuildCommands ? "" +, extraTools ? [], extraPackages ? [], extraBuildCommands ? "" , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , buildPackages ? {} , libcxx ? null @@ -212,7 +212,7 @@ stdenv.mkDerivation { ''; strictDeps = true; - propagatedBuildInputs = [ bintools ]; + propagatedBuildInputs = [ bintools ] ++ extraTools; depsTargetTargetPropagated = extraPackages; wrapperName = "CC_WRAPPER"; diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix index fd4aaa363bf4..3c1b07e7ca70 100644 --- a/pkgs/development/compilers/llvm/5/default.nix +++ b/pkgs/development/compilers/llvm/5/default.nix @@ -50,8 +50,10 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ + extraTools = [ libstdcxxHook + ]; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index 85bb00d80c76..ba704f972c31 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -50,8 +50,10 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ + extraTools = [ libstdcxxHook + ]; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix index 816649e62ad3..5124a5df00b3 100644 --- a/pkgs/development/compilers/llvm/7/default.nix +++ b/pkgs/development/compilers/llvm/7/default.nix @@ -57,8 +57,10 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ + extraTools = [ libstdcxxHook + ]; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix index d604dda5fe5e..105011595c8b 100644 --- a/pkgs/development/compilers/llvm/8/default.nix +++ b/pkgs/development/compilers/llvm/8/default.nix @@ -57,8 +57,10 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ + extraTools = [ libstdcxxHook + ]; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix index 11e44b8bdfaa..d42e5187c3c7 100644 --- a/pkgs/development/compilers/llvm/9/default.nix +++ b/pkgs/development/compilers/llvm/9/default.nix @@ -57,8 +57,10 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ + extraTools = [ libstdcxxHook + ]; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; -- cgit 1.4.1 From 05343f6ff134c771802e554bbdacd109b7434933 Mon Sep 17 00:00:00 2001 From: Benjamin Hipple Date: Wed, 18 Mar 2020 20:43:07 -0400 Subject: rust: remove legacy cargo fetcher We have now migrated every single Rust package in NixPkgs! This deletes the legacy fetcher, which is now unused. Resolves #79975 --- doc/languages-frameworks/rust.section.md | 6 +-- pkgs/build-support/rust/default.nix | 23 +++----- pkgs/build-support/rust/fetchcargo.nix | 81 ----------------------------- pkgs/development/compilers/rust/default.nix | 8 +-- 4 files changed, 10 insertions(+), 108 deletions(-) delete mode 100644 pkgs/build-support/rust/fetchcargo.nix (limited to 'pkgs/build-support') diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 97dc9e2ff531..cec3373cbee6 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -60,9 +60,9 @@ Nix depends on this file, so if it missing you can use `cargoPatches` to apply it in the `patchPhase`. Consider sending a PR upstream with a note to the maintainer describing why it's important to include in the application. -Unless `legacyCargoFetcher` is set to `true`, the fetcher will also verify that -the `Cargo.lock` file is in sync with the `src` attribute, and will compress the -vendor directory into a tar.gz archive. +The fetcher will verify that the `Cargo.lock` file is in sync with the `src` +attribute, and fail the build if not. It will also will compress the vendor +directory into a tar.gz archive. ### Building a crate for a different target diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index f42f951680f7..7cfd03a4e265 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,4 +1,4 @@ -{ stdenv, cacert, git, rust, cargo, rustc, fetchcargo, fetchCargoTarball, buildPackages, windows }: +{ stdenv, cacert, git, rust, cargo, rustc, fetchCargoTarball, buildPackages, windows }: { name ? "${args.pname}-${args.version}" , cargoSha256 ? "unset" @@ -14,7 +14,6 @@ , cargoUpdateHook ? "" , cargoDepsHook ? "" , cargoBuildFlags ? [] -, legacyCargoFetcher ? false , buildType ? "release" , meta ? {} , target ? null @@ -26,21 +25,17 @@ assert buildType == "release" || buildType == "debug"; let - cargoFetcher = if legacyCargoFetcher - then fetchcargo - else fetchCargoTarball; - cargoDeps = if cargoVendorDir == null - then cargoFetcher { + then fetchCargoTarball { inherit name src srcs sourceRoot unpackPhase cargoUpdateHook; patches = cargoPatches; sha256 = cargoSha256; } else null; - # If we're using the modern fetcher that always preserves the original Cargo.lock - # and have vendored deps, check them against the src attr for consistency. - validateCargoDeps = cargoSha256 != "unset" && !legacyCargoFetcher; + # If we have a cargoSha256 fixed-output derivation, validate it at build time + # against the src fixed-output derivation to check consistency. + validateCargoDeps = cargoSha256 != "unset"; # Some cargo builds include build hooks that modify their own vendor # dependencies. This copies the vendor directory into the build tree and makes @@ -50,8 +45,6 @@ let then ('' unpackFile "$cargoDeps" cargoDepsCopy=$(stripHash $cargoDeps) - '' + stdenv.lib.optionalString legacyCargoFetcher '' - chmod -R +w "$cargoDepsCopy" '') else '' cargoDepsCopy="$sourceRoot/${cargoVendorDir}" @@ -65,13 +58,9 @@ let cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; releaseDir = "target/${rustTarget}/${buildType}"; - # Fetcher implementation choice should not be part of the hash in final - # derivation; only the cargoSha256 input matters. - filteredArgs = builtins.removeAttrs args [ "legacyCargoFetcher" ]; - in -stdenv.mkDerivation (filteredArgs // { +stdenv.mkDerivation (args // { inherit cargoDeps; patchRegistryDeps = ./patch-registry-deps; diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix deleted file mode 100644 index 7a0ba38dce71..000000000000 --- a/pkgs/build-support/rust/fetchcargo.nix +++ /dev/null @@ -1,81 +0,0 @@ -{ stdenv, cacert, git, cargo, python3 }: -let cargo-vendor-normalise = stdenv.mkDerivation { - name = "cargo-vendor-normalise"; - src = ./cargo-vendor-normalise.py; - nativeBuildInputs = [ python3.pkgs.wrapPython ]; - dontUnpack = true; - installPhase = "install -D $src $out/bin/cargo-vendor-normalise"; - pythonPath = [ python3.pkgs.toml ]; - postFixup = "wrapPythonPrograms"; - doInstallCheck = true; - installCheckPhase = '' - # check that ./fetchcargo-default-config.toml is a fix point - reference=${./fetchcargo-default-config.toml} - < $reference $out/bin/cargo-vendor-normalise > test; - cmp test $reference - ''; - preferLocalBuild = true; -}; -in -{ name ? "cargo-deps" -, src ? null -, srcs ? [] -, patches ? [] -, sourceRoot -, sha256 -, cargoUpdateHook ? "" -, # whenever to also include the Cargo.lock in the output - copyLockfile ? false -, ... -} @ args: -stdenv.mkDerivation ({ - name = "${name}-vendor"; - nativeBuildInputs = [ cacert git cargo-vendor-normalise cargo ]; - - phases = "unpackPhase patchPhase installPhase"; - - installPhase = '' - if [[ ! -f Cargo.lock ]]; then - echo - echo "ERROR: The Cargo.lock file doesn't exist" - echo - echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change" - echo "when the registry is updated." - echo - - exit 1 - fi - - # Keep the original around for copyLockfile - cp Cargo.lock Cargo.lock.orig - - export CARGO_HOME=$(mktemp -d cargo-home.XXX) - CARGO_CONFIG=$(mktemp cargo-config.XXXX) - - ${cargoUpdateHook} - - mkdir -p $out - cargo vendor $out | cargo-vendor-normalise > $CARGO_CONFIG - # fetchcargo used to never keep the config output by cargo vendor - # and instead hardcode the config in ./fetchcargo-default-config.toml. - # This broke on packages needing git dependencies, so now we keep the config. - # But not to break old cargoSha256, if the previous behavior was enough, - # we don't store the config. - if ! cmp $CARGO_CONFIG ${./fetchcargo-default-config.toml} > /dev/null; then - install -D $CARGO_CONFIG $out/.cargo/config; - fi; - - '' + stdenv.lib.optionalString copyLockfile '' - # add the Cargo.lock to allow hash invalidation - cp Cargo.lock.orig $out/Cargo.lock - ''; - - outputHashAlgo = "sha256"; - outputHashMode = "recursive"; - outputHash = sha256; - - impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars; - preferLocalBuild = true; -} // (builtins.removeAttrs args [ - "name" "sha256" "cargoUpdateHook" "copyLockfile" -])) diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index a5da7ee7a6d4..1673441575c0 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -30,14 +30,8 @@ inherit cargo; }; - # N.B. This is a legacy fetcher implementation that is being phased out and deleted. - # See ../../../build-support/rust/README.md for details. - fetchcargo = buildPackages.callPackage ../../../build-support/rust/fetchcargo.nix { - inherit cargo; - }; - buildRustPackage = callPackage ../../../build-support/rust { - inherit rustc cargo fetchcargo fetchCargoTarball; + inherit rustc cargo fetchCargoTarball; }; rustcSrc = callPackage ./rust-src.nix { -- cgit 1.4.1 From 0229936bbe241f4686747d22919af0aac0dbb078 Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Sun, 15 Mar 2020 18:14:11 +0100 Subject: buildDunePackage: add a “useDune2” option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/build-support/ocaml/dune.nix | 6 ++++-- pkgs/development/ocaml-modules/dune-configurator/default.nix | 2 ++ pkgs/development/ocaml-modules/dune-private-libs/default.nix | 2 ++ pkgs/development/ocaml-modules/eigen/default.nix | 6 ++++-- pkgs/development/ocaml-modules/owl-base/default.nix | 6 ++++-- pkgs/development/ocaml-modules/owl/default.nix | 6 +++--- pkgs/development/ocaml-modules/phylogenetics/default.nix | 6 ++++-- pkgs/top-level/ocaml-packages.nix | 6 ++---- 8 files changed, 25 insertions(+), 15 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/ocaml/dune.nix b/pkgs/build-support/ocaml/dune.nix index a0aac1447969..435bbe89c1c4 100644 --- a/pkgs/build-support/ocaml/dune.nix +++ b/pkgs/build-support/ocaml/dune.nix @@ -1,7 +1,9 @@ -{ stdenv, ocaml, findlib, dune, opaline }: +{ stdenv, ocaml, findlib, dune, dune_2, opaline }: { pname, version, buildInputs ? [], ... }@args: +let Dune = if args.useDune2 or false then dune_2 else dune; in + if args ? minimumOCamlVersion && ! stdenv.lib.versionAtLeast ocaml.version args.minimumOCamlVersion then throw "${pname}-${version} is not available for OCaml ${ocaml.version}" @@ -29,7 +31,7 @@ stdenv.mkDerivation ({ name = "ocaml${ocaml.version}-${pname}-${version}"; - buildInputs = [ ocaml dune findlib ] ++ buildInputs; + buildInputs = [ ocaml Dune findlib ] ++ buildInputs; meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; }; diff --git a/pkgs/development/ocaml-modules/dune-configurator/default.nix b/pkgs/development/ocaml-modules/dune-configurator/default.nix index d84c21565db8..aa12ebc8d796 100644 --- a/pkgs/development/ocaml-modules/dune-configurator/default.nix +++ b/pkgs/development/ocaml-modules/dune-configurator/default.nix @@ -3,6 +3,8 @@ buildDunePackage rec { pname = "dune-configurator"; + useDune2 = true; + inherit (dune_2) src version; dontAddPrefix = true; diff --git a/pkgs/development/ocaml-modules/dune-private-libs/default.nix b/pkgs/development/ocaml-modules/dune-private-libs/default.nix index 1c3503f11a15..14059070c9a0 100644 --- a/pkgs/development/ocaml-modules/dune-private-libs/default.nix +++ b/pkgs/development/ocaml-modules/dune-private-libs/default.nix @@ -3,6 +3,8 @@ buildDunePackage rec { pname = "dune-private-libs"; + useDune2 = true; + inherit (dune_2) src version; dontAddPrefix = true; diff --git a/pkgs/development/ocaml-modules/eigen/default.nix b/pkgs/development/ocaml-modules/eigen/default.nix index 3922b5cfec75..dacd3a758623 100644 --- a/pkgs/development/ocaml-modules/eigen/default.nix +++ b/pkgs/development/ocaml-modules/eigen/default.nix @@ -1,9 +1,11 @@ -{ stdenv, buildDune2Package, fetchFromGitHub, ctypes, libcxx }: +{ stdenv, buildDunePackage, fetchFromGitHub, ctypes, libcxx }: -buildDune2Package rec { +buildDunePackage rec { pname = "eigen"; version = "0.2.0"; + useDune2 = true; + src = fetchFromGitHub { owner = "owlbarn"; repo = pname; diff --git a/pkgs/development/ocaml-modules/owl-base/default.nix b/pkgs/development/ocaml-modules/owl-base/default.nix index ce6ee124466c..9d2bf74a3ace 100644 --- a/pkgs/development/ocaml-modules/owl-base/default.nix +++ b/pkgs/development/ocaml-modules/owl-base/default.nix @@ -1,9 +1,11 @@ -{ stdenv, buildDune2Package, fetchFromGitHub, stdlib-shims }: +{ stdenv, buildDunePackage, fetchFromGitHub, stdlib-shims }: -buildDune2Package rec { +buildDunePackage rec { pname = "owl-base"; version = "0.8.0"; + useDune2 = true; + src = fetchFromGitHub { owner = "owlbarn"; repo = "owl"; diff --git a/pkgs/development/ocaml-modules/owl/default.nix b/pkgs/development/ocaml-modules/owl/default.nix index c6eaf69b704b..7fa912d808db 100644 --- a/pkgs/development/ocaml-modules/owl/default.nix +++ b/pkgs/development/ocaml-modules/owl/default.nix @@ -1,5 +1,5 @@ { stdenv -, buildDune2Package +, buildDunePackage , dune-configurator , fetchFromGitHub , alcotest @@ -11,10 +11,10 @@ , npy }: -buildDune2Package rec { +buildDunePackage rec { pname = "owl"; - inherit (owl-base) version src meta; + inherit (owl-base) version src meta useDune2; checkInputs = [ alcotest ]; buildInputs = [ dune-configurator ]; diff --git a/pkgs/development/ocaml-modules/phylogenetics/default.nix b/pkgs/development/ocaml-modules/phylogenetics/default.nix index 049a9a97c8e2..87e88cbf496e 100644 --- a/pkgs/development/ocaml-modules/phylogenetics/default.nix +++ b/pkgs/development/ocaml-modules/phylogenetics/default.nix @@ -1,10 +1,12 @@ -{ stdenv, buildDune2Package, fetchFromGitHub, ppx_deriving +{ stdenv, buildDunePackage, fetchFromGitHub, ppx_deriving , alcotest, biocaml, gnuplot, lacaml, menhir, owl }: -buildDune2Package rec { +buildDunePackage rec { pname = "phylogenetics"; version = "unstable-2019-11-15"; + useDune2 = true; + src = fetchFromGitHub { owner = "biocaml"; repo = pname; diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index e8a6bc21035b..485dfa7d807e 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -16,8 +16,6 @@ let buildDunePackage = callPackage ../build-support/ocaml/dune.nix {}; - buildDune2Package = buildDunePackage.override { dune = dune_2; }; - alcotest = callPackage ../development/ocaml-modules/alcotest {}; alcotest-lwt = callPackage ../development/ocaml-modules/alcotest/lwt.nix {}; @@ -232,9 +230,9 @@ let dune_2 = callPackage ../development/tools/ocaml/dune/2.nix { }; - dune-configurator = callPackage ../development/ocaml-modules/dune-configurator { buildDunePackage = buildDune2Package; }; + dune-configurator = callPackage ../development/ocaml-modules/dune-configurator { }; - dune-private-libs = callPackage ../development/ocaml-modules/dune-private-libs { buildDunePackage = buildDune2Package; }; + dune-private-libs = callPackage ../development/ocaml-modules/dune-private-libs { }; earley = callPackage ../development/ocaml-modules/earley { }; -- cgit 1.4.1