-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Add mill build tool #51110
Add mill build tool #51110
Conversation
${gnused}/bin/sed -i '0,/mill.MillMain/{s|mill.MillMain|mill.MillMain --no-remote-logging|}' $out/bin/mill | ||
''; | ||
meta = with stdenv.lib; { | ||
homepage = http://www.lihaoyi.com/mill; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well be HTTPS?
cp ${src} $out/bin/mill | ||
chmod +x $out/bin/mill | ||
${gnused}/bin/sed -i '0,/java/{s|java|${jre}/bin/java|}' $out/bin/mill | ||
${gnused}/bin/sed -i '0,/mill.MillMain/{s|mill.MillMain|mill.MillMain --no-remote-logging|}' $out/bin/mill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to manually do gnused like this? It should be in stdenv, shouldn't it?
propagatedBuildInputs = [ jre ] ; | ||
buildInputs = [ makeWrapper gnused ] ; | ||
phases = "installPhase"; | ||
installPhase = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation seems to be a little wonky
stdenv.mkDerivation rec { | ||
name = "mill-${version}"; | ||
version = "0.3.5"; | ||
src = fetchurl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fetchFromGitHub
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your feedback @alyssais !
Lihaoyi has prebuilt the Mill binary on this url:
I am not able to fetch that since it does not have the .tar.gz
extension.
I am not sure how easy it is to build this from source, since it is a build tool that is building itself. Would it be ok to keep the fetchurl
. Are there any special requirements concerning using binaries like this in nixpkgs?
I've used sbt that is also a build tool in scala as my recipe:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! I didn't catch that it was a binary. Generally builds from source are vastly preferred in Nixpkgs. Usually binaries are only used when source builds are impossible (eg if it's proprietary, closed-source software).
If it has a dependency on itself, something that, eg ghc and rustc do it to pull in a binary of the previous release, and use that to build the latest one from source.
Probably best to wait for somebody else to weigh in about the binary – personally I'd rather not have binaries in Nixpkgs when it's not absolutely necessary, but that's not my call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.. I agree about binaries :-) I think creating a build using scalac would be quite some work though. I'll wait to see. Thank you very much for helping me out so far! :-)
sha256 = "19ka81f6vjr85gd8cadn0fv0i0qcdspx2skslfksklxdxs2gasf8"; | ||
}; | ||
propagatedBuildInputs = [ jre ] ; | ||
buildInputs = [ makeWrapper gnused ] ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you use makeWrapper
?
${gnused}/bin/sed -i '0,/java/{s|java|${jre}/bin/java|}' $out/bin/mill | ||
${gnused}/bin/sed -i '0,/mill.MillMain/{s|mill.MillMain|mill.MillMain --no-remote-logging|}' $out/bin/mill | ||
''; | ||
meta = with stdenv.lib; { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've taken lib
as an argument so this can just be with lib
.
}; | ||
propagatedBuildInputs = [ jre ] ; | ||
buildInputs = [ makeWrapper gnused ] ; | ||
phases = "installPhase"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this line for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to override all other phases with my own defined installPhase
. This will crash on the unpack phase for example, since it is a binary. Maybe there are better ways doing this? I think I took this from the nix pills.
propagatedBuildInputs = [ jre ] ; | ||
buildInputs = [ makeWrapper gnused ] ; | ||
phases = "installPhase"; | ||
installPhase = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're overriding installPhase
you should add runHook preInstall
and runHook postInstall
to your implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to do that also if we only have our own self defined installPhase
? I tested it locally and it works, but I guess that is because they are undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, because it allows people to use overrideAttrs
and insert their own things without having to override your whole installPhase
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course! hehe, didn't think about that! Nice :-)
We have a standard commit message format. In this case, it should be |
|
||
propagatedBuildInputs = [ jre ] ; | ||
|
||
phases = "installPhase"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good way. You are throwing away the standard unpackPhase
and fixupPhase
.
I think its fine to instead let the standard phases fail here, they should not terminate the build. You can ask to skip some of the phases by setting
stdenv.mkDerivation {
# ...
dontConfigure = true;
dontBuild = true;
# ...
}
Note that dontConfigure
doesn't work at the moment, but it's worth to state the intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for helping out on this. I've added the flags you mention, I also override the unpackPhase, so there are no errors occuring during the build. Is this an ok way of doing this? Without it, my build did actually stall locally.
I've also removed the sed patching, it was not necessary it seems.
@scalavision Other problem is that Finally, I propose following fixes: diff --git a/pkgs/development/tools/build-managers/mill/default.nix b/pkgs/development/tools/build-managers/mill/default.nix
index 933a7e56cca..97910d22cb3 100644
--- a/pkgs/development/tools/build-managers/mill/default.nix
+++ b/pkgs/development/tools/build-managers/mill/default.nix
@@ -1,4 +1,5 @@
-{ stdenv, fetchurl, jre }:
+{ stdenv, fetchurl, jre, makeWrapper }:
+
stdenv.mkDerivation rec {
name = "mill-${version}";
version = "0.3.5";
@@ -8,11 +9,9 @@ stdenv.mkDerivation rec {
sha256 = "19ka81f6vjr85gd8cadn0fv0i0qcdspx2skslfksklxdxs2gasf8";
};
- propagatedBuildInputs = [ jre ] ;
+ nativeBuildInputs = [ makeWrapper ];
- unpackPhase = ''
- # Skipping unpackphase, nothing to unpack
- '';
+ unpackPhase = "true";
dontConfigure = true;
@@ -20,9 +19,9 @@ stdenv.mkDerivation rec {
installPhase = ''
runHook preInstall
- mkdir -p $out/bin
- cp ${src} $out/bin/mill
- chmod +x $out/bin/mill
+ install -Dm555 "$src" "$out/bin/.mill-wrapped"
+ # can't use wrapProgram because it sets --argv0
+ makeWrapper "$out/bin/.mill-wrapped" "$out/bin/mill" --prefix PATH : ${stdenv.lib.makeBinPath [ jre ]}
runHook postInstall
'';
@@ -31,7 +30,6 @@ stdenv.mkDerivation rec {
license = licenses.mit;
description = "A build tool for Scala, Java and more";
maintainers = with maintainers; [ scalavision ];
- platforms = platforms.unix;
+ inherit (jre.meta) platforms;
};
-
} |
Thank you very much for your feedback @veprbl :-) |
oh.. hm... do you think there is a way to solve it? I used this as my recipe originally, I see they have used patform.all in there. |
|
@GrahamcOfBorg build mill |
No attempt on aarch64-linux (full log) The following builds were skipped because they don't evaluate on aarch64-linux: mill Partial log (click to expand)
|
Success on x86_64-darwin (full log) Attempted: mill Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: mill Partial log (click to expand)
|
Seems to work to compile and run a simple hello world Scala project. I don't understand where it gets java and scala compiler from. @scalavision do you understand how it works? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I see that it does look for javac to compile java. It seems to work fine for interactive use as is. It probably will need some more work to be used inside a Nix build (e.g. some artefacts need to be fetched, probably can be done in a way similar to what's done in bloop
).
I think this is good to be merged.
Just in case, cc'ing sbt
maintainers @NeQuissimus @rickynils
I am really no sure @veprbl , it seems he has a dependency on zinc, and maybe that one does the magic. I think he has reused some stuff from sbt and zinc. I agree, I think support for use within a nix build could be added on later. Again, thank you very much for helping out :-) |
Motivation for this change
Mill is a very nice tool for building java and scala projects. It is easier to learn than sbt, maven and gradle for beginners in Scala.
I can be the maintainer of this package, I am also working on several new bioinformatic tools that I will add shortly to nixpkgs. I am still learning nix so please let me know what could be improved! I have mostly looked at other, similar projects to accomplish this derivation.
Thank you for creating Nix and NixOS, it's an awesome project!
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)