Created
August 14, 2023 14:49
-
-
Save infinisil/28211d024963f2d7859a38d76b9390c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import <nixpkgs/lib>).evalModules { | |
modules = [ | |
({ lib, config, ... }: { | |
options.foo = lib.mkOption { | |
type = lib.types.int; | |
}; | |
options.bar = lib.mkOption { | |
default = { }; | |
type = lib.types.attrsOf (lib.types.submodule { | |
options.baz = lib.mkOption { | |
type = lib.types.str; | |
default = "don't know"; | |
}; | |
}); | |
}; | |
config = { | |
foo = 10; | |
#bar.x = { | |
# baz = lib.mkIf (config.foo > 5) "foo is greater than 5"; | |
#}; | |
#bar = lib.mkIf (config.foo > 5) { | |
# x.baz = "foo is greater than 5"; | |
#}; | |
bar = lib.mkMerge [ | |
{ | |
x.baz = "other module"; | |
} | |
(lib.mkIf (config.foo > 5) { | |
x.baz = lib.mkDefault "foo is greater than 5"; | |
}) | |
#(lib.mkIf (config.foo <= 5) { | |
# x.baz = lib.mkDefault "foo is less than 5"; | |
#}) | |
]; | |
}; | |
}) | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment