Skip to content

Commit

Permalink
Revert to nix-community/mavenix in nix build (#3749)
Browse files Browse the repository at this point in the history
This reverts the change to mavenix from
#2673 which introduced a
custom version of the mavenix build tool. The original mavenix builds a
"repo" derivation which symlinks to all the pom and jar files maven
needs to build k. The way mavenix assembles this repo is to first copy
each pom/jar file into the nix store individually and then symlink them
into a single derivation. Once we build using maven, mavenix copies any
required runtime jars to the final k derivation. This obviously creates
some redundancy, because there are now two copies of some jar/pom files
in the store. For the cachix cache, this means unnecessary duplication
each time we push to it. The solution in the aforementioned PR was to
symlink to the already present jars/poms instead of copying them.

However, with the new binary cache, the focus is on speed of downloading
the pre-compiled binaries and having lot of symlinked paths from the k
derivation to each individual pom/jar file introduces a serious
bottleneck when we call `nix copy` to download the k binary (see
NixOS/nix#2559). Until such time as this issue
is resolved, we should revert to the old mavenix which reduces the k
closure size (i.e. the number of files the k derivation depends on in
the nix store, not necessarily the total size in mb) drastically at the
expense of some added duplication of jar files with each build.
  • Loading branch information
goodlyrottenapple authored Oct 24, 2023
1 parent 0bbfe47 commit 18c190f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
llvm-backend.inputs.nixpkgs.follows = "haskell-backend/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
rv-utils.url = "github:runtimeverification/rv-nix-tools";
mavenix.url = "github:goodlyrottenapple/mavenix";
mavenix.url = "github:nix-community/mavenix";
# needed by nix/flake-compat-k-unwrapped.nix
flake-compat = {
url = "github:edolstra/flake-compat";
Expand Down
14 changes: 0 additions & 14 deletions nix/k.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ let
infoFile = ./mavenix.lock;
inherit src;

# By default, mavenix copies the jars defined in `submodules` of mavenix.lock to `$out/share/java`.
# The following flag disables this, since we copy the jars ourselves.
# Otherwise, the jars are needlessly duplicated and bloat the cachix cache.
copySubmodules = false;

# Add build dependencies
buildInputs = [ git ];

Expand All @@ -38,15 +33,6 @@ let
postInstall = ''
cp -r k-distribution/target/release/k/{bin,include,lib} $out/
for file in $out/lib/kframework/java/*; do
file_name=$(basename $file)
found_in_share="$(find -L $out/share/mavenix/repo -maxdepth 20 -name "$file_name")"
if [ ! -z "$found_in_share" ]; then
rm "$file"
ln -sf "$found_in_share" "$file"
fi
done
mkdir -p $out/lib/cmake/kframework && cp ${llvm-backend.src}/cmake/* $out/lib/cmake/kframework/
ln -sf ${llvm-backend}/include/kllvm $out/include/
ln -sf ${llvm-backend}/include/kllvm-c $out/include/
Expand Down

0 comments on commit 18c190f

Please sign in to comment.