Skip to content

Instantly share code, notes, and snippets.

@txtyash
Last active November 4, 2023 19:56
Show Gist options
  • Save txtyash/4d0aadd3d10a35866ef93fbc046fb038 to your computer and use it in GitHub Desktop.
Save txtyash/4d0aadd3d10a35866ef93fbc046fb038 to your computer and use it in GitHub Desktop.
submodules
{
lib,
config,
...
}: {
imports = [./options.nix ./yash];
config.profiles.yash.editor = "nvim";
# Generate this: users.users.yash.description = "Yash Shinde";
# using the line below
config.profiles.yash.description = "Yash Shinde";
# This gives users.users.yash.description = "Yash Shinde".
# WHY DOES THIS WORK?????
config.users.users =
lib.mapAttrs (
name: values: {
description = values.description;
}
)
config.profiles;
config.warnings = lib.mapAttrsToList (name: cfg: "I am ${name} and my editor is ${cfg.editor}") config.profiles;
}
{
config,
lib,
...
}: let
settings = {
options = {
editor = lib.mkOption {
type = lib.types.str;
};
description = lib.mkOption {
type = lib.types.str;
};
};
};
in {
options = {
profiles = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [settings];
});
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment