Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use protoc from nix when available #1558

Merged
merged 8 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,10 @@ lazy val bootstrapped = projectMatrix
Compile / PB.protoSources ++= Seq(
exampleGeneratedResourcesOutput.value
),
Compile / PB.protocExecutable := sys.env
.get("PROTOC_PATH")
.map(file(_))
.getOrElse((Compile / PB.protocExecutable).value),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

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

20 changes: 10 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils, ... }@inputs:
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
shellPackages = [
"jre"
"sbt"
"nodejs-16_x"
"yarn"
shellPackages = with pkgs; [
temurin-jre-bin-17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I replaced default jre with the same one that is used on the CI

nodejs-18_x
yarn
(pkgs.sbt.override { jre = pkgs.temurin-jre-bin-17; })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I had to override the jre version used by this particular derivation of sbt (which is still 1.8.x version) as it was using too recent version of jre - 21.

I then decided to completely drop the idea of shellInputs being just a list of strings since this required the packages to be defined in two places without any particular benefit. Also the errors from nix evaluator were harder to debug when using strings.

];
in
{
devShells.default = pkgs.mkShell {
buildInputs = map (pkgName: pkgs.${pkgName}) shellPackages;
nativeBuildInputs = [ pkgs.openssl pkgs.zlib ];
buildInputs = shellPackages;
nativeBuildInputs = [ pkgs.openssl pkgs.zlib pkgs.protobuf3_21 ];
welcomeMessage = ''
Welcome to the smithy4s Nix shell! 👋
Available packages:
${builtins.concatStringsSep "\n" (map (n : "- ${n}") shellPackages)}
${builtins.concatStringsSep "\n" (map (n : "- ${n.name}") shellPackages)}
'';

shellHook = ''
echo "$welcomeMessage"
'';
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
PROTOC_PATH = pkgs.lib.getExe pkgs.protobuf3_21;
kubukoz marked this conversation as resolved.
Show resolved Hide resolved
ghostbuster91 marked this conversation as resolved.
Show resolved Hide resolved
};
}
);
Expand Down