Help with gcc installation

I have a fresh nixos 23.11 virtual machine setup. My goal is to populate configuration.nix with the necessary systemPackages to be able to run a demo Rails 7.1.2 application. To that end, I have a environment.systemPackages section that looks like this:

  environment.systemPackages = with pkgs; [
    libgcc
    git
    ruby_3_3
    gnumake
    sqlite
    rubyPackages_3_3.sqlite3
    rubyPackages_3_3.rails
    rubyPackages_3_3.psych
    rubyPackages_3_3.io-console
    rubyPackages_3_3.puma
    rubyPackages_3_3.msgpack
    rubyPackages_3_3.websocket-driver
    rubyPackages_3_3.nio4r
    rubyPackages_3_3.nokogiri
  ];

So, my problem is that everything appears to be installed, however, I do not have gcc in my path after running:

nixos-rebuild switch

But if I say do this, it works fine:

nix-shell -p libgcc
[appuser@nixos:~]$ nix-shell -p libgcc
[nix-shell:~]$ gcc -v
Using built-in specs.
...
gcc version 12.3.0 (GCC)

I didn’t notice any errors, and the other tools on the list like gnu make are working fine.

Any idea how I can debug this or fix it?

Rails needs to have a compiler and a set of development tools in order to build some of the gems so while the rails command is there, creating an application fails due to all the missing development tools, specifically a compiler at the moment.

Thank you,

I will answer this question myself because after doing more research (i.e. google searching) I found that my question demonstrated my temporary lack of “getting nix” in that the rails bundler / workflow is, as it stands incompatible with the declarative model that NIX adheres to.

I found some references that were useful to me but don’t immediately resolve my “I just want to run a simple rails demo” goal. But, I now have more information to see if this is still the approach I will take.

The answer therefore to this question is:

  1. It’s not that simple, the bundler in rails which is invoked is trying to modify the running NIXOS system without using the NIX tooling so this breaks the contract we have when running NIX.

  2. Adding the libgcc package to /etc/nixos/configuration.nix’s environment.systemPackages is not the way to work with compilers or development environments on NIX. The behavior I observed is the correct behavior. I now know that there are packages in NIX which do modify your PATH when used in the systemPackages list, and there are packages which do NOT modify your PATH when added to the same list. Epiphany boom!

So much more to learn.

I really just want a way to build a reproducible development and production environments for “things” where “things” are rails and other frameworks that have dependencies.

These two posts were useful in hitting me up side the head:

  1. https://actually.fyi/posts/rails-on-nix/
  2. rust - Compiler not installed when using configuration.nix - Stack Overflow