Can one have a “workspace” like workflow with nix, flakes and multiple repositories, including nixpkgs? Here’s what I mean, what I have now, and it seems to mostly work, but I’m afraid, and there are parts where it doesn’t. I’m curious to hear how other people are approaching setups like this.
With “workspace-like”, here’s what I’d like to have:
- Allow individual direnvs to work in individual directories (subrepositories) of the project.
- Avoid needing to push every development version to github or some similar public URL for testing to make nix happy.
- Avoid needing to push to github fixed paths to my home directory. Currently I’m failing this.
My nix_observe/flake.nixpoints topath:/home/sliedes/proj/observe/nixpkgs. - Being able to work in an IDE like vscode neatly so that I add the three directories,
nix_observe,nixpkgsandtopin a vscode workspace as folders.
Currently I have a directory structure like
workspace/.git
workspace/nix_observe/.direnv
workspace/nix_observe/.git
workspace/nix_observe/flake.nix
workspace/nixpkgs
workspace/nixpkgs/.git
workspace/top/.direnv
workspace/top/flake.nix
(Context for the curious: nix-observe is a transparent wrapper for executing programs and observing the execution. Very much WIP and experimental, but I want to bring visibility to builds. It is intended to wrap command executions, like nix-observe -- gcc -c foo.c -o foo — also for ld, make, ninja, … . I can discuss that too if someone is curious, but we might want to do that in a different topic. I don’t make any claims of it being suitable for anything, yet.)
top/flake.nix is intended to implement whatever is needed to make nixpkgs use the wrapper around whatever I want to wrap. nixpkgs is there because I plan to edit it too. And the whole setup is structured as a directory tree in order to avoid necessary round trips to github, which is a pain point I’ve had when working with nix as a nix beginner.
Non-goals:
While I ended up using git submodules to make nix happy, tracking precise version dependencies between the three git repositories while developing is at this point a non-goal.
Questions:
- Can I somehow reasonably have
nixpkgs.urlinnix_observe/flake.nixpoint to some generally reasonable place (like github nixpkgs), yet persistently getdirenvto use../nixpkgsfor it when I’m undernix_observe/? It just seems wrong to have something in github pointing to a path in my computer. - Is there some silly pitfall?
- Can this be done without git submodules? Or are they just the right tool for this?
In my top/flake.nix, I do this:
{
inputs = {
self.submodules = true;
nixpkgs.url = ../nixpkgs;
nix-observe = {
url = ../nix_observe;
inputs.nixpkgs.follows = "nixpkgs";
};
};
...
}
While this overrides nix_observe.nixpkgs to be what I want for the top flake, it doesn’t help direnv when inside nix_observe/…