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

julia: cleanup/reorganisation #117881

Merged
merged 12 commits into from Apr 28, 2021
Merged

julia: cleanup/reorganisation #117881

merged 12 commits into from Apr 28, 2021

Conversation

ghost
Copy link

@ghost ghost commented Mar 28, 2021

Motivation for this change

The Julia ecosystem needed – in my opinion – a bit of work in that expressions had large redundant chunks, v1.0.x was broken due to CVEs, etc.

Things done

I am not sure how the Nixpkgs community feels about very large PRs, but it was all interconnected and I have done my utmost to break everything down into small incremental commits. Comments are more than welcome and here is a high-level summary reflecting the individual commits:

  • Rewrite/cleanup of the v1.0.x expression, highlights:
    • Patch to resolve libgit2 CVEs by bumping version
    • Removed large redundant chunks of the expression
    • Simplified by relying on official tar with dependency sources
    • Patch to only disable tests requiring networking
    • More comments across the board
  • Dropped julia_13 as it is not supported upstream
  • Dropped julia_1 as it was unclear if it referred to v1.0.x or v1.y.z.
  • Introduced julia-lts and julia-stable to replace the “numbered” aliases as these are the only two releases that will ever be supported upstream. This saves us from deprecating multiple aliases each year and simplifies our expressions somewhat.
  • Make the LTS the default branch. This reverts the non-syntax part of 1e4c335, but opinion is that the expected default by an end-user.
  • Removed redundant patches:
    • mtime
    • diagonal test

Comments are more than welcome. I had also intended to include an expression for v1.6.0, but the one I have needs more work before I consider it PR-worthy. If it takes some time to get this PR merged I may add it as I will be working on it in the meantime.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ghost
Copy link
Author

ghost commented Mar 28, 2021

Ah, forgot to mention that we are now a few people over on the Julia slack in #nix in an attempt to organise collectively going forward.

@ofborg ofborg bot added 8.has: clean-up 8.has: package (new) This PR adds a new package labels Mar 28, 2021
@ofborg ofborg bot requested review from garrison, 7c6f434c and rbvermaa March 28, 2021 13:25
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 labels Mar 28, 2021
@7c6f434c
Copy link
Member

7c6f434c commented Mar 28, 2021

I think a part of that explixit numbering was that Julia has been enough of a moving target that sometimes moving from the freshly-unsupported version to the just-packaged-but-not-yet-fully version was quite a bit of a tradeoff, and depending on the use case different moments were optimal migration points for different users. Do you expect Julia packaging to be more stable going forward?

(expression code looks fine to me)

@ghost
Copy link
Author

ghost commented Mar 28, 2021

@7c6f434c That is a very fair point and one I had not immediately considered, I guess it is all the more relevant on NixOS as we can not as easily just grab the binary release. Happy to rework this part as long as we can agree on some sort of policy going forward that I can document in the expressions. How about we continue using numbered releases (but do offer the aliases) and keep around releases not supported upstream for say six months? Is there a good way to signal an upcoming deprecation to the Nixpkg end-user? I feel it is not really responsible on our side not to let them know that security patches etc. will not be coming their way.

@7c6f434c
Copy link
Member

7c6f434c commented Mar 28, 2021 via email

@cstich
Copy link
Contributor

cstich commented Mar 28, 2021

Generally speaking I am also in favor of making the naming convention of "lts/stable" the new default. Not sure how much need there is to keep numbered versions (internally). Even if we don't keep numbered versions around it should be relatively straightforward for a user to use the stable version from a previous NixOS release, no?

@7c6f434c
Copy link
Member

Mixing glibc versions gets annoying annoyingly quickly, though (and Julia has some great FFI-based packages…)

pkgs/development/compilers/julia/lts.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/lts.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/stable.nix Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Mar 29, 2021 via email

@7c6f434c
Copy link
Member

how things are handled by the Nixpkgs community

