What’s really great about Nix is that we can define a package derivation and get a development shell for free. Only that sometimes simply doing nix develop .#myPackage is not enough for a real-life development shell (e.g. maybe I want a static analysis tool in my path, …). I’d like to be able to take the shell created by my package derivation and extend it.
There is inputsFrom but this (as the name implies) only works for the inputs. I recently had a case where I defined hardeningDisable in my package derivation. This is not inherited by using inputsFrom. Is there a way to achieve this? In my dream world, there would be something like inherit, which would take a list of packages or devShells and inherit all their inputs and options. Maybe I’m missing something here? Thanks!
If you need one package why not just use .overrideAttrs? I’m not aware of a way to combine multiple packages together though and I’m not sure how that should even work
Hmm yeah that could work. I would lose mkShell functionality, like shellHook, though. Also it just doesn’t really feel right, I think mkShell should be able to do this. Maybe let’s look at inheriting from a single package for now (multiple packages may be not feasible anyway, as you noted). I think the use case is valid: I want to be able to get the exact build environment of the package + other inputs and shellHook stuff (like environment variables, aliases, etc…).
If you’d call overrideAttrs on the package you pass into inputs from, then the shell will take the inputs from the overridden package. On mobile so young the example out would take a lot of work…
symlinkJoin does that; it wouldn’t have the desired effect here, though.
I think @waffle8946 assumed you were doing some kind of override on the package included in inputsFrom, and just wanted to get the inputs from the overridden package. At least that was my interpretation. You’d do that as such for the record:
If I interpret your example correctly, though, you’re trying to inherit environment variables set in the build environment.
I think the closest you can get is to filter out attributes from your input that are ALL_CAPS and then to include all those. You’d have to also hard-code a pretty selective filter on top of that to prevent leaking stuff like $HOME and whatnot. This’d take a lot of work, and even more maintenance.
I don’t believe there is a good generic way to achieve what you want.