Skip to content

Instantly share code, notes, and snippets.

@infinisil
Created August 14, 2023 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinisil/28211d024963f2d7859a38d76b9390c8 to your computer and use it in GitHub Desktop.
Save infinisil/28211d024963f2d7859a38d76b9390c8 to your computer and use it in GitHub Desktop.
(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