I have each host declare their own capabilities (i.e video, sound, bluetooth etc.) in a dedicated system.nix file within hosts/<hostname>.
Both Nixos configurations and home-manager configurations parse those capabilities before enabling certain apps and features.
For example, Hyprland (the wayland compositor) will not be enabled unless all conditions are met:
video is enabled (sys.video.enable)
user environment is wayland (env.isWayland)
Hyprland is set as the main desktop (usrEnv.deskstop == Hyprland)
Checking for each declaration is a tedious process, because we need to first declare things like sys (which corresponds to config.modules.system) or usrEnv (which corresponds to config.modules.userEnv) in a let in block for the current scope.
Ideally, we should be able to have validator functions to declare each one of those just once, and then evaluate those functions later on.
I.e a function that goes isHyprland should check if video is enabled, if user environment is wayland and if Hyprland is set as the main desktop, then return true if all three of those evaluate to true.
Then a program can be enabled conditionally.
I.e programs.waybar.enable = isHyprland;
Current limitation is that the config attribute Nixos accesses is not directly accessible in home-manager.
Where nixos does config.modules.video, home-manager has to do osConfig.modules.video - which (seemingly?) requires to functions, one for each infrastructure taking config and osConfig as arguments to the function respectively.
Edit: it is as simple as setting the argument to the function as config or osConfig:
I have each host declare their own capabilities (i.e video, sound, bluetooth etc.) in a dedicated
system.nix
file withinhosts/<hostname>
.Both Nixos configurations and home-manager configurations parse those capabilities before enabling certain apps and features.
For example, Hyprland (the wayland compositor) will not be enabled unless all conditions are met:
Checking for each declaration is a tedious process, because we need to first declare things like
sys
(which corresponds toconfig.modules.system
) orusrEnv
(which corresponds toconfig.modules.userEnv
) in a let in block for the current scope.Ideally, we should be able to have validator functions to declare each one of those just once, and then evaluate those functions later on.
I.e a function that goes
isHyprland
should check if video is enabled, if user environment is wayland and if Hyprland is set as the main desktop, then return true if all three of those evaluate to true.Then a program can be enabled conditionally.
I.e
programs.waybar.enable = isHyprland;
Current limitation is that the config attribute Nixos accesses is not directly accessible in home-manager.
Where nixos does config.modules.video, home-manager has to do
osConfig.modules.video
- which (seemingly?) requires to functions, one for each infrastructure taking config and osConfig as arguments to the function respectively.Edit: it is as simple as setting the argument to the function as
config or osConfig: