-
Notifications
You must be signed in to change notification settings - Fork 89
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
Document how to share devshell modules #52
Comments
note, I don't expose mine in my flake yet - I've recently been thinking about this too. I have lots of lofty ideas with fuzzy handwaving around devshells and it intersects with a lot of the questions you prompt here @blaggacao. I don't have much to contribute right now, I have too many other things I really need to finish first. |
I'd love to hear of those lofty handwaving thoughts. 😉 If only for the pure joy of waving back at them, or — in fact — trying to broker the hearsay through the graph. |
Since devshell uses the nix module system, I think we should take advantage of that more. There is already one project that uses it successfully. Potentially flakes could export a devshellModules attribute that is a list of modules to load. This would then allow composing the module definitions into the current shell. |
Thank you! Sounds like a good idea, I'll adapt my exploratory draft PR over at nixflk accordingly. |
@zimbatm, could you expand on this more. What do mean by nix modules? Surely you don't mean NixOS modules 😜 |
I think this refers to the way a numtide/devshell is configured and read. I understand that those devshell configurations can be made composable modules. |
Thanks, makes perfect sense. |
There are actually two levels to share shells.
The other way, that would work with the devshell project is to export some nix modules. Since devshell is extensible using the same module system as NixOS, extensions could be written and exported out of a flake attribute. In that scenario, the setup is a bit more complicated. First, there is a flake that exports the modules. {
outputs = inputs: {
# A module that generates per-project TLS certificates.
devshellModules.certificates = { config, lib, ... }: {
options.certificates = {
enable = lib.mkEnableOption "certificates";
# TODO: add real config here
};
config = lib.optionalAttrs config.certificiates.enable {
# TODO: set some devshell config here, like add a new command
};
};
};
} Then on the consumer side: {
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.devshell.url = "github:numtide/devshell";
inputs.devshell-modules.uri = "github:numtide/devshell-modules"; # does not exist
outputs = { self, flake-utils, devshell, devshell-modules, nixpkgs }:
flake-utils.lib.simpleFlake {
inherit nixpkgs;
name = "my-project";
preOverlays = [ (import devshell.overlay) ];
shell = { pkgs }:
pkgs.mkDevShell {
imports = [ (import devshell-modules.devshellModules.certificates) ];
# Now the certificates options are available
certificates.enable = true;
};
};
} Something like that. As you can see it's much more complicated to use. But it allows changing the behavior of devshell. |
I would be opposite to opposed to |
Playing around with this idea: https://github.com/nrdxp/nixflk/pull/39/files done so in nixflk to encourage sharing by default, but any community curated devshells should probably live in EDIT: also divnix/digga#55 for a more useful attempt. |
After some thought, for the first sharing use case mentioned, I think A simple project-proper use case:
How should this be proposed / approached for most chances of success and effectiveness? |
One possible implementation / blueprint for docs: divnix/digga#24 (Exported as |
we just use |
Sorry for necroposting here, but in case anyone stumbles upon this and tries to use the module method described in #52 (comment) (notably These are working snippets (atm) that should get you going:
|
I think flakes are an excellent code / knowledge sharing platform infrastructure.
I would like to seek structural guidance (later on: eg. examples / templates) on how to combine those ideas in a proper way.
I'm also wondering, how user provided devshells would / could / should interact with project provided devshells.
The text was updated successfully, but these errors were encountered: