I have a set of development vagrant VMs which traditionally have been provisioned using ansible which I am trying to port to nix and nixos-generators for all the normal nix reasons (reproducability, fine-grained control of package versions, etc). The end use of these VMs is to provide a C/C++ development environment which will run on a Windows host, but disconnected from the internet.
My current approach has been to install the desired tools system wide in the VM’s system.environmentPackages. This has mostly worked, but I’ve hit a roadblock getting tools like gcov which are available in a nix-shell -p gcc but not when gcc is added to system.environmentPackages. Somewhat less of an issue for me currently, but this approach also does not allow me to link against “system” libraries.
@lovesegfault @adisbladis on IRC suggested that I need to somehow build an offline nix-shell (thanks again for your help! I’m re-posting here because this is a little more async, and my work/life schedule isn’t allowing much access to IRC at the momement). The first approach attempted for doing this was to add a mkShell “package” to my system.environmentPackages per their suggestion like below:
( (mkShell{ buildInputs = [gcc]; }).overrideAttrs(_: {nobuildPhase = "touch $out";}) )
Unfortunately, this leas to the following error when building the VM:
The store path /nix/store/6lni8hzpqbbgiq6hwnda5cnlrv79fp88-nix-shell is a file and can't be merged into an environment using pkgs.buildEnv! at /nix/store/pm3r9b13iwvw2hr7v7b9nwlnssp0i858-builder.pl line 109.
I’ve also tried adding gcc-unwrapped to my systemPackages. This makes gcov available, but the gcc it provides doesn’t work (I haven’t looked into it extensively, but I think that without the wrap it doesn’t have a stdlib).
I’ve also since tried to do a similar thing to mkShell with a buildEnv like below, which I add to my systemPackages:
gccEnv = ( (pkgs.buildEnv rec{ name = "gccEnv"; paths=buildInputs; buildInputs = [pkgs.gcc]; }) );
This results in a working VM, but the gccEnv directory in the nix-store only has what I would get with gcc in systemPackages, so things like gcov are not included.
Are there any other approaches to producing an offline C development environment with NixOS? Is there some sort of override I need to supply gcc to get it to spit out gcov (I’ve been able to manage overrides for simpler packages but the expression for gcc is a bit over my head
). I realize this use case is not completely typical, but I don’t think it’s that insane either?
Greatly appreciate any ideas and help!