2022-02-14 21:06:17 +03:00
|
|
|
|
{ system ? import ./system.nix
|
2021-06-23 12:39:00 +03:00
|
|
|
|
, pkgs ? import ./nixpkgs.nix { inherit system; }
|
|
|
|
|
}:
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
# Selects "bin" output from multi-output derivations which are has it. For
|
|
|
|
|
# other multi-output derivations, select only the first output. For
|
|
|
|
|
# single-output generation, do nothing.
|
|
|
|
|
#
|
|
|
|
|
# This ensures that as few output as possible of the tools we use below are
|
|
|
|
|
# realized by Nix.
|
|
|
|
|
selectBin = pkg:
|
|
|
|
|
if pkg == null then
|
|
|
|
|
null
|
|
|
|
|
else if builtins.hasAttr "bin" pkg then
|
|
|
|
|
pkg.bin
|
|
|
|
|
else if builtins.hasAttr "outputs" pkg then
|
|
|
|
|
builtins.getAttr (builtins.elemAt pkg.outputs 0) pkg
|
|
|
|
|
else
|
|
|
|
|
pkg;
|
|
|
|
|
|
|
|
|
|
# Add all packages that are used by Bazel builds here
|
|
|
|
|
bazel_dependencies = import ./bazel.nix { inherit system pkgs; };
|
|
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
|
inherit pkgs;
|
|
|
|
|
|
2021-01-25 14:53:53 +03:00
|
|
|
|
ghc = bazel_dependencies.ghc;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
2021-06-23 12:39:00 +03:00
|
|
|
|
# wrap the .bazelrc to automate the configuration of
|
|
|
|
|
# `build --config <kernel>`
|
|
|
|
|
bazelrc =
|
|
|
|
|
let
|
|
|
|
|
kernel =
|
|
|
|
|
if pkgs.stdenv.targetPlatform.isLinux then "linux"
|
|
|
|
|
else if pkgs.stdenv.targetPlatform.isDarwin then "darwin"
|
|
|
|
|
else throw "unsupported system";
|
|
|
|
|
in
|
|
|
|
|
pkgs.writeText "daml-bazelrc" ''
|
|
|
|
|
build --config ${kernel}
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
toolAttrs = rec {
|
2020-02-26 19:34:51 +03:00
|
|
|
|
# Code generators
|
|
|
|
|
|
|
|
|
|
make = pkgs.gnumake;
|
|
|
|
|
m4 = pkgs.m4;
|
|
|
|
|
|
|
|
|
|
thrift = pkgs.thrift;
|
|
|
|
|
protoc = bazel_dependencies.protobuf3_8;
|
|
|
|
|
|
|
|
|
|
# Haskell development
|
2021-01-25 14:53:53 +03:00
|
|
|
|
ghc = bazel_dependencies.ghc;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
ghcid = pkgs.haskellPackages.ghcid;
|
2021-02-08 14:12:07 +03:00
|
|
|
|
hlint = bazel_dependencies.hlint;
|
2021-01-25 14:53:53 +03:00
|
|
|
|
ghci = bazel_dependencies.ghc;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
|
|
|
|
# Hazel’s configure step currently searches for the C compiler in
|
|
|
|
|
# PATH instead of taking it from our cc toolchain so we have to add
|
|
|
|
|
# it to dev-env. See https://github.com/FormationAI/hazel/issues/80
|
|
|
|
|
# for the upstream issue.
|
|
|
|
|
cc = bazel_dependencies.bazel-cc-toolchain;
|
|
|
|
|
|
|
|
|
|
mvn = bazel_dependencies.mvn;
|
|
|
|
|
|
|
|
|
|
zinc = pkgs.callPackage ./tools/zinc {};
|
|
|
|
|
|
2021-11-18 17:48:37 +03:00
|
|
|
|
jdk = bazel_dependencies.jdk11;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
java = jdk;
|
|
|
|
|
javac = jdk;
|
|
|
|
|
jinfo = jdk;
|
|
|
|
|
jmap = jdk;
|
|
|
|
|
jstack = jdk;
|
|
|
|
|
jar = jdk;
|
|
|
|
|
|
2021-01-29 15:59:26 +03:00
|
|
|
|
javafmt = pkgs.callPackage ./tools/google-java-format {};
|
|
|
|
|
|
2021-07-27 17:23:39 +03:00
|
|
|
|
buf = pkgs.buf;
|
|
|
|
|
|
2021-05-17 18:04:53 +03:00
|
|
|
|
scala = bazel_dependencies.scala_2_13;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
fsc = scala;
|
|
|
|
|
scalac = scala;
|
|
|
|
|
scaladoc = scala;
|
|
|
|
|
scalap = scala;
|
|
|
|
|
sbt = pkgs.sbt;
|
|
|
|
|
|
|
|
|
|
coursier = pkgs.coursier;
|
|
|
|
|
# nixpkgs ships with an RC for scalafmt 2.0 that seems to be significantly slower
|
|
|
|
|
# and changes a lot of formatting so for now we stick to 1.5.1.
|
|
|
|
|
scalafmt = pkgs.callPackage ./overrides/scalafmt.nix { jre = jdk; };
|
|
|
|
|
|
|
|
|
|
# Nix development
|
|
|
|
|
cabal2nix = pkgs.cabal2nix;
|
|
|
|
|
|
|
|
|
|
pypi2nix = pkgs.pypi2nix;
|
|
|
|
|
|
|
|
|
|
# Web development
|
|
|
|
|
node = bazel_dependencies.nodejs;
|
|
|
|
|
npm = bazel_dependencies.nodejs;
|
|
|
|
|
yarn = (pkgs.yarn.override {
|
|
|
|
|
nodejs = bazel_dependencies.nodejs;
|
|
|
|
|
}).overrideAttrs (oldAttrs: rec {
|
|
|
|
|
version = "1.12.3";
|
|
|
|
|
src = pkgs.fetchzip {
|
|
|
|
|
url = "https://github.com/yarnpkg/yarn/releases/download/v${version}/yarn-v${version}.tar.gz";
|
|
|
|
|
sha256 = "0izn7lfvfw046qlxdgiiiyqj24sl2yclm6v8bzy8ilsr00csbrm2";
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
node2nix = pkgs.nodePackages.node2nix;
|
|
|
|
|
|
|
|
|
|
chromedriver = pkgs.chromedriver;
|
|
|
|
|
|
|
|
|
|
# Python development
|
|
|
|
|
pip3 = pkgs.python37Packages.pip;
|
|
|
|
|
python = python37;
|
|
|
|
|
python3 = python37;
|
|
|
|
|
python37 = pkgs.python37Packages.python;
|
|
|
|
|
|
|
|
|
|
yapf = pkgs.python37Packages.yapf;
|
|
|
|
|
|
|
|
|
|
pex = pkgs.python37Packages.pex;
|
|
|
|
|
pipenv = import ./tools/pipenv {
|
2021-02-08 14:12:07 +03:00
|
|
|
|
lib = pkgs.lib;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
python3 = python3;
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-22 17:30:15 +03:00
|
|
|
|
sphinx-build = sphinx;
|
|
|
|
|
sphinx-quickstart = sphinx;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
2022-02-22 17:30:15 +03:00
|
|
|
|
sphinx = bazel_dependencies.sphinx-exts;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
|
|
|
|
convert = bazel_dependencies.imagemagick;
|
|
|
|
|
|
|
|
|
|
sass = bazel_dependencies.sass;
|
|
|
|
|
|
2021-12-01 15:01:46 +03:00
|
|
|
|
graphviz = pkgs.graphviz;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
dot = graphviz;
|
|
|
|
|
tred = graphviz;
|
|
|
|
|
unflatten = graphviz;
|
|
|
|
|
circo = graphviz;
|
|
|
|
|
|
2020-08-18 14:50:45 +03:00
|
|
|
|
pandoc = pkgs.pandoc;
|
|
|
|
|
|
2020-02-26 19:34:51 +03:00
|
|
|
|
# Build tools
|
|
|
|
|
|
|
|
|
|
bazel = pkgs.writeScriptBin "bazel" (''
|
2021-06-23 12:39:00 +03:00
|
|
|
|
#!${pkgs.bash}/bin/bash
|
2020-02-26 19:34:51 +03:00
|
|
|
|
# Set the JAVA_HOME to our JDK
|
|
|
|
|
export JAVA_HOME=${jdk.home}
|
|
|
|
|
export GIT_SSL_CAINFO="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
|
2021-02-08 14:12:07 +03:00
|
|
|
|
'' + pkgs.lib.optionalString (pkgs.buildPlatform.libc == "glibc") ''
|
2020-02-26 19:34:51 +03:00
|
|
|
|
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
|
|
|
|
|
'' + ''
|
Revert "Switch to Bazel 5 (#12935)" (#12974)
This reverts commit 4c0118df4d0304153e8f6ed9e3cfb1a1295876df.
This breaks passing -p to bazel test for Haskell tests, e.g.,
bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p
--test_arg InterfaceEq
which breaks with something horrifying like
moritz@adjunction ~/daml (main)> bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p --test_arg InterfaceEq
[dev-env] Building tools.bazel...
[dev-env] Built tools.bazel in /nix/store/m7gzlmr0pqjpl01ihgvazxgfs3sfwl61-bazel and linked to /home/moritz/daml/dev-env/var/gc-roots/bazel
[dev-env] Building tools.find...
[dev-env] Built tools.find in /nix/store/645v3545lcbx77wq7355rgdrgbhn5wx7-findutils-4.8.0 and linked to /home/moritz/daml/dev-env/var/gc-roots/find
INFO: Invocation ID: 034b3e45-851f-472e-ab71-b7f718829582
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/rules_haskell/haskell/private/versions.bzl:60:10: WARNING: bazel version is too recent. Supported versions range from 4.0.0 to 4.2.1, but found: 5.0.0- (@non-git)
/nix/store/dadkhf8vch2i2kvig962ilfr5j3chshr-go-1.17.6
/nix/store/pzh24n543i6jqa01hdmgqknlyf294bn1-bazel-nixpkgs-posix-toolchain
/nix/store/2hfwndk47wpvaib06qyhcdp83b423xvh-jq-1.6-bin
/nix/store/hjggs9s82qh7r5j8sgapn389hf24wdx8-bazel-nixpkgs-cc-toolchain
/nix/store/yxgg3bn4v288sc00kf09svrwz2r461c9-ghc-native-bignum-9.0.2
/nix/store/2hwx0jhcdsx3wfvmb50ih19jkh2ra4jh-glibc-locales-2.33-108
/nix/store/8wpmx049z8m0ffhy3jyi41qb6pbxwvy8-bazel-nixpkgs-java-runtime
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 3d79fe1470dcb842d5944c98dfe7a62715db6d86fdb12d3ff60af3bdf41b7996
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 9f46e824944add9e9951ef51ddb6cb4b744bc97f90b5749132179d1d1699dfa1
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: com.google.devtools.build.lib.skyframe.ArtifactConflictFinder$ConflictException: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o, previous action: action 'Compiling src/tools/launcher/dummy.cc', attempted action: action 'Compiling src/tools/launcher/dummy.cc'
changelog_begin
changelog_end
2022-02-16 21:24:00 +03:00
|
|
|
|
exec ${pkgs.bazel_4}/bin/bazel --bazelrc "${bazelrc}" "$@"
|
2020-02-26 19:34:51 +03:00
|
|
|
|
'');
|
|
|
|
|
|
|
|
|
|
# System tools
|
|
|
|
|
shellcheck = pkgs.shellcheck;
|
|
|
|
|
curl = bazel_dependencies.curl;
|
2020-11-25 17:43:37 +03:00
|
|
|
|
lsof = pkgs.lsof;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
|
|
|
|
patch = pkgs.patch;
|
2021-09-02 11:31:56 +03:00
|
|
|
|
timeout = pkgs.coreutils;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
wget = pkgs.wget;
|
|
|
|
|
grpcurl = pkgs.grpcurl;
|
|
|
|
|
|
|
|
|
|
# String mangling tooling.
|
2020-10-21 16:00:19 +03:00
|
|
|
|
base64 = pkgs.coreutils;
|
|
|
|
|
bc = pkgs.bc;
|
2021-03-24 15:35:02 +03:00
|
|
|
|
date = pkgs.coreutils;
|
2020-10-21 16:00:19 +03:00
|
|
|
|
find = pkgs.findutils;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
gawk = bazel_dependencies.gawk;
|
2020-10-21 16:00:19 +03:00
|
|
|
|
grep = pkgs.gnugrep;
|
|
|
|
|
jq = bazel_dependencies.jq;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
sed = pkgs.gnused;
|
|
|
|
|
sha1sum = pkgs.coreutils;
|
2022-01-10 19:45:33 +03:00
|
|
|
|
sha256sum = pkgs.coreutils;
|
2020-10-21 16:00:19 +03:00
|
|
|
|
xargs = pkgs.findutils;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
xmlstarlet = pkgs.xmlstarlet;
|
|
|
|
|
|
|
|
|
|
# Cryptography tooling
|
|
|
|
|
gnupg = pkgs.gnupg;
|
|
|
|
|
gpg = gnupg;
|
|
|
|
|
|
|
|
|
|
# Packaging tools
|
|
|
|
|
patchelf = bazel_dependencies.patchelf;
|
|
|
|
|
zip = bazel_dependencies.zip;
|
2021-08-17 19:59:12 +03:00
|
|
|
|
unzip = pkgs.unzip;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
openssl = pkgs.openssl.bin;
|
|
|
|
|
tar = bazel_dependencies.gnutar;
|
|
|
|
|
|
|
|
|
|
semver = pkgs.callPackage ./tools/semver-tool {};
|
|
|
|
|
|
|
|
|
|
undmg = pkgs.undmg;
|
|
|
|
|
|
|
|
|
|
# Cloud tools
|
|
|
|
|
aws = pkgs.awscli;
|
2022-02-14 04:49:38 +03:00
|
|
|
|
az = pkgs.azure-cli;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
gcloud = pkgs.google-cloud-sdk;
|
2020-06-30 15:01:43 +03:00
|
|
|
|
bq = gcloud;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
gsutil = gcloud;
|
2020-06-30 15:01:43 +03:00
|
|
|
|
docker-credential-gcloud = gcloud;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
# used to set up the webide CI pipeline in azure-cron.yml
|
|
|
|
|
docker-credential-gcr = pkgs.docker-credential-gcr;
|
2022-01-31 17:46:59 +03:00
|
|
|
|
terraform = pkgs.terraform_1.withPlugins (p: with p; [
|
2020-02-26 19:34:51 +03:00
|
|
|
|
google
|
|
|
|
|
google-beta
|
|
|
|
|
random
|
|
|
|
|
secret
|
|
|
|
|
template
|
|
|
|
|
]);
|
|
|
|
|
nix-store-gcs-proxy = pkgs.callPackage ./tools/nix-store-gcs-proxy {};
|
2021-06-23 12:39:00 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Tools used in the dev-env. These are invoked through wrappers in dev-env/bin.
|
|
|
|
|
tools = pkgs.lib.mapAttrs (_: pkg: selectBin pkg) toolAttrs;
|
2020-02-26 19:34:51 +03:00
|
|
|
|
|
|
|
|
|
# Set of packages that we want Hydra to build for us
|
|
|
|
|
cached = bazel_dependencies // {
|
|
|
|
|
# Packages used in command-line tools
|
|
|
|
|
cli-tools = {
|
|
|
|
|
inherit (pkgs) coreutils nix-info getopt;
|
|
|
|
|
};
|
|
|
|
|
} // (if pkgs.stdenv.isLinux then {
|
|
|
|
|
# The following packages are used for CI docker based builds
|
|
|
|
|
bash = pkgs.bash;
|
|
|
|
|
busybox = pkgs.busybox;
|
|
|
|
|
bzip2 = pkgs.bzip2;
|
|
|
|
|
cacert = pkgs.cacert;
|
|
|
|
|
cheat = pkgs.cheat;
|
|
|
|
|
coreutils = pkgs.coreutils;
|
|
|
|
|
dockerd = pkgs.docker;
|
|
|
|
|
ftop = pkgs.ftop;
|
|
|
|
|
gcc7 = pkgs.gcc7;
|
|
|
|
|
glibc = pkgs.glibc;
|
|
|
|
|
iputils = pkgs.iputils;
|
|
|
|
|
less = pkgs.less;
|
|
|
|
|
ltrace = pkgs.ltrace;
|
|
|
|
|
lvm2 = pkgs.lvm2;
|
|
|
|
|
ncurses = pkgs.ncurses;
|
|
|
|
|
nettools = pkgs.nettools;
|
|
|
|
|
procps = pkgs.procps;
|
|
|
|
|
glibcLocales = pkgs.glibcLocales;
|
|
|
|
|
strace = pkgs.strace;
|
|
|
|
|
sudo = pkgs.sudo;
|
|
|
|
|
su = pkgs.su;
|
|
|
|
|
tcpdump = pkgs.tcpdump;
|
|
|
|
|
tldr = pkgs.tldr;
|
|
|
|
|
tmux = pkgs.tmux;
|
|
|
|
|
utillinux = pkgs.utillinux;
|
|
|
|
|
vim = pkgs.vim;
|
|
|
|
|
which = pkgs.which;
|
|
|
|
|
zsh = pkgs.zsh;
|
|
|
|
|
openssh = pkgs.openssh;
|
|
|
|
|
}
|
|
|
|
|
else {});
|
|
|
|
|
|
|
|
|
|
# On CI we only cache a subset of cached since we only build a subset of targets.
|
|
|
|
|
ci-cached =
|
|
|
|
|
if pkgs.stdenv.isDarwin
|
|
|
|
|
then builtins.removeAttrs cached ["texlive"]
|
|
|
|
|
else cached;
|
|
|
|
|
|
|
|
|
|
# The build environment used for the 'da' package set above.
|
|
|
|
|
# Exported here for testing purposes.
|
|
|
|
|
environment = {
|
|
|
|
|
ghc = bazel_dependencies.ghc;
|
|
|
|
|
cabal2nix = tools.cabal2nix;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dade = {
|
|
|
|
|
tools-list = pkgs.runCommand "tools-list" {
|
|
|
|
|
ts = builtins.concatStringsSep " " (builtins.attrNames tools);
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
} "echo $ts > $out";
|
|
|
|
|
};
|
|
|
|
|
}
|