Skip to content
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

Load TOML shells with numtide/devshell #78

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vic
Copy link

@vic vic commented Feb 18, 2025

This changeset loads TOML devshells using numtide/blueprint.

The only requirement is that the user's flake has an input.devshell otherwise they will be told to add it.

I still have to add documentation for this feature.

Basically, if you have any /devshells/*.toml or /devshell.toml they will be loaded with something like devshell.fromTOML but that allows custom nix modules to also access packages from perSystem.self.

I'm using this branch at my local nixos setup, see https://github.com/vic/vix/tree/main/devshells for some devshells I've defined, particularly nixos.toml that imports nixos/leader.nix which can access packages defined in the flake itself.

The old behaviour is still preserved, and any .nix files will still be loaded as-is. So those nix files are responsible for using either nixpkgs's mkShell or devshell's one. For example, my scala3.nix customizes the JRE for some tools.

I'll be adding documentation tomorrow, and would love if you could direct me on how to write tests for this functionality.

Cheers :)

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, this is going in the right direction.

The best way to add a test at the moment is to create a new template/devshell example that exercises the feature.

);

defaultNix = (
optionalPathAttrs (src + "/devshell.nix") (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of any way for blueprint to detect if the devshell.nix is a numtide/devshell module? Otherwise it could be confusing to the user to have the TOML in one system, and the other one in another one.

@vic
Copy link
Author

vic commented Feb 21, 2025

Hey @zimbatm, thanks for the pointers on how to test :)
Added a template and checks on this commit: 1db26a0

Still have to write documentation.

vic added 3 commits February 21, 2025 16:59
The new template exercises some features:

- TOML devshells are loaded automatically if found.
- Nix shells behaviour is preserved: Users are expected to call
  `mkShell` themselves.

  Added some documentation explaining why users should call `mkShell`
  at `devshells/hello.nix`

- TOML devshells (and also Nix devshells) can import modules.

The template flake also has a couple of checks, ensuring that
the devshell commands are correctly provided.
@vic vic force-pushed the load-toml-devshells branch from 795f879 to aa0ae9a Compare February 21, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants