cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.56k stars 259 forks source link

ruby: add bundler options #579

Closed bobvanderlinden closed 1 year ago

bobvanderlinden commented 1 year ago

Currently there is no way to disable bundler nor is it possible to alter the bundler package.

In addition, there was a problem with the prioritization of the ruby/bundler packages, as modern ruby packages include a bundler executable.

This was reported here: https://github.com/bobvanderlinden/nixpkgs-ruby/issues/72

I also wanted to avoid regressions, so I added a stricter example/test.

Resolves https://github.com/bobvanderlinden/nixpkgs-ruby/issues/72

bobvanderlinden commented 1 year ago

@ryansch could you give this a try?

domenkozar commented 1 year ago

Seems like the ruby test is still failing

bobvanderlinden commented 1 year ago

Found out the problem. Bundler was internally still using the Ruby version from nixpkgs. When I pkgs.bundler.override { ruby = cfg.package; } I ran into a strange issue where env inside mkDerivation was not supported. This was because nixpkgs-ruby was still based on nixos-22.11, while devenv was using nixpkgs-unstable. The env in mkDerivation was introduced inbetween these versions(?). To circumvent this I've let the nixpkgs-ruby input follow nixpkgs in the Ruby example.

bobvanderlinden commented 1 year ago

I ran the following, which succeeds locally. :crossed_fingers: that this works for CI as well:

git checkout . && git clean -xdf && pushd examples/ruby && mv devenv.yaml devenv.yaml.orig && awk '
            { print }
            /^inputs:$/ {
              print "  devenv:";
              print "    url: path:../../src/modules";
            }
          ' devenv.yaml.orig > devenv.yaml && popd && devenv-test-example ruby
bobvanderlinden commented 1 year ago

It seems that the self-hosted MacOS machine doesn't have xcode installed (or isn't up-to-date?). The native dependencies fail to build:

`try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

I think the x86_64-darwin build automatically comes with xcode installed, so it relies on those libraries to build the native dependencies.

I'm contemplating whether to include darwin.apple_sdk.frameworks.* or whether rely on preinstalled xcode.

I see that the rust has:

https://github.com/cachix/devenv/blob/4da6478ed21c3ab643bed241660c1e8d62be4371/src/modules/languages/rust.nix#L66

Should this be part of languages.c?

I'm also wondering whether https://github.com/cachix/devenv/pull/507 would already add CFLAGS when the right frameworks are chosen.

domenkozar commented 1 year ago

We should rely on xcode not being installed and list all the deps we need. Most likely #507 addresses this, I'll look into it next week.

For the YAML schema I was hoping we can render it with strictyaml, how can we keep it in sync with the validation logic. Any ideas?

bobvanderlinden commented 1 year ago

We should rely on xcode not being installed and list all the deps we need.

That would indeed be the most reliable. I'm guessing people aren't using it this way yet though 😅

For the YAML schema I was hoping we can render it with strictyaml, how can we keep it in sync with the validation logic. Any ideas?

Are you referring to making changes in the tests (like awk does currently)? If so, I was thinking maybe all tests could be run inside a Nix build using something like __impure. That way changes to the tests can be reproduced more easily.

But maybe I'm not understanding what you meant by validation logic?

sandydoo commented 1 year ago

@bobvanderlinden, if you'd like to rebase this over master, I can help iron out the remaining macos issues 🙂

bobvanderlinden commented 1 year ago

@bobvanderlinden, if you'd like to rebase this over master, I can help iron out the remaining macos issues 🙂

I had some other PRs that were becoming problematic with the lack of a MacOS system, so I have put in some time to get my old x86_64 mac working again. :+1: I was able to reproduce the problem by not installing xcode.

EDIT: Ah! I just saw your addition of libllvm, I think that fixed it here as well. Nice :+1: I rebased the PR.

sandydoo commented 1 year ago

EDIT: Ah! I just saw your addition of libllvm, I think that fixed it here as well. Nice 👍 I rebased the PR.

Yeah, sorry, I really should've mentioned that 😂

bobvanderlinden commented 12 months ago

Awesome, thanks!