-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mkShell: add builder #30975
mkShell: add builder #30975
Conversation
For now I am looking for feedback on the following things:
|
It would be nice if the shellHooks where composable |
pkgs/build-support/shell-builder.nix
Outdated
|
||
buildInputs = mergeInputs' "buildInputs"; | ||
nativeBuildInputs = mergeInputs' "nativeBuildInputs"; | ||
propagatedBuildInputs = mergeInputs' "propagatedBuildInputs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing propagatedNativeBuildInputs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't know this existed, but makes sense. Fixed in b111860 which will be squashed later
@zimbatm Could you also add documentation to the manual for this? Edit: I see you asked where to document.. good question ;-) |
bump - i would love to see this merged. What's the status? |
pkgs/top-level/all-packages.nix
Outdated
@@ -301,6 +301,8 @@ with pkgs; | |||
inherit kernel rootModules allowMissing; | |||
}; | |||
|
|||
mkShell = callPackage ../build-supports/shell-builder.nix { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be build-support
, not build-supports
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest moving it into ../build-support/mkshell/default.nix
anyway. Quiet a few derivations there are already single file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
pkgs/build-support/shell-builder.nix
Outdated
buildInputs ? [], | ||
nativeBuildInputs ? [], | ||
propagatedBuildInputs ? [], | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing propagatedNativeBuildInputs
here (or not, and the others are not needed too?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
pkgs/build-support/shell-builder.nix
Outdated
# A special kind of derivation that is only meant to be consumed by the | ||
# nix-shell. | ||
{ | ||
mergeInputs ? [], # a list of derivations whose inputs will be merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not explain what it means for an input to be "merged". (And it's not clear to me from your description.)
Also, linguistically, mergeInputs
sounds like a Boolean variable, i.e. whether or not to merge inputs, not "list of things to be merged".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about inputsFrom
? a list of derivations whose inputs will be made available to the environment
Nice, |
I realize that the doc needs to be improved, will do another round tomorrow. |
Is this coming to |
This is a new feature so it will land in 18.04 |
The I'm wondering if one major usecase is say you have multiple projects each with their own @zimbatm Could you enumerate what other usecases you envision for Also with regards to merging shell hook, this is definitely something that would be cool as well as long as the shell hooks were written in a way that didn't conflict with each other. My project's shell hook tends to be creating relevant environment variables. So they could be automerged. However I'd imagine in some cases you wouldn't want to auto merge them. Maybe some function that can explicitly compose the shell hooks based on the |
Yes that's exactly the use-case that I had in mind. Imagine you have a monorepo with multiple services, each in their own folder with their own default.nix that you can nix-shell and nix-build. On the top-level you can then add a shell.nix with, shellHooks are a bit more tricky because they also tend to assume things about |
How should |
I don't have a satisfying answer and would be interested in figuring this out. Aside from changing the One idea is to require each environment to provide a function that takes the project root as an argument. Eg: For now I just use |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-shell-tips-tricks-and-best-practices/22332/1 |
Motivation for this change
For nix-shell-only scenarios, this is a small optimization to make it nicer such that:
Is simplified to:
It also fails when trying to build it directly:
And finally, it supports the scenario where one wants to compose the shell with different inputs from various packages: