forked from nix-community/bundix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change format of generated
gemset.nix
files
This commit is an attempt to make Bundix more "platform-aware." Every rubygem has a "platform" field which names the ruby-platform that it can run on. For the vast majority of gems, this will be `"ruby"`, indicating that it's a gem written entirely in ruby and should be able to run on any ruby interpreter; however, there are some gems that rely on native extensions that might only work on certain systems. The previous `gemset.nix` format only supported one version of each dependency. If the `Gemfile.lock` included a reference to `nokogiri (1.14.2)` and also `nokogiri (1.14.2-x86-linux)`, Bundix would render a `gemset.nix` that included only one of them. The trouble with this behaviour is that, at runtime, Bundler, will see has multiple nokogiri gems to choose from and may choose that one that was never built. This leads to issues like [1] and [2]. The new format of `gemfile.nix` is: ```nix { dependencies = ["list" "of" "top-level" "dependencies"]; platforms = { ruby = { gem-name = { dependencies = ["list" "of" 'transitive" "dependencies"] groups = [ ... ]; version = "..."; source = { # attrs describing the git, path, or RubyGems source }; }; }; other-platform = { gem-name = { ... }; }; }; } ``` The gemset's `dependencies` entry copies the `DEPENDENCIES` section of the `Gemfile.lock` and names all the top-level gem dependencies from the `Gemfile`. The gemset's `platforms` entry is an attrset where every key is a ruby-platform and its value is an attrset of the gems particular to that platform. This last attrset is essentially the same as the previous `gemset.nix` format. This commit also introduces a new nix function: `bundixEnv` (like `bundlerEnv`, but for Bundix). This function accepts the same arguments as `bundlerEnv`, with the addition of a `platform`. `bundixEnv` then converts the given gemset into a format suitable for `bundlerEnv` by selecting the gems appropriate for the given `platform`. Finally, it delegates to `bundlerEnv`, with the platform-specific gemset. `bundix --init` will generate an example `flake.nix` with an example package that demonstrates how `bundixEnv` works. See `gem help platforms` for more info about ruby platforms. The Bundler Guide [3] provides a few examples of rubygems that support multiple platforms. This commit also adds two guides, `guides/getting-started.md` and `guides/motivations.md` that describe this format in more detail. [1] nix-community#71 [2] https://discourse.nixos.org/t/issues-with-nix-reproducibility-on-macos-trying-to-build-nokogiri-ruby-error-unknown-warning-option/22019 [3] https://guides.rubygems.org/gems-with-extensions/
- Loading branch information
Showing
78 changed files
with
3,302 additions
and
1,889 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
.bundle/ | ||
*.gem | ||
tmp | ||
result | ||
/*.gem | ||
/.bundle/ | ||
/.yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/result | ||
/tmp/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.