Hello,
I’m trying to write the following code, in order to have a configuration that can adapt to virtual machines (by removing the hardware configuration). So I wrote:
{ config, pkgs, lib, isVM ? false, ... }:
{
imports =
(lib.optional (!isVM) ./hardware_configuration.nix) ++
[
./users_management.nix
];
}
But it fails with:
error: infinite recursion encountered, at /nix/store/m59d3v89nhp9207hgvf6v21wxq7lhq64-source/lib/modules.nix:217:28`
I tried to put an empty file inside hardware_configuration.nix
, and the error is present, until I remove the line (lib.optional (!isVM) ./hardware_configuration.nix)
. Any idea what’s wrong?
– EDIT –
It’s actually weird enough that, with a nearly empty bidon.nix
file:
(if (!isVM) then [ ./bidon.nix ] else [ ./bidon.nix ]) ++
also fails, but:
[ ./bidon.nix ] ++
works. So it’s like if nix has trouble to give a value to isVM
, but the isVM ? false
should make it clear no?