For quite some time I have a single Git repo to maintain multiple hosts and virtual servers. Ignoring the multi-host aspect, my setup is like this:
/flake.nix - entry point for nixos config
/servers/flake.nix - configures all servers / adds systemd files…
/servers/vm01/flake.nix - some server as VM
/servers/cont23/flake.nix - some server as container
Each subdirectory / flake can live on its own and is a valid flake. So is the servers-flake (that creates a module-list for nixosConfigurations). So no flake depends on its parent.
This worked fine for quite some time, but since 2.26+ I run into errors with lock files. Here is a MVP-reproducer:
/flake.nix
{
description = "Main flake: uses servers flake";
inputs = {
servers.url = "path:./servers";
};
outputs = { self, servers }:
{
packages.x86_64-linux.default = servers.server;
};
}
/servers/flake.nix
{
description = "Servers flake: aggregates individual server flakes";
inputs = {
foo.url = "path:./foo";
};
outputs = { self, foo }:
{
server = foo.foo;
};
}
servers/foo/flake.nix
{
description = "Foo flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
};
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
{
foo = pkgs.hello;
};
}
An initial nix run works as expected. But then, a flake.lock is created and a further run results in:
$ nix run
error:
… while evaluating the attribute 'server'
at /nix/store/4zfn4xmmsp3j4qmi42mbp782rczlpva0-source/servers/flake.nix:10:7:
9| {
10| server = foo.foo;
| ^
11| };
… while evaluating the attribute 'foo.result'
at «flakes-internal»/call-flake.nix:98:7:
97| {
98| result =
| ^
99| if node.flake or true then
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: path '/nix/store/4zfn4xmmsp3j4qmi42mbp782rczlpva0-source/servers/servers/foo/flake.nix' does not exist
For some reason servers is twice in the path.
I’ve been pulling my hair out over this since weeks, and all super-duper AI to the rescue couldn’t help me either…
I really hope, someone can tell me what I’m doing wrong here. Any help very much appreciated!