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

Practically composable devShell modules #133

Closed
srid opened this issue Mar 30, 2023 · 1 comment
Closed

Practically composable devShell modules #133

srid opened this issue Mar 30, 2023 · 1 comment
Labels
DX Developer Experience enhancement New feature or request

Comments

@srid
Copy link
Owner

srid commented Mar 30, 2023

I can't think of an easy to way to fully modularize the nix devShell, however I think we can get closer.

Unlike flake-parts mkFlake, we start with a base devShell (ie., whatever shellFor returns), and then build up the mkShellArgs values using the module system. So, instead of:

      devShell = {
        nativeBuildInputs = [
          config.mission-control.wrapper
          pkgs.pre-commit
        ];
        shellHook = ''
          FLAKE_ROOT="''$(${lib.getExe config.flake-root.package})"
          export FLAKE_ROOT

          (cd FLAKE_ROOT && ${config.pre-commit.installationScript})

          ${config.mission-control.banner}
        '';
      }

the user simply have to write:

      devShell = {
        module = {
          imports = [
            config.mission-control.devShellModule
            config.flake-root.devShellModule
            config.pre-commit.devShellModule
          ];
        };
      }

Those 3 modules (mission-control, flake-root, pre-commit) would export the associated config that will be merged. Like #82, we can't predict the order of merging, so things like shellHook could be problematic in some cases.

All of this can happen in separate repo, and haskell-flake can simply use that to evaluate the final mkShellArgs from the given module.

@srid srid added enhancement New feature or request DX Developer Experience labels Mar 30, 2023
@srid
Copy link
Owner Author

srid commented Mar 30, 2023

Closing in favour of #135

@srid srid closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer Experience enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant