I have code in a file which is always loaded but contains parts which are linked to a file which are not loaded. How can I detect whether an option is available or ignore the code otherwise.
Error:
error: The option `ncfg.persist' does not exist. Definition values:
- In `/nix/store/xxx-source/modules/scripts':
{
_type = "if";
condition = false;
content = {
homeLinks = [
persist.nix file which is not always loaded and gives an error building. For machines they are loaded, not for building an iso.
options.ncfg.persist.enable = lib.mkEnableOption "a root with explicit opt-in state";:
scripts.nix file which is always loaded:
..
options.ncfg.scripts.something.enable = lib.mkEnableOption "Enable something";
config = lib.mkMerge [
..
# This doesn't seem to work
(lib.mkIf (config.ncfg.scripts.something.enable && config ? "ncfg" && config.ncfg ? "persist") {
ncfg.persist.homeLinks = [{ path = "somepath"; type = "persist"; }];
})
..
];
..