Note that there is no consensus on basically anything (but top-level warning prohibition works as a piece of code, so that's definitely there). A lot of people want to minimise the number of extra versions around, but for large packages especially where «working» is a complicated notion having multiple version happens.

Would it be frowned upon if I broke out an expression to build LLVM out of the main Julia expression using the same source?

I think it should be fine.

@garrison
Copy link
Member

LTS releases are not interchangeable, and the release process leaves open the possibility that there might be multiple LTS versions worth using at a given time. With regard to linux kernel packages, lts is not even part of the name -- instead, the current supported versions are given (e.g. linux_4_19). Why do something different for julia?

I am glad to hear people are interested in maintaining julia/nix; thank you too for adding yourself to the maintainers in this PR.

@cstich cstich mentioned this pull request Apr 4, 2021
9 tasks
@samuela
Copy link
Member

samuela commented Apr 4, 2021

Unrelated, I am fairly tired of rebuilding LLVM a gorillion times just by virtue of minute changes to the expression – it greatly slows down the process… Would it be frowned upon if I broke out an expression to build LLVM out of the main Julia expression using the same source? Defined in the same file as it will only ever be used by that specific Julia expression. I hear that Guix rips out the patches (I can not confirm as I stay clear from anything GPL) and patch their “vanilla” LLVM expression, but this is far too fragile for my taste as we have to keep the build process in sync with upstream Julia or risk potentially passing on truly nasty errors to our users (I mean, our expressions already deviated greatly from upstream Julia and we needed a rewrite). Is there precedence for this that I could look at or strong opinions against it?

Yes yes yes to this! It is such a huge PITA to work on the julia nix derivations in some tiny way and then wait years for it to finish rebuilding all of LLVM...

@ghost
Copy link
Author

ghost commented Apr 5, 2021 via email

@ghost
Copy link
Author

ghost commented Apr 13, 2021 via email

@samuela
Copy link
Member

samuela commented Apr 13, 2021

Thanks @ninjin ! This is a heroic effort! I'll try to review and test it out in the next few days.

pkgs/development/compilers/julia/1.0.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.0.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.0.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.6.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.6.nix Outdated Show resolved Hide resolved
Copy link
Member

@samuela samuela left a comment

Choose a reason for hiding this comment

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

overall lgtm as long as all the tests pass.

could we keep the update script though? the following should do (untested):

#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 python3Packages.requests

import os
import re
import requests
import subprocess

latest = requests.get("https://api.github.com/repos/JuliaLang/julia/releases/latest").json()["tag_name"]
assert latest[0] == "v"
major, minor, patch = latest[1:].split(".")
assert major == "1"
# When a new minor version comes out we'll have to refactor/copy this update script.
assert minor == "6"

sha256 = subprocess.check_output(["nix-prefetch-url", "--unpack", f"https://github.com/JuliaLang/julia/releases/download/v{major}.{minor}.{patch}/julia-{major}.{minor}.{patch}-full.tar.gz"], text=True).strip()

nix_path = os.path.join(os.path.dirname(__file__), "1.6.nix")
nix0 = open(nix_path, "r").read()
nix1 = re.sub("version = \".*\";", f"version = \"{latest[1:]}\";", nix0)
nix2 = re.sub("src_sha256 = \".*\";", f"src_sha256 = \"{sha256}\";", nix1)
open(nix_path, "w").write(nix2)

with the src_sha256 refactored as suggested in the review.

pkgs/development/compilers/julia/1.0.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.0.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.6.nix Outdated Show resolved Hide resolved
pkgs/top-level/aliases.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/1.6.nix Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Apr 14, 2021

overall lgtm as long as all the tests pass.

could we keep the update script though? the following should do (untested):

#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 python3Packages.requests

import os
import re
import requests
import subprocess

latest = requests.get("https://api.github.com/repos/JuliaLang/julia/releases/latest").json()["tag_name"]
assert latest[0] == "v"
major, minor, patch = latest[1:].split(".")
assert major == "1"
# When a new minor version comes out we'll have to refactor/copy this update script.
assert minor == "6"

sha256 = subprocess.check_output(["nix-prefetch-url", "--unpack", f"https://github.com/JuliaLang/julia/releases/download/v{major}.{minor}.{patch}/julia-{major}.{minor}.{patch}-full.tar.gz"], text=True).strip()

nix_path = os.path.join(os.path.dirname(__file__), "1.6.nix")
nix0 = open(nix_path, "r").read()
nix1 = re.sub("version = \".*\";", f"version = \"{latest[1:]}\";", nix0)
nix2 = re.sub("src_sha256 = \".*\";", f"src_sha256 = \"{sha256}\";", nix1)
open(nix_path, "w").write(nix2)

with the src_sha256 refactored as suggested in the review.

I really would prefer to drop it as I think it offers very little improvement in convenience at the cost of additional maintenance and fragility. We do have update scripts elsewhere in the Nixpkgs source tree, but most of them are for more complex projects. What I mean by this is that for Julia the process is actually fairly simple and standard in relationship to what one would have to do for any package: 1.) Go to download page for the URL 2.) Run nix-prefetch-url 3.) Update the version number in X.Y.nix and copy in the hash. It does not take any special knowledge really as any Nixpkgs maintainer or contributor should be familiar with the process. The update script instead depends on the format of the upstream JSON, constrains the format of X.Y.nix since changes in syntax could break it (just like your edit suggestion regarding src_sha256 demonstrated) as it just like a C macro is largely unaware of the underlying syntax of what it is modifying, only supports one release unless we make it more complex, and lastly it is easy to forget about its existence and update “manually” and then we have the expression and update script out of sync. Given this line of reasoning, I came to the conclusion that dropping it would be a sane thing to do.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/get-going-with-julia-on-nixos-in-under-an-hour/12530/4

Pontus Stenetorp added 10 commits April 28, 2021 06:55
According to the Julia release process [1] there will only ever be two
supported release branches at any given time: stable and LTS. Once a new
version of either is released, support for the previous release will be
dropped upstream. Introducing aliases for these branches allows our
users to easily track either depending on their need for stability.

