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

Fix Julia packages with binary blobs failures and add withPackages attribute #210685

Closed

Conversation

fedeinthemix
Copy link
Contributor

Description of changes

Currently many Julia packages installed with the native package manager Pkg fail to work. In this PR we fix this by

  1. Adding a Julia build system to patch the binary blobs and make them available in nixpkgs with the help of the withPackages passthru attribute. A utility julia2nix is also added to facilitate adding packages to nixpkgs.
  2. Put the julia compiler in a buildFHSUserEnv thereby providing the interpreter in the expected location and defining some required environment variables.
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ninjin @7c6f434c @NickCao @benneti @pasqui23 @florianjacob @mayl @schlichtanders

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation labels Jan 14, 2023
@fedeinthemix fedeinthemix requested a review from mweinelt January 14, 2023 11:32
Copy link
Member

@NickCao NickCao left a comment

Choose a reason for hiding this comment

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

Overall promising, a bit skeptical about the dependency handling part.

pkgs/development/compilers/julia/build-env.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/build-julia-package.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/build-julia-package.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/build-julia-package.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot added 8.has: clean-up 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 14, 2023
@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch from e3de6d7 to a52e413 Compare January 15, 2023 13:20
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 15, 2023
@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch from a52e413 to f57a11e Compare January 15, 2023 14:44
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 15, 2023
@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch from f57a11e to 654cdad Compare January 15, 2023 14:56
@benneti
Copy link
Contributor

benneti commented Jan 16, 2023

Hey, thanks for another try! It seems like julia2nix -f -o env.nix -- "IJulia" is broken however piping to the file still works (i.e. I think "-o" is broken).

Additionally what is the intended way to loag a custom env

julia-bin.withPackages
  (ps: [ ps.Plots ] ++ (map fixpkgs
         (import ./env.nix {juliaPkgs = ps; inherit fetchurl; })))

does not seem to work as dependencies only in the env seem to be unavailable.

@fedeinthemix
Copy link
Contributor Author

You call it like this julia2nix -f -o env.nix IJulia (no "--"). But with this variant you don't need it anymore. For packages not in nixpkgs you just use Pkg as normal.

@benneti
Copy link
Contributor

benneti commented Jan 16, 2023

Ah sorry I am just so used to -- being able to separate the "rest" of the options.
I think it would be nice to still have the option for including a custom env file, to have a standard julia environment for the system (for example IJulia and other pkgs where I might want to regenerate the configuration when the path to julia changes) or simply packages I always want to have anyway.
But there is probably a way with the current implementation, I'll try it later and provide some feedback.

@benneti
Copy link
Contributor

benneti commented Jan 16, 2023

I don't know if this is accepted in nix, but maybe something like julia.withPackagesList that takes a generated packages list and automates

let
fixpkgs = pkgs: ...
inherit (julia-bin.juliaPackages) juliaPackagesFromList buildJuliaPackage;
juliaPkgs = juliaPackagesFromList (map fixpkgs juliaPkgsList);
juliaPkgsList = import ./env.nix { inherit juliaPkgs fetchurl; };
in julia-bin.withPackages (ps: (lib.mapAttrsToList (name: val: val) juliaPkgs))

but as this works in someway I am already happy.

Also I don't understand what triggers the precompiler sometimes it works and sometimes it does not for no apparent reason (and for the same packages no less).
PS: what makes this even more strange is, if I use home-manager to recursively symlink

  home.file.".julia" = {
    # HACK seems to enhance the chance of precompilation being picked up
    source = "${julia}/share/julia";
    recursive = true;
  };

precompilation seems to not happen at all. Maybe julia gets confused if some directories exists in ~/.julia but not all.
PPS: symlinking is no reliable solution as it breaks some packages (for me SymPy)

@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch from 654cdad to 0267785 Compare January 16, 2023 14:15
@ofborg ofborg bot requested review from a user, 7c6f434c and NickCao January 16, 2023 14:27
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-ready-for-review/3032/1761

pkgs/development/compilers/julia/with-packages.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/with-packages.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/julia/build-julia-package.nix Outdated Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/julia-packages.nix Show resolved Hide resolved
pkgs/development/julia-modules/README.md Outdated Show resolved Hide resolved
pkgs/development/julia-modules/julia2nix.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot requested a review from wegank January 30, 2023 09:36
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Jan 30, 2023
@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch 4 times, most recently from b07395b to 9156b72 Compare January 30, 2023 13:27
@fedeinthemix
Copy link
Contributor Author

