There’s a way you can do this without disrupting your main flake.lock. It also doesn’t require running nix develop multiple times.
- Create subdirectory in your project. Say
mkdir extra. - Create a new
extra/flake.nixfile. Have that flake refer to the mainflake.nixas an input. - Add
extra/flake.nixandextra/flake.lockto the git index but hide it from your commits.
git add --intent-to-add extra/flake.nix
git update-index --assume-unchanged extra/flake.nix
Here’s what your extra/flake.nix might look like (you could write a cleaner flake, but I hope you get the idea):
{
description = "Extra";
inputs.otherFlake.url = "path:..";
outputs = { self, otherFlake, ... }:
{
devShells.x86_64-linux = let
pkgs = import otherFlake.inputs.nixpkgs { system = "x86_64-linux"; };
in {
default = pkgs.mkShell {
buildInputs =
otherFlake.outputs.devShells.x86_64-linux.default.buildInputs
++ [ pkgs.hello ];
};
};
};
}
Then you can just run nix develop ./extra instead of nix develop . (no direnv required).