Skip to content

Commit 29b6c7b

Browse files
author
Dmitry Voronov
authored
Merge pull request #882 from input-output-hk/feature/ETCM-129-scala-point-13-ringer
Fix scala==2.13 nix build, cleanup
2 parents 25ee0c1 + bec2be4 commit 29b6c7b

19 files changed

+198
-6985
lines changed

.buildkite/pipeline.nix

+1-18
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,7 @@ in
1414
nixExpr = commonAttrs // {
1515
label = "ensure Nix expressions are up-to-date";
1616
command = ''
17-
echo "Checking if Nix expressions are up-to-date..."
18-
19-
nix-shell --run 'sbtix-gen-all2'
20-
21-
set +e
22-
git diff --exit-code > nix-expr.patch
23-
if [ "$?" -eq "1" ]; then
24-
set -e
25-
echo "Nix expressions not up-to-date."
26-
echo "Download and apply the patch available in the artifact paths of this step:"
27-
echo " patch -p1 < nix-expr.patch"
28-
echo "Aborting."
29-
exit 1
30-
else
31-
set -e
32-
echo "Nix expressions up-to-date!"
33-
exit 0
34-
fi
17+
./update-nix.sh --check
3518
'';
3619
retry.automatic = false;
3720
artifactPaths = [

.buildkite/shell.nix

+2-7
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@ let
1717
1818
exec ${pkgs.protobuf}/bin/protoc "$@"
1919
'';
20-
21-
sbtix = pkgs.callPackage sources.Sbtix { };
22-
2320
in
2421

2522
with pkgs;
26-
23+
2724
mkShell {
28-
29-
buildInputs = [ sbt solc jdk8 protoc-wrapper sbtix ];
25+
nativeBuildInputs = [ sbt solc jdk8 protoc-wrapper ];
3026
# SBT = "sbt -v -mem 2048 -J-Xmx4g -Dsbt.ivy.home=/cache/ivy2 -Dsbt.boot.directory=/cache/sbt -Dmaven.repo.local=/cache/maven -Dnix=true";
3127
SBT = "sbt -v -mem 2048 -J-Xmx4g -Dnix=true";
32-
SBTIX_GEN = "true";
3328
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ metals.sbt
2222

2323
# Nix
2424
result
25+
.nix/

README.md

+9-29
Original file line numberDiff line numberDiff line change
@@ -116,40 +116,20 @@ In the root of the project:
116116
nix-build
117117
```
118118

119-
##### Regenerate lock files
119+
##### Update sbt+nix dependencies
120120

121-
```
122-
nix-shell
123-
sbtix-gen-all2
124-
```
125-
126-
OR
127-
128-
If the "ensure Nix expressions are up-to-date" step of your CI
129-
build has failed, check the artifacts of that step. There should be a
130-
patch provided, which you can apply locally with:
121+
When updating project dependencies, the nix fixed-output-derivation
122+
will need to be updated so that it includes the new dependency state.
131123

124+
To do so, please run:
132125
```
133-
patch -p1 < downloaded.patch
126+
./update-nix.sh
127+
git add ./nix/pkgs/mantis.nix
128+
git commit -m "Update nix-sbt sha"
134129
```
135130

136-
This patch will update the lock files for you.
137-
138-
###### Why so many lock files?
139-
140-
- `repo.nix` : generated by the `sbtix-gen` command and includes only the build dependencies for the project.
141-
- `project/repo.nix` : generated by the `sbtix-gen-all` command and includes only the plugin dependencies. Also generates `repo.nix`.
142-
- `project/project/repo.nix` : generated by the `sbtix-gen-all2` command and includes only the plugin dependencies. Also generates `repo.nix` and `project/repo.nix`.
143-
144-
##### error: unsupported argument 'submodules' to 'fetchGit'
145-
146-
You get this error when you aren't using a new-enough version of Nix (fetchGit support for submodules is recent).
147-
148-
To fix this, update the version of Nix you are using, or in a pinch:
149-
150-
- Remove the "submodules = true;" argument from fetchGit (in `./nix/pkgs/mantis/default.nix`).
151-
- `git submodule update --recursive --init`
152-
- `nix-build`
131+
*NOTE:* This should only be necessary when updating dependencies
132+
(For example, edits to build.sbt or project/plugins.sbt will likely need to be regenerated)
153133

154134
### Monitoring
155135

build.sbt

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def commonSettings(projectName: String): Seq[sbt.Def.Setting[_]] = Seq(
1414
name := projectName,
1515
organization := "io.iohk",
1616
version := "3.2.1",
17-
scalaVersion := "2.13.3",
17+
scalaVersion := "2.13.4",
1818
// Scalanet snapshots are published to Sonatype after each build.
1919
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
2020
testOptions in Test += Tests
@@ -203,7 +203,9 @@ lazy val node = {
203203
if (!nixBuild)
204204
node
205205
else
206+
//node.settings(PB.protocExecutable := file("protoc"))
206207
node.settings(PB.runProtoc in Compile := (args => Process("protoc", args) !))
208+
207209
}
208210

209211
coverageExcludedPackages := "io\\.iohk\\.ethereum\\.extvm\\.msg.*"

manual-repo.nix

-26
This file was deleted.

nix/default.nix

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
{ system ? builtins.currentSystem, sources ? import ./sources.nix, src ? ../. }:
22

33
let
4-
overlay = final: prev: {
5-
inherit sources;
4+
# we need to filter out the nix files in this repository as they will
5+
# affect the fixed derivation calculation from sbt-derivation
6+
overlay = final: prev: let
67
inherit (import sources.gitignore { inherit (prev) lib; }) gitignoreSource;
8+
cleanedSrc = prev.lib.cleanSource (gitignoreSource src);
9+
in {
10+
inherit sources;
711

8-
sbtix = prev.callPackage ../sbtix.nix {
9-
jdk = prev.openjdk8_headless;
10-
jre = prev.openjdk8_headless.jre;
11-
};
12-
13-
mantisPkgs = final.callPackage ./pkgs/mantis {
12+
mantis = final.callPackage ./pkgs/mantis.nix {
1413
inherit (prev.openjdk8_headless) jre;
15-
inherit src;
14+
src = cleanedSrc;
1615
};
17-
18-
inherit (final.mantisPkgs) mantis;
19-
20-
mkSrc = import sources.nix-mksrc { inherit (final) lib; };
2116
};
17+
sbt-derivation-overlay = import sources.sbt-derivation;
2218
in import sources.nixpkgs {
2319
inherit system;
24-
overlays = [ overlay ];
20+
overlays = [
21+
sbt-derivation-overlay
22+
overlay
23+
];
2524
}

nix/pkgs/default.nix

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
{ pkgs, lib, newScope, sources, src, impure ? false }:
1+
{ pkgs, lib, src, impure ? false }:
22

3-
lib.makeScope newScope (self:
4-
with self;
5-
let callPackages = lib.callPackagesWith (pkgs // self);
6-
in {
7-
inherit sources src impure;
8-
jdk = prev.openjdk8_headless;
9-
})
3+
lib.makeScope pkgs.newScope (self: with self; {
4+
inherit src impure;
5+
mantis = callPackage ./mantis.nix { };
6+
jdk = openjdk8_headless;
7+
})

nix/pkgs/mantis.nix

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{ src
2+
, lib
3+
, stdenv
4+
, makeWrapper
5+
, writeShellScriptBin
6+
, bash
7+
, protobuf
8+
, coreutils
9+
, jdk
10+
, jre
11+
, gawk
12+
, sbt
13+
, impure ? false
14+
}:
15+
16+
let
17+
18+
# sbt-protoc puts the scala plugin in /tmp/protobridge<some-random-number>.
19+
# it is in fact a shell script with a standard `#!/usr/bin/env sh` shebang
20+
# that makes the Nix sandbox ANGRY and breaks all the things in a cryptic,
21+
# hairpull-inducing way. So we gotta sed it out. Not the prettiest thing
22+
# but it works.
23+
#
24+
# This will be unnecessary in sbt-protoc>=1.0.0, as we can specify a file path
25+
# Also, https://github.com/thesamet/sbt-protoc/issues/209 will need to be resolved
26+
# for the plugins to not fail.
27+
protoc-wrapper = writeShellScriptBin "protoc" ''
28+
set -e
29+
30+
for f in "$@"; do
31+
echo ''${f##*=}
32+
done | grep protocbridge | xargs sed -i "1s|.*|#!${bash}/bin/bash|"
33+
34+
exec ${protobuf}/bin/protoc "$@"
35+
'';
36+
nativeBuildInputs = [ protoc-wrapper jdk makeWrapper ];
37+
38+
# read version from build.sbt
39+
version = let
40+
buildSbt = builtins.readFile ../../build.sbt;
41+
captures = builtins.match ''.*version := "([^"]+)".*'' buildSbt;
42+
in builtins.elemAt captures 0;
43+
44+
LD_LIBRARY_PATH = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
45+
PATH = lib.makeBinPath [ coreutils jre gawk ];
46+
47+
in sbt.mkDerivation {
48+
pname = "mantis";
49+
50+
inherit src nativeBuildInputs version;
51+
52+
# This sha represents the change dependencies of mantis.
53+
# Update this sha whenever you change the dependencies
54+
depsSha256 = "sha256-yAaJUJgg5Sdnhr3mX85BquC3X1ygF6If/FOngMUIkPU=";
55+
56+
# this is the command used to to create the fixed-output-derivation
57+
depsWarmupCommand = "sbt compile --debug -Dnix=true";
58+
59+
# just inherit build artifacts from fixed-output-derivation
60+
dontBuild = true;
61+
62+
overrideDepsAttrs = oldAttrs: oldAttrs // {
63+
# $out is a directory, thus the archive will fail to write a file
64+
preInstall = ''
65+
rm -rf $out
66+
'';
67+
};
68+
69+
installPhase = ''
70+
sbt stage -Dnix=true
71+
mkdir -p $out/
72+
cp -r target/universal/stage/* $out/
73+
mkdir -p $out/share/mantis
74+
mv $out/{LICENSE,RELEASE,mantis_config.txt} $_
75+
76+
# wrap executable so that java is available at runtime
77+
for p in $(find $out/bin/* -executable); do
78+
wrapProgram "$p" \
79+
--prefix PATH : ${PATH} \
80+
${lib.optionalString (!stdenv.isDarwin)
81+
"--prefix LD_LIBRARY_PATH : ${LD_LIBRARY_PATH}"
82+
}
83+
done
84+
'';
85+
86+
dontPatchShebangs = impure;
87+
88+
# limit warnings from trying to strip jar files
89+
dontStrip = true;
90+
}

nix/pkgs/mantis/default.nix

-11
This file was deleted.

nix/pkgs/mantis/unwrapped.nix

-51
This file was deleted.

nix/pkgs/mantis/wrapped.nix

-33
This file was deleted.

0 commit comments

Comments
 (0)