tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add global enable option

CryoMyst opened this issue · comments

I am trying to abstract this module behind a custom module of my own inside my flake.
However since imports cannot be within a config block and defaults are set upon importing of the module itself unconditionally for example in kernel this creates an undesirable situation where I would have to reset most options back to default which seems fragile on updates if new ones are added.

Would it be possible to make a global options.hardware.asahi.enable defaulting to true that either everything checks or add new enable options for each submodule which is set by default by this global?

I might also be missing something with nix that would help deal with this setup however most searches on conditional imports don't yield anything.

This would not be difficult, but is there some reason that adding this module (and its settings) as a top level one to just your Apple Silicon configuration would not meet your needs?

That is currently what I am doing to get around this limitation.
It just felt a little weird to have a 2 way "dependency" direction between the Systems and the Module part of the flake. Where the module uses an import from systems and systems uses options from the module and only if that import happens are parts of the module actually valid.
I could perhaps use hasAttr in an assertion to determine if the module is imported to give a nicer error in this case.

flowchart TB
    flake["flake.nix"]
    library["Lib"]
    module["Custom Module"]
    systems["Systems (configuration.nix)"]
    
    flake-->library
    flake-->module
    flake-->systems
    
    module-->library
    
    systems<-- Here -->module

This does not look too difficult to do. I will add it in the next release.

Added to the latest release.