[1]: https://julialang.org/blog/2019/08/release-process/#long_term_support
This is potentially controversial, but it is unclear to me whether
julia_1 should refer to either the latest stable or LTS release of 1.x.
We may want to revisit this when/if we get 2.x, but as it stands the
Julia release process [1] makes it clear that there will only ever be a
single supported stable and LTS release at any given time which should
speak in favour of using the julia-stable and julia-lts aliases instead.

[1]: https://julialang.org/blog/2019/08/release-process/#long_term_support
Erroneously disabled by 3ae5e6c as it
mistook Julia for using CMake (it is used by some of the vendored
dependencies).
As far as I can tell this patch is redundant as all pre-compiled code
generated at build time is baked into the Julia system image and will
thus never get invalidated: Note that for both julia_10 and julia_15
there are no `.ji` files produced in the derivations.
Fix merged upstream and backported to Julia 1.0.5:

    JuliaLang/julia#31443
Makes the top-level directory organisation easier with an increasing
number of patches.
Provides very little comfort compared what is outlined in the
manual [1], only supports a single version, and would probably be better
to implement as a general Nixpkg tool.

[1]: https://nixos.org/manual/nixpkgs/stable/#sec-source-hashes
No change in semantics, but makes it consistent with the expressions.
This is a fairly pedantic thing to do to be honest.
Provides a few hopefully helpful pointers that would not work well as
inline comments in the expressions themselves. Most likely the README
will need to be expanded upon over time to cover how we handle the Julia
release process, but I hope this is a good starting point.
@7c6f434c
Copy link
Member

I think a patched upstream binary release and non-perfect source build can coexist and both add value.

Do I understand correctly that LLVM is not broken out right now?

@ghost
Copy link
Author

ghost commented Apr 28, 2021 via email

@7c6f434c
Copy link
Member

I wonder if it is a good idea to have a summary in the description about the build status of the latest tried iteration…

I think searching for x86_64 - in the beginning of the line should find the failing invocation

@rikhuijzer
Copy link
Contributor

rikhuijzer commented Apr 28, 2021

I've just been experimenting with https://git.sr.ht/~ninjin/nixpkgs/log/julia-bin for Julia 1.6 and must say that it is a massive improvement over a buildFHSUserEnv that many people are using. For example, I've put a buildFHSUserEnv at https://github.com/rikhuijzer/julia-nixos. The build by ninjin:

So, I'm definitely a proponent of adding the bin derivation for Julia 1.6 to nixpkgs. Also because Julia developers are advised to only support the latest Julia release which is 1.6 and missing from nixpkgs currently.

EDIT: Nevermind. I already found an issue on Linux. With Gadfly:
EDIT2: The issue is probably something else, because my old setup is now broken too (GiovineItalia/Gadfly.jl#1535).

@samuela
Copy link
Member

samuela commented Apr 28, 2021

I tried running the test suite on julia_15 on AWS, and it has the same BLAS errors as always. But that's no fault of this PR and I think we've made @ninjin suffer enough here already. I propose we

  1. Merge this PR in its current state.
  2. I'll open an issue for BLAS related failures. We can address that issue by either finding a fix, or by adding the test suite to the build process and marking the 1.5 version as broken for the time being.
  3. @ninjn can submit a PR for the patched 1.6 version. I tested out his derivation and it seems to work great! It doesn't have any of the BLAS related failures that I've found in 1.5 so it really is set to go.

@7c6f434c
Copy link
Member

Indeed, the current state seems to be mostly a cleanup more than too much reorganisation.

@samuela thanks for the summary, I was not sure I am not missing something among all these test reports and wanted someone to confirm that there is nothing obvious hanging.

@7c6f434c 7c6f434c merged commit ae96c29 into NixOS:master Apr 28, 2021
@samuela
Copy link
Member

samuela commented May 10, 2021

@ninjin Any progress on the 1.6 binary version? The branch-off for NixOS 21.05 is happening May 21st, so it would be great to have the new 1.6 merged in by then!

@ghost
Copy link
Author

ghost commented May 10, 2021 via email

@symphorien
Copy link
Member

Firstly, apologies for my silence over the last week or so. I have been busy with work and also I am wavering a bit in terms of confidence that I can get this PR “ashore” given what we have seen for aarch64 and macOS which I lack access to hardware and software to in order to debug.

Maybe you could ask for access to https://github.com/nix-community/aarch64-build-box to debug aarch64 builds.

@samuela
Copy link
Member

samuela commented May 10, 2021

Oof… No pressure, eh? '^^ Thank you for the poke, I will increase the priority over the next few days as it really is not that much work.

Sorry, only meant for it to be a friendly ping! I think your 1.6 solution is exciting, but no pressure intended. We're all volunteers here.

@ghost
Copy link
Author

ghost commented May 16, 2021 via email

@jtrakk
Copy link

jtrakk commented May 19, 2021

@ninjin I think project-tracking issues are common in nixpkgs.

@7c6f434c
Copy link
Member

It is probably even better to have a single issue «not all Julia versions can be built with all tests passing everywhere» so that if that matches an unrelated search it can be skipped as a single entry… (oh wait GitHub search is effectively broken for Nixpkgs, but if it ever gets fixed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: clean-up 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants