Shared nix flake for nix flakes in the same repo

I have a monorepo providing different development shells for different purposes:

$ tree devShells/
├── minimum
│   ├── flake.lock
│   └── flake.nix
├── spec
│   ├── flake.lock
│   └── flake.nix
└── whitehat
    ├── flake.lock
    └── flake.nix

To use them:

$ nix develop path:devShells/minimum
$ nix develop path:devShells/spec

The problem is, these flake.nix files have some shared build inputs, but I have yet to find a way to somehow not to repeat those in these flakes. For example: I tried to include a shared flake.nix from a parent directory through relative path [FAILED].

P.S.: they can be found here protocol-monorepo/devShells at dev · superfluid-finance/protocol-monorepo · GitHub

I would recommend using one flake.nix with different devShells as outputs.

Then you should be able to use them like this:

$ nix develop path#minimum
$ nix develop path#spec

Ah, makes sense, that’s better

1 Like