Sorry for the incremental changes. I used the new "Add to batch commit" feature, but then didn't realize that I didn't commit all of them...

@fedeinthemix
Copy link
Contributor Author

would be glad if anyone with commit access could comment on what's missing to get this merged (apart from fixing the rl-2305 conflict).

@NickCao
Copy link
Member

NickCao commented Mar 13, 2023

I have nothing against this. cc @GTrunSec (an active julia user) for a review.

fedeinthemix and others added 2 commits May 13, 2023 11:33
- Add 'withPackages' and 'juliaPackages' passthru attributes to
  'julia_16-bin', 'julia_18-bin', 'julia-bin' and 'julia-stable-bin'.
- The 'withPackages' function creates an environment for the Julia
  compiler with additional packages.
- 'build-julia-package.nix' is used to compile Julia packages and
  artifacts.
- We provide a FHS environment to the julia compiler to make
  native packages with binary artifacts work.
- Add julia2nix to facilitate importing of Julia packages into nixpkgs.
@fedeinthemix fedeinthemix force-pushed the wip-julia-build-system-FHS branch from 9156b72 to 331a96c Compare May 13, 2023 09:48
@fedeinthemix fedeinthemix added the 0.kind: ZHF Fixes Fixes during the Zero Hydra Failures (ZHF) campaign label May 13, 2023
@fedeinthemix
Copy link
Contributor Author

ZHF: #230712

@fedeinthemix
Copy link
Contributor Author

Not sure why ofbor-eval-package-list-no-aliases fails. The package producing the error works on my system
image

@benneti
Copy link
Contributor

benneti commented May 13, 2023 via email

@fedeinthemix
Copy link
Contributor Author

I am travelling right now so i can not check in detail, but it might be that there is no graphical environment available in the ofborg script making plots fail.

I don't think this is the issue: the evaluation was successful until yesterday when I fixed two merge conflicts

  1. A release note entry (no code change)
  2. A couple of days ago julia_19 was added to master. So I wrapped it as the others
+  julia_19-bin = wrapJulia (callPackage ../development/compilers/julia/1.9-bin.nix { });

Also, there's no plot involved in the evaluation.

Can it be a false failure?

@RaitoBezarius
Copy link
Member

I am travelling right now so i can not check in detail, but it might be that there is no graphical environment available in the ofborg script making plots fail.

I don't think this is the issue: the evaluation was successful until yesterday when I fixed two merge conflicts

  1. A release note entry (no code change)
  2. A couple of days ago julia_19 was added to master. So I wrapped it as the others
+  julia_19-bin = wrapJulia (callPackage ../development/compilers/julia/1.9-bin.nix { });

Also, there's no plot involved in the evaluation.

Can it be a false failure?

I don't believe so, let's try again.

@ofborg eval

@fedeinthemix
Copy link
Contributor Author

I've found out that buildFHSUserEnv was deprecated in favor of buildFHSEnv.

@RaitoBezarius
Copy link
Member

Result of nixpkgs-review pr 210685 run on x86_64-linux 1

2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
1 package failed to build:
  • julia2nix
7 packages built:
  • cantor (libsForQt5.cantor ,plasma5Packages.cantor)
  • julia (julia-stable ,julia_19)
  • julia-bin (julia-stable-bin ,julia_19-bin)
  • julia-lts (julia-lts-bin ,julia_16-bin)
  • julia_18
  • julia_18-bin
  • labplot

@RaitoBezarius
Copy link
Member

Seems like not ready yet, also, please fix the title and ensure you follow CONTRIBUTING for commit messages.

@RaitoBezarius RaitoBezarius marked this pull request as draft May 22, 2023 07:56
@RaitoBezarius
Copy link
Member

Result of nixpkgs-review pr 210685 run on aarch64-darwin 1

4 packages marked as broken and skipped:
  • julia-bin
  • julia-stable-bin
  • julia_18-bin
  • julia_19-bin

@RaitoBezarius
Copy link
Member

Result of nixpkgs-review pr 210685 run on x86_64-darwin 1

5 packages marked as broken and skipped:
  • julia-bin
  • julia-stable-bin
  • julia_18-bin
  • julia_19-bin
  • labplot

@fedeinthemix
Copy link
Contributor Author

closing in favor of #225513

@fedeinthemix fedeinthemix deleted the wip-julia-build-system-FHS branch November 16, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: ZHF Fixes Fixes during the Zero Hydra Failures (ZHF) campaign 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: clean-up 8.has: documentation This PR adds or changes documentation 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 11-100
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants