The question is how I should pass hostName from home.nix to a sub module (lf.nix in my example). (Or, alternatively, how to access networking.hostName if possible.)
Is this in the context of NixOS configuration or home-manager configuration? If it’s home-manager running on NixOS, you should be able to use osConfig as a module argument to access the configuration of the NixOS host. In this context, think you might be able to get the hostname as osConfig.networking.hostName.
There’s an example in the Home Manager Manual that sounds like what you might be looking for (search osConfig).
Thanks a lot, @devusb. This was exactly was I was looking for, as it was home-manager config.
{ lib, osConfig, ... }:
let
inherit (import ../../../hosts/${osConfig.networking.hostName}/options.nix) lf;
in
{
programs.lf.enable = lib.mkIf lf true;
}
(For the record, I also found a following related post, about sending parameters into an imported module. However, nrdxp’s solution did not work for me. The statement ../../modules/programs/lf/lf.nix { hostName = "koala"; } resulted in an error saying that hostName is not defined. Maybe it is since I am doing it from inside home-manager.)