Hi!
How can I import different files based on hostname in home-manager as a nixos module? This is what I was trying to do:
{ config, lib, osConfig, ... }:
lib.mkMerge [
(lib.mkIf (osConfig.networking.hostName == "dell-1") {
imports = [ ./dell-1.nix ];
})
(lib.mkIf (osConfig.networking.hostName == "dell-2") {
imports = [ ./dell-2.nix ];
})
(lib.mkIf (osConfig.networking.hostName == "dell-3") {
imports = [ ./dell-3.nix ];
})
]
But that gives me this error:
[root@dell-1:/etc/nixos]# nixos-rebuild switch
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/attrsets.nix:1574:11:
1573| || pred here (elemAt values 1) (head values) then
1574| head values
| ^
1575| else
… while evaluating the attribute 'value'
at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/modules.nix:846:9:
845| in warnDeprecation opt //
846| { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
847| inherit (res.defsFinal') highestPrio;
… while evaluating the option `system.build.toplevel':
… while evaluating definitions from `/nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/nixos/modules/system/activation/top-level.nix':
… while evaluating the option `assertions':
… while evaluating definitions from `/nix/store/9hhihnwyflj1m47f23yja31mnxckp3ph-source/nixos/common.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `home-manager.users.kazimierzkrauze.imports' does not exist. Definition values:
- In `/nix/store/diyr1y8nlqs4cii0vky1wx87y851yh7r-source/home-manager/kazimierzkrauze/syncthing/syncthing.nix':
{
_type = "if";
condition = true;
content = [
/nix/store/diyr1y8nlqs4cii0vky1wx87y851yh7r-source/home-manager/kazimierzkrauze/syncthing/dell-1.nix
...
[root@dell-1:/etc/nixos]#