我正在尝试根据主机名设置配置
config = lib.mkMerge [
( lib.mkIf config.networking.hostName == "nuc" {
config.installconfig.hardware.intel = true;
} )
( lib.mkIf config.networking.hostName == "xps" {
config.installconfig = {
hardware.intel = true;
workstation-components.enable = true;
users.allow-rad = true;
};
} )
];
我在“nuc”处收到以下错误
error: attempt to call something which is not a function but a string.
我理解该错误,但我不确定如何构造 lib.mkIf 条件块。
有人可以帮我解决这个问题吗?
您需要将条件句的各个部分组合在一起:
let
config = pkgs.lib.mkMerge [
(pkgs.lib.mkIf (config.networking.hostName == "nuc") {
config.installconfig.hardware.intel = true;
})
(pkgs.lib.mkIf (config.networking.hostName == "xps") {
config.installconfig = {
hardware.intel = true;
workstation-components.enable = true;
users.allow-rad = true;
};
})
];
in
config.contents