NotAShelf / nyx

My overengineered NixOS flake. Desktops, laptops, servers and everything else that can run an OS.
https://nyx.notashelf.dev/
GNU General Public License v3.0
292 stars 8 forks source link

Extend nixpkgs lib to streamline capability checks #11

Closed NotAShelf closed 8 months ago

NotAShelf commented 1 year ago

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:

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:

NotAShelf commented 8 months ago

Closed by #24