-
Notifications
You must be signed in to change notification settings - Fork 73
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 Nix configuration files #313
Conversation
Co-authored-by: George Stagg <georgestagg@gmail.com>
I made a few more changes:
I also found out that there's no way to find the top-level directory, where flake.nix lives. I think this will be fixed in the future, but what that means for now is that if you run |
I made some more changes. Notably, the most recent commit does the following:
To build, run the following: nix build github:wch/webr/use-flang-flake --print-build-logs (This will automatically pull in and build the flang-webr package.) If you want to run a shell with both of them present, run:
You can see both of them in the path if you run
|
Are the modifications you made general, as in could they be merged back into the webR project repo? I ask because I'd prefer not to have duplication of build scripts, if possible. For example, the I guess that would only make sense if nix can be told to use a |
I originally started by adding a flang-webr build target in this repo, but then I realized that any changes to this repo would cause flang to rebuild. At least, I think that's what will happen. It's possible there's a way around this, but I don't know Nix well enough to figure it out. A couple of possibilities I can think of, some better than others:
|
By the way, the only change I made to the flang stuff was this one commit: Previously, the I changed it to get the path dynamically, which also meant that the I think that would probably be a good change to make to the original sources in this repository as well. |
Okay, fair enough. I think we should combine r-wasm/webr-flang and wch/flang-webr into a single repo can build both the Docker container and/or the Nix flake, sharing the build scripts. In the future that repo could then upload the resulting Docker image and the Nix flake to the GH container registry and cachix (or whatever) through CI.
I'm taking a look at LLVM 17.0.5 to see how difficult it would be to rebase our WebAssembly changes onto the latest release, and if it looks doable then experiment with merging in your
Nice! Yes, we should definitely backport that back here. |
Move EMFC and libFortranRuntime.a targets into individual fortran-*.mk files. Update Makefile to reflect the above change. Update Makefile cleanup targets: * clean - Remove webR build tree * clean-wasm - Remove webR and Wasm library build tree * distclean - Remove webR, Wasm library, and compiler toolchain build tree.
Fixes an issue when building with LLVM Flang 17
Required so that webR's build scripts may download external sources for R and its required system libraries.
LLVM Flang for WebAssembly is now available as a Nix package at https://github.com/r-wasm/flang-wasm. Following up on that, I've pushed a bunch of commits here so that this PR can build webR as a Nix package as part of GitHub Actions CI. A short list of changes:
TODO: Allow webR to build with |
Fixes an issue rebuilding when `dist` has been removed.
Updated to nixos-23.11. The separate input entry for Emscripten has been removed. |
This PR adds a Nix configuration file. The basic idea is that it provides a declarative specification of an environment, so that it is easy to create a reproducible build/development environment.
Prerequisites:
Once you have Nix installed on your system, all you need to do to use the build environment is the following:
The first time you run this, it will take a while because it will download a number of packages -- the ones specified in the flake.nix file.
Then you can build as usual, with:
You can exit the development environment with a Ctrl-D or
exit
.The flake.nix file specifies what goes into the development environment; the flake.lock file is automatically generated, and ensures that others will get the exact same versions of dependencies. (They are somewhat analogous to package.json and package-lock.json files)
Normally when you run
nix develop
, it will make the specified packages available overlaid on top of the normal stuff you have available in your path.For example, the flake.nix says to include the
curl
package. When you are in the development environment, and you typewhich curl
, it will show that the nix copy ofcurl
will be used, instead of the system copy (which is in/usr/bin/curl
).This works because Nix modifies the
PATH
and puts the development environment directories in front of the existingPATH
.However, for programs that aren't specified by the flake.nix, it will fall through to the usual path. For example, flake.nix does not specify
rsync
, but it can find the system copy from the PATH:If you want to try a purer development environment, use
-i
or--ignore-environment
. This causes it to ignore/reset all external environment settings. If you do that, it will not findrsync
, because/usr/bin
won't be in the path.Using
nix develop -i
is useful for testing ifflake.nix
truly captures all the dependencies needed to build webR.To install Nix, I used the installer from Determinate Systems. Instructions are here: https://zero-to-nix.com/start/install
The installation is a one-liner:
In the future, we should be able to build in CI using Nix. I've only built on my Mac, and hopefully the Nix config file would also work for Linux.
We could also publish to nixpkgs and flakehub so that other Nix users could have webR available just by adding a
webr
entry to their Nix